Jump to content

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
https://forums.kleientertainment.com/forums/topic/56229-whats-wrong-with-my-code/
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.

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