jimmosio Posted May 29, 2015 Share Posted May 29, 2015 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 https://forums.kleientertainment.com/forums/topic/54559-is-it-really-necessary-to-edit-an-item-to-let-a-character-eat-it/ Share on other sites More sharing options...
Blueberrys Posted May 29, 2015 Share Posted May 29, 2015 @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 https://forums.kleientertainment.com/forums/topic/54559-is-it-really-necessary-to-edit-an-item-to-let-a-character-eat-it/#findComment-641995 Share on other sites More sharing options...
Mobbstar Posted May 29, 2015 Share Posted May 29, 2015 (edited) 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 May 29, 2015 by Mobbstar Link to comment https://forums.kleientertainment.com/forums/topic/54559-is-it-really-necessary-to-edit-an-item-to-let-a-character-eat-it/#findComment-641998 Share on other sites More sharing options...
jimmosio Posted May 29, 2015 Author Share Posted May 29, 2015 (edited) 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 May 30, 2015 by jimmosio Link to comment https://forums.kleientertainment.com/forums/topic/54559-is-it-really-necessary-to-edit-an-item-to-let-a-character-eat-it/#findComment-642010 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now