Jump to content

Recommended Posts

Ive been making my first modded character for a bit now and I've run into an issue I cant see a way to solve, I can't find a way to give the Glow Berry light effect to other foods. I don't have much experience in coding (have been using this as a learning project); but pulling code from the wormlight prefab file and putting it within a AddPrefabPostInit in my modmain has only resulted in a crashes so far. I was looking to pull it from the glow berry mousse but I cant find its prefab file.

I have found this chunk of code on the single player Don't Starve modding forums as a response to someone asking the same question -

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)

And when plugged into my modmain I get the error -

Quote

[00:02:00]: error calling PrefabPostInit: moonrocknugget in mod Worldeater Ryihaj (Worldeater Ryihaj Ashke Ralithizzad):
[string "scripts/components/edible.lua"]:143: attempt to index local 'self' (a function value)
LUA ERROR stack traceback:
        scripts/components/edible.lua(143,1) in function 'SetOnEatenFn'
 

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