Jump to content

[Info] Modifying quaker component's drop table


Recommended Posts

Not sure why @Terra M Welch decided to hide their topic, but here's my code from the thread for doing this task for anyone searching in the future.

The user wanted to remove the items in 'lootblacklist' table from potentially dropping from the table, and this does that.

local lootblacklist = {
    goldnugget = true,
    rabbit = true,
    mole = true,
    redgem = true,
    bluegem = true,
}
AddComponentPostInit(
    "quaker",
    function(inst)
        if not GLOBAL.TheWorld.ismastersim
        then
            return
        end
        if GLOBAL.TheWorld.worldprefab ~= "cave"
        then
            return
        end
        local index = 1
        while true
        do
            local name, upvalue = GLOBAL.debug.getupvalue(inst.SetDebris, index)
            if name == nil
            then
                break
            end
            if name == "_debris"
            then
                local newdebris = {}
                for i, lootset in ipairs(upvalue)
                do
                    local newlootset = {}
                    for k, v in pairs(lootset)
                    do
                        if k == "loot"
                        then
                            local newdrops = {}
                            for i, drop in ipairs(v)
                            do
                                if lootblacklist[drop] == nil
                                then
                                    GLOBAL.table.insert(newdrops, drop)
                                end
                            end
                            newlootset.loot = newdrops
                            if #newdrops > 0
                            then
                                GLOBAL.table.insert(newdebris, newlootset)
                            end
                        else
                            newlootset[k] = v
                        end
                    end
                end
                -- Doing it like this because doing 'upvalue = newdebris' won't set the reference pointers to the upvalue used elsewhere
                local c = #upvalue
                for i=1, c
                do
                    upvalue[i] = nil
                end
                for i, v in ipairs(newdebris)
                do
                    GLOBAL.table.insert(upvalue, v)
                end
                break
            end
            index = index + 1
        end
    end
)
Link to comment
Share on other sites

I hid the topic for a reason, I didn't wish to get involved with some complicated jumble of coding for something as silly as a project that will likely flop anyway. I honestly want people to not use that mod, and do not plan to mess around with it any further.

Now please, keep me out of the subject, I am getting very sick of it, and want it to just be over with.

Let others use it, but please, leave me out of it from here on out.

Edited by Terra M Welch
Link to comment
Share on other sites

6 minutes ago, IronHunter said:

This is really helpful, it is extemely annoying how much of the game is not modder friendly and workarounds have to be composed to accomplish simple tasks.

Most of the unfriendly code stems from the base game (Don't Starve SP).  Some of Klei's devs decided to encapsulate public/private variable methodology into their works, which is really bad for modding purposes.

Ideally this component would have a reference to the _debris table stored onto the component itself, freely able to be changed at any point in time.

Since there's none of that, the debug library has to be used to gain access to this "private" local variable.

 

3 minutes ago, Terra M Welch said:

I hid the topic for a reason, I didn't wish to get involved with some complicated jumble of coding for something as silly as a project that will likely flop anyway. I honestly want people to not use that mod, and do not plan to mess around with it any further.

Now please, keep me out of the subject, I am getting very sick of it, and want it to just be over with.

Let others use it, but please, leave me out of it from here on out.

My solution posted there could have helped others in the future, but by hiding it you essentially took my code and put it into the trash bin.

It's not nice to me nor the potential future readers.

Edited by CarlZalph
Link to comment
Share on other sites

1 minute ago, CarlZalph said:

Most of the unfriendly code stems from the base game.  Some of Klei's devs decided to encapsulate public/private variable methodology into their works, which is really bad for modding purposes.

Ideally this component would have a reference to the _debris table stored onto the component itself, freely able to be changed at any point in time.

Since there's none of that, the debug library has to be used to gain access to this "private" local variable.

In an ideal world =/, at least there are solutions to unideal problems.

Link to comment
Share on other sites

9 minutes ago, CarlZalph said:

My solution posted there could have helped others in the future, but by hiding it you essentially took my code and put it into the trash bin.

It's not nice to me nor the potential future readers.

And by quoting me now you're doing the opposite of what I asked. To please leave me out of it.

It's here now, end of story, let others use it, but I want to be out of this conversation before it gets way too out of hand and the moderators have to break it up.

Link to comment
Share on other sites

5 minutes ago, Terra M Welch said:

And by quoting me now you're doing the opposite of what I asked. To please leave me out of it.

It's here now, end of story, let others use it, but I want to be out of this conversation before it gets way too out of hand and the moderators have to break it up.

I'm not sure where your hostility is coming from or why you're trying to escalate a nonissue into an issue.

It's nothing personal when I mentioned you in this thread, just noting it as both a personal point of confusion as well as to tie my work to who I did the work for.

 

If you're like me and feel compelled to reply back to a quote, then perhaps I may provide the suggestion to not do it in this case.  I will most likely reply back.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...