Jump to content

Custom Item Interaction


artaddict

Recommended Posts

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

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

    end

end

 

In the function in which you declared your characters voice (and possibly other powers) you now need to place:

 

inst.components.eater.oneatfn = OnEat

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.

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

    end

end

 

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.

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