Jump to content

[Scripting] Character specific items


Whirt

Recommended Posts

Hi there,

I'm new to modding and I'm trying to create new character (Don't Starve Reign of Giants version) with player specific craftable items and foods. I'm mostly learning from already written scripts and occasionaly find myself searching online. There is one thing bugging me though. 

I have an item - a cup - that needs to be placed into the Crock Pot as well as other ingredients. When the food gets rotten I want it to change to cup filled with rot that needs to be cleaned and if the food is consumed I want the cup to return to players inventory. Now the question is how do I do that. The closest thing to this I could think of was Message in Bottle from Shipwrecked but it didn't help me at all.

If anyone could help me, give me some direction I would very much appreciate it!

Link to comment
Share on other sites

yeah I'm new too but a prefab script worth checking out would be ballphin free tuna, or tunacan.lua for shipwrecked. Cause when you interact with it the can deletes itself and gives the player some cooked fish., which sounds fairly similar to the eating idea you want.

a chunk of the code looks like this, so maybe this could be a bit helpful:

   inst.components.useableitem:SetOnUseFn(function(inst)
        inst.SoundEmitter:PlaySound("dontstarve_DLC002/common/can_open")
        local steak = SpawnPrefab("fish_med_cooked")
        GetPlayer().components.inventory:GiveItem(steak)

        inst:Remove()
    end)

Oh yeah, and for the rotting. I found this in the meats.lua prefab:

    inst:AddComponent("perishable")
    inst.components.perishable:SetPerishTime(TUNING.PERISH_FAST)
    inst.components.perishable:StartPerishing()
    inst.components.perishable.onperishreplacement = "spoiled_food"

 

Looks like you add the perishable component, and you can set it to replace the perished foods with whatever you want, in your case, a dirty cup

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...