Page 1 of 1

Timer and fx:setlight problems

Posted: Sat Sep 22, 2012 9:41 am
by Lmaoboat
I've almost finished a completely script self contained script for creating a number display, and to change the displayed number, I have to remove the lights and create them again. The only way to remove them is set the duration very low and have them time out, but even setting the duration to zero will have them still existing when the script does everything instantly. I didn't want to have to rely on extra external timers to make sure everything happens right, so a tried to make each script spawn it's own. There where my other problem is:

Code: Select all

spawn("timer", self.level, self.x, self.y, 3, "self.name".."time")

time = findEntity("self.name".."time")


time:setTimerInterval(0.1)

time:addConnector("activate", self.name, "makelight()")
time:addConnector("activate", self.name, "test()")

function test()
print("succsess")
end

time:activate()
I know it doesn't have anything to do with the naming, because it tried with static names as well. I'm not getting errors, but I still can't seem to get the timer to do anything.

Re: Timer and fx:setlight problems

Posted: Sat Sep 22, 2012 10:41 am
by Montis
Try the below (you need to replace "self" in the 3rd line to the script entity that contains the makelight function).

Code: Select all

spawn("timer", self.level, self.x, self.y, 3, self.id.."time")
	:setTimerInterval(.1)
	:addConnector("activate", self.id, "makelight")
	:addConnector("activate", self.id, "test")
	:activate()

function test()
print("success")
end

You might also want to add

Code: Select all

	:addConnector("activate", self.id.."time", "deactivate")
so it only runs once after activation.

Re: Timer and fx:setlight problems

Posted: Sat Sep 22, 2012 11:01 am
by Lmaoboat
Can't believe I was using self.name this entire time... and putting in quotes.

Re: Timer and fx:setlight problems

Posted: Sat Sep 22, 2012 11:16 am
by Lmaoboat
Awesome, I think everything might just be working now! You have even hammer the button to no ill effect! Now just to write the timer part again because the editor crashed!

Re: Timer and fx:setlight problems

Posted: Sat Sep 22, 2012 11:27 am
by Montis
Happy to help :)