Jump to content

What's wrong with my code?


Recommended Posts

I'm just trying to create a simple code for testing reasons that will cause spiders to set fire during the day.

 

I created this: 

local function dayfire(inst)
if GetClock():IsDay() and not
inst.components.burnable == nil then do
target.components.burnable:Ignite(true) end
end
end

 

With a listener to call the function:

inst:ListenForEvent("daytime", dayfire)

 

I don't get a error or anything when testing this code, just doesn't do what i want. The spider doesn't set on fire.

 

Anyone know what's wrong?

Link to comment
Share on other sites

"daytime" fires from the world instance ("GetWorld()", or in Together it's "TheWorld"). You can change the source by simply adding a third argument to the listener:

 

inst:ListenForEvent("bla",function,GetWorld())

 

Keep in mind that "inst" in the function becomes the world and not the spider. You can cheat that by constructing the function (without parameters) in the listener, since "inst" is already declared then.

 

On a side note, "not nil" is a double negative. In lua, any existing object that isn't boolean already equals "true" if no logic operations are performed.

Link to comment
Share on other sites

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