Jump to content

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"

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

Actually, I think wood is already edible to beavers. Add the "beaver" food pref to your character!

 

EDIT: you need to listen for "oneat" or "oneatsomething" (as described on the page linked above) for the HP bonus.

Edited by Mobbstar

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()
Edited by jimmosio

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