Jump to content

Recommended Posts

I don't know if there's a way to set it to work on all veggies at once, but I know how to set it to work on all veggies separately.

You basically just need to add to your modmain.lua

 
 GetPlayer = GLOBAL.GetPlayer     (<- Add this one at the very top of the modmain.lua)

    AddPrefabPostInit("carrot", function(inst)
        if GetPlayer().prefab == "YourCharacterHere" then
            inst.components.edible.healthvalue = -10
        end
    end)
    
However this method will require you to add this for every veggie or food in the game that you will want to modify like that.
(You can change the "-10" (which is the HP damage) to whatever other damage you want it to give.)
To make it work, you simply need to replace the "YourCharacterHere" with your character's (prefab) name, and then simply copy-paste the code a bunch of times and replace the "carrot" with other veggie's "code names".  XD 
(If you don't know or are not sure what are the code names of the veggies/food you want to manipulate, them you can head to the don't starve wiki and look for the veggie that you want. Then simply check it's "Debug/Spawn". Those are their code names.)

    So basically your code probably should look like this:
    
    AddPrefabPostInit("carrot", function(inst)
        if GetPlayer().prefab == "YourCharacterHere" then
            inst.components.edible.healthvalue = -10
        end
    end)
    AddPrefabPostInit("carrot_cooked", function(inst)
        if GetPlayer().prefab == "YourCharacterHere" then
            inst.components.edible.healthvalue = -10
        end
    end)
    AddPrefabPostInit("corn", function(inst)
        if GetPlayer().prefab == "YourCharacterHere" then
            inst.components.edible.healthvalue = -10
        end
    end)
    AddPrefabPostInit("eggplant", function(inst)
        if GetPlayer().prefab == "YourCharacterHere" then
            inst.components.edible.healthvalue = -10
        end
    end)
    
And so on...  XD
I hope this will help you if there won't be anybody else that would know how to script it differently in an easier way.    
    
    Also, just in case if you would want to manipulate the amount of hunger or sanity values of each food, here are the codes for that:
    
    inst.components.edible.hungervalue = 0
    inst.components.edible.sanityvalue = 0

    
    Simply add them along with the
    
    inst.components.edible.healthvalue = -10

Edited by BraveChicken

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
×
  • Create New...