artaddict Posted May 1, 2015 Share Posted May 1, 2015 Is there a way to code a character to react to an item differently than other characters do? For example, make a character who restores a little sanity when they eat butterfly wings? I looked at the lua files and the stats for the items are built into the items code, so I am not sure how I would override their stats from the character's lua file. I am brand new at this and I can't find a topic like this anywhere in the forums. I thought I might discover something looking at wigfrid's lua file, since she says, "This is not food for a warrior!" when you try to get her to eat veggies but I can't even find her file and I am pretty sure it won't have what I need anyway. If a forum already exists on this topic a link would be much appreciated. Link to comment https://forums.kleientertainment.com/forums/topic/53416-custom-item-interaction/ Share on other sites More sharing options...
Mobbstar Posted May 2, 2015 Share Posted May 2, 2015 It depends, in your case you want to check something when eating. For that, you can construct a function in your character file: local function OnEat(inst,item) if blablabla then--do stufff endend In the function in which you declared your characters voice (and possibly other powers) you now need to place: inst.components.eater.oneatfn = OnEat Link to comment https://forums.kleientertainment.com/forums/topic/53416-custom-item-interaction/#findComment-633874 Share on other sites More sharing options...
HornetCorset Posted May 2, 2015 Share Posted May 2, 2015 I can't help you directly without looking more closely at the code, but Wigfrid's prefab is in the following location: dont_starve\data\DLC0001\scripts\prefabswathgrithr.lua Link to comment https://forums.kleientertainment.com/forums/topic/53416-custom-item-interaction/#findComment-634100 Share on other sites More sharing options...
artaddict Posted May 3, 2015 Author Share Posted May 3, 2015 I can't help you directly without looking more closely at the code, but Wigfrid's prefab is in the following location: dont_starve\data\DLC0001\scripts\prefabswathgrithr.lua Oh thank you so much that is very helpful! Even if it doesn't help with this specific problem I also needed her lua file for a different project. Link to comment https://forums.kleientertainment.com/forums/topic/53416-custom-item-interaction/#findComment-634258 Share on other sites More sharing options...
artaddict Posted May 3, 2015 Author Share Posted May 3, 2015 It depends, in your case you want to check something when eating. For that, you can construct a function in your character file: local function OnEat(inst,item) if blablabla then--do stufff endend In the function in which you declared your characters voice (and possibly other powers) you now need to place: inst.components.eater.oneatfn = OnEat Thank you, that gives me a good starting point. Link to comment https://forums.kleientertainment.com/forums/topic/53416-custom-item-interaction/#findComment-634261 Share on other sites More sharing options...
Recommended Posts
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.