Jump to content

Recommended Posts

Hello, I'm trying to make a mod where the character can craft a little chunk of slime using health, but my problems are that the item uses durability (instead of spoilage) and that it can't be eaten. I've attached the item's .lua and modmain.lua, ask me about any other information you may need!
(Also, if anyone wants to help me with getting images to work in the crafting menu, that'd be awesome too)

slime_chunk.lua modmain.lua

    FOODTYPE = {
        GENERIC = "GENERIC",
        MEAT = "MEAT",
        VEGGIE = "VEGGIE",
        ELEMENTAL = "ELEMENTAL",
        GEARS = "GEARS",
        HORRIBLE = "HORRIBLE",
        INSECT = "INSECT",
        SEEDS = "SEEDS",
        BERRY = "BERRY",
        RAW = "RAW",
        BURNT = "BURNT",
        ROUGHAGE = "ROUGHAGE",
        WOOD = "WOOD",
        GOODIES = "GOODIES",
        MONSTER = "MONSTER",
    },

There is no definition of FOODTYPE.SWEETENER. I think this should work:

    inst:AddComponent("edible")
    inst.components.edible.healthvalue = slimeChunkHealValue
    inst.components.edible.hungervalue = slimeChunkHungerValue
    inst.components.edible.sanityvalue = slimeChunkSanityValue

    inst:AddComponent("perishable")
    inst.components.perishable:SetPerishTime(slimeChunkSpoilTime)
    inst.components.perishable:StartPerishing()
    inst.components.perishable.onperishreplacement = "spoiled_food"
9 hours ago, yanecc said:

There is no definition of FOODTYPE.SWEETENER. I think this should work:

What FOODTYPE does honey and royal honey use then? I would like to be able to use the slime chunks to craft things like taffy and jellybeans.
 

9 hours ago, yanecc said:
inst.components.perishable.onperishreplacement = "spoiled_food"

I'd like for it to spoil into nothing instead, especially since the character's favourite food is most likely going to be rot.

Apart from that, it is edible now, and it does actually spoil instead of deplete durability! Thanks!

I recommend keeping it FOODTYPE.GENERIC as default (or use FOODTYPE.GOODIES).

10 hours ago, NotLuzeria said:

I'd like for it to spoil into nothing instead

Food would corrupt into nothing by default, just delete it.

    inst.components.perishable:SetOnPerishFn(inst.Remove)
4 hours ago, yanecc said:

I recommend keeping it FOODTYPE.GENERIC as default (or use FOODTYPE.GOODIES).

How can I make the item acceptable as a unit of sweetener for crockpots then?

 

4 hours ago, yanecc said:

inst.components.perishable:SetOnPerishFn(inst.Remove)

It now just no longer spoils at all?

9 hours ago, NotLuzeria said:

How can I make the item acceptable as a unit of sweetener for crockpots then?

In your modmain.lua

AddIngredientValues({ "slime_chunk" }, { sweetener = 1 })

 

9 hours ago, NotLuzeria said:

It now just no longer spoils at all?

    inst:AddComponent("perishable")
    inst.components.perishable:SetPerishTime(slimeChunkSpoilTime)
    inst.components.perishable:StartPerishing()
    inst.components.perishable:SetOnPerishFn(inst.Remove)
8 hours ago, yanecc said:

AddIngredientValues({ "slime_chunk" }, { sweetener = 1 })

yuurpp!! this all works now, thanks
 

8 hours ago, yanecc said:

inst:AddComponent("perishable") inst.components.perishable:SetPerishTime(slimeChunkSpoilTime) inst.components.perishable:StartPerishing() inst.components.perishable:SetOnPerishFn(inst.Remove)

This didn't work, but adding

inst.components.perishable:SetPercent(1)

made it work, strangely. It spoiled before when it spoiled to rot, but making it spoil to nothing made it require this little bit...
Thanks for the help!

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