Jump to content

How to edit existing prefabs via mod??


Recommended Posts

So, I want to make it so you can't use cooked/dried monster meat on the Birdcage; it feels really exploity and Klei even tried to bugfix it out but people complained. Anyway, I can't figure it out- even though birdcage.lua already has it, just commented out. :S I looked at a mod I helped on in the past to edit Willow's lighter and made this, but I can still feed the birds cooked meat. Tried a bunch of other stuff but it all crashed.

 

local invalid_foods = 
{
    "bird_egg",
    "rottenegg",
    "monstermeat",
    "cookedmonstermeat",
    "monstermeat_dried",
}  
AddPrefabPostInit("birdcage")

 

Link to comment
Share on other sites

@Tumalu

local banned_prefabs = {}
banned_prefabs["cookedmonstermeat"] = true
banned_prefabs["monstermeat_dried"] = true

AddPrefabPostInit(
    "birdcage",
    function(inst)
        if not GLOBAL.TheWorld.ismastersim
        then
            return
        end
        if inst.components.trader and inst.components.trader.test
        then
            local trader_test_old = inst.components.trader.test
            inst.components.trader.test = function(self, item, giver, ...)
                if banned_prefabs[item.prefab]==true
                then
                    return false
                end
                return trader_test_old(self, item, giver, ...)
            end
        end
    end
)
Link to comment
Share on other sites

Oh wow, that doesn't look even remotely like what I would have expected! I guess to edit that sort of table just isn't as easy as adding new functions on Willow's Lighter, heh!

Tested and it worked! Thanks a whole bunch <3 With this and the "no ice as filler" mod, I don't have to self-restrict to avoid exploit-y food recipes.

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...