Yo.
Im trying to disable a Sprite, but I can’t seem to get it to co-operate.
Just started Defold
This is my code:
function init(self)
local TimeL = 0
end
function update(self, dt)
TimeL = TimeL + dt
if TimeL > 1 then
msg.post("/main/Map/Room1/light#sprite" , “disable”)
end
if
TimeL > 2 then
msg.post("/main/Map/Room1/light#sprite" , “enable”)
TimeL = 0
end
function on_input(self, action_id, action)
– Add input-handling code here
– Remove this function if not needed
end
Print also did not give me anything at all -.-
but i got this new error:
main/Map/Room1/light/light.script:12: in function <main/Map/Room1/light/light.script:9>
ERROR:SCRIPT: main/Map/Room1/light/light.script:12: attempt to index global ‘TimeL’ (a nil value)
stack traceback:
Yes. You declare TimeL as a local in init(). It won’t exist outside that function. If you want to store state in a game object instance you should set it in the self table:
Not weird “” are special characters and not "" or '' it must be this forum software messing it up when copied, and user copied the special chars into a code block.