minty1 Posted April 20, 2022 Share Posted April 20, 2022 Hey hey! I've started coding a Don't Starve mod character and I am really enjoying the process, so far most problems I have encountered were fixable with a little dedication. Though I am having some trouble with getting the Glowberry light effect to work on a different item. I am not exactly sure what I should do to fix the issue, no idea where to start to be honest. What I want to do is to have a food item where when you eat it and gain a temporary light emitting effect for a lil' bit. I presumed I would be able to be easily copy and paste the code into a prehab file, and then rework the code a little to have it work on a different item. Anything I do results in a crash, freeze or lack of a glowing effect though. I was hoping someone on the forums would be able to help me out with this? Or perhaps, if anyone has a mod that has a food item which provides light when eaten then I would be very thankful if you would post it here. Thanks! *NOTE: I should mention that I have no prior coding knowledge and that this character mod I'm making is quite basic, sort of a practice thing. Link to comment Share on other sites More sharing options...
Leonidas IV Posted May 4, 2022 Share Posted May 4, 2022 I think you can set a OnEatenFn for your food item with this: inst.components.edible:SetOnEatenFn( function(inst, eater) -- This function is from wormlight.lua prefab if eater.wormlight then eater.wormlight.components.spell.lifetime = 0 eater.wormlight.components.spell:ResumeSpell() else local light = SpawnPrefab("wormlight_light") light.components.spell:SetTarget(eater) if not light.components.spell.target then light:Remove() end light.components.spell:StartSpell() end end) Link to comment 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.