Jump to content

Is it really necessary to edit an item to let a character eat it?


Recommended Posts

I want to make a character able to eat wood to gain HP and lose sanity. I looked around in the workshop and found similar mechanics, but all I could see was people editing the item itself to make it edible. The problem with this is that ALL characters can eat that item. Is there another way around? Something in the character's code like:

"If X enters inventory then X is edible, and gives n HP blablabla when eaten"

Link to comment
Share on other sites

@jimmosio Yes.

inst:ListenForEvent("gotnewitem", function(inst, data)	if data.item == "item_prefab" then		-- ...	endend)inst:ListenForEvent("dropitem", function(inst, data)	if data.item == "item_prefab" then		-- ...	endend)

See "..\scripts\components\inventory.lua" for more events you could use instead of gotnewitem and dropitem, if you want.

Link to comment
Share on other sites

I'm looking forward the beaver food pref.

However, I need enlightenment.

 

By adding this simple line, I still can't eat logs (note that I can't eat standard food, which is a good thing because this character eats nothing but wood)

inst.components.eater:SetBeaver()
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...