Hi guys , is possible in Lua to know when a function end the internal process ?
I mean , when i call a function ,the function starts to do something.If i call another function within that , is there any way to know how the first process ends?
Hi guys , is possible in Lua to know when a function end the internal process ?
I mean , when i call a function ,the function starts to do something.If i call another function within that , is there any way to know how the first process ends?
You could do this:
[lua]
–make a variable called done
done = false;
local function whatever()
–check if done = false
if( done == false) then
–do whatever
–set done to true so it stops doing the stuff
done = true;
end
– if done = true, execute the second function
if( done == true ) then
local function nextfunction()
–do stuff in here
end
end
end
[/lua]
Hope this makes sense!
return true at the end of the function
Thank for the replies guys , but my problem is with a function that i call many times in my code.I want to know what is the last call and when the process of that last call end.Any idea ?
Don’t fully understand. If you want to time a function you can do
[lua]
local function test()
local started = os.time()
– Do bunch of stuff
print(“function took " … os.time() - started … " seconds”
end
[/lua]
This measures time in seconds, so probably will just be 0, unless you are doing something very process heavy I guess.
Thanks jonjonsson, its a good piece of code,but i mean in a recursive function that calls itself repeatedly at the same time.
How i can control , which of these repetitions is the last and when it ends.
It is for a chain reaction effect, like a domino effect when it forks.
Airam, not sure if this is what you’re looking for, but I have a series of transition.to’s and only want the last one to turn touch back on and set the colors… I used playCount as a counter, incrementing it 1 each time it was called. If it was equal to the #a_inPlay then it runs through a_inPlay again and turns on touch. Simply, you could…
local playcount = 0
local atEnd = function()
playCount = playCount + 1
if playCount == # then … [final code]; end; end
for i = 1, # do
xxxx
atEnd()
end
You could do this:
[lua]
–make a variable called done
done = false;
local function whatever()
–check if done = false
if( done == false) then
–do whatever
–set done to true so it stops doing the stuff
done = true;
end
– if done = true, execute the second function
if( done == true ) then
local function nextfunction()
–do stuff in here
end
end
end
[/lua]
Hope this makes sense!
return true at the end of the function
Thank for the replies guys , but my problem is with a function that i call many times in my code.I want to know what is the last call and when the process of that last call end.Any idea ?
Don’t fully understand. If you want to time a function you can do
[lua]
local function test()
local started = os.time()
– Do bunch of stuff
print(“function took " … os.time() - started … " seconds”
end
[/lua]
This measures time in seconds, so probably will just be 0, unless you are doing something very process heavy I guess.
Thanks jonjonsson, its a good piece of code,but i mean in a recursive function that calls itself repeatedly at the same time.
How i can control , which of these repetitions is the last and when it ends.
It is for a chain reaction effect, like a domino effect when it forks.
Airam, not sure if this is what you’re looking for, but I have a series of transition.to’s and only want the last one to turn touch back on and set the colors… I used playCount as a counter, incrementing it 1 each time it was called. If it was equal to the #a_inPlay then it runs through a_inPlay again and turns on touch. Simply, you could…
local playcount = 0
local atEnd = function()
playCount = playCount + 1
if playCount == # then … [final code]; end; end
for i = 1, # do
xxxx
atEnd()
end