quindo Posted October 13, 2015 Share Posted October 13, 2015 Hey, I'm working on some small project of mine, I want to create a function where there is a timer, and some other things. The other things need to start after the timer has finished, how can I do it? Here is sample of my code, a tried to put destroyElement and table.remove in another timer, but that doesn't work for me either. setTimer( function() a = math.floor(math.random(#arena)) setTimer( function() trans = trans-25 setElementAlpha(arena[a],trans) outputChatBox(a .. " done") end, (GTIME-100)/8,6) destroyElement(arena[a]) table.remove(arena, a) outputChatBox(a .. " deleted", getRootElement(), 255, 0, 0) trans = 255 end, GTIME, #arena-1) Thanks in advance for any help. Link to comment
MAB Posted October 13, 2015 Share Posted October 13, 2015 Hey, I'm working on some small project of mine, I want to create a function where there is a timer, and some other things. The other things need to start after the timer has finished, how can I do it?Here is sample of my code, a tried to put destroyElement and table.remove in another timer, but that doesn't work for me either. setTimer( function() a = math.floor(math.random(#arena)) setTimer( function() trans = trans-25 setElementAlpha(arena[a],trans) outputChatBox(a .. " done") end, (GTIME-100)/8,6) destroyElement(arena[a]) table.remove(arena, a) outputChatBox(a .. " deleted", getRootElement(), 255, 0, 0) trans = 255 end, GTIME, #arena-1) Thanks in advance for any help. Full code would be useful Link to comment
Dealman Posted October 13, 2015 Share Posted October 13, 2015 Simply put the code you want to execute once the timer's done inside that timer. Otherwise, you can use getTimerDetailsto see if it's still running, stopped running or does not exist. Link to comment
MAB Posted October 14, 2015 Share Posted October 14, 2015 Simply put the code you want to execute once the timer's done inside that timer. Otherwise, you can use getTimerDetailsto see if it's still running, stopped running or does not exist. I got to say.. first time i see this function... looked for it for a long time... Link to comment
quindo Posted October 14, 2015 Author Share Posted October 14, 2015 Thanks for all help, i managed to find out what was wrong with my script. When I didn't use a timer for 2nd part it was just faster than first timer. When i put 2nd part into timer i set it to wrong time, so a was randomly generated too fast. I just put it with a bit smaller time and it works fine. here's the fixed code, i didn't explain properly at first what i meant, so sorry for that. setTimer( function() a = math.floor(math.random(#arena)) setTimer( function() trans = trans-25 setElementAlpha(arena[a],trans) outputChatBox(a .. " done") end, (GTIME-100)/8,6) setTimer( function() destroyElement(arena[a]) table.remove(arena, a) outputChatBox(a .. " deleted", getRootElement(), 255, 0, 0) trans = 255 end, GTIME-50,1) end, GTIME, #arena-1) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now