Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

How to delay in a loop ?
Started by han7 Apr 16 2019 07:50 AM

3 replies to this topic
timer delay timer.performwithdelay

Best Answer Quantumwave , 16 April 2019 - 05:48 PM

If all you need is to pass the loop count to the function every 3 seconds for 10 times, this would work too:

 

timer.performWithDelay(3000, function(e) return here(e.count) end, 10)

 

Dave

 

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

han7

[GLOBAL: userInfoPane.html]
han7
  • Observer

  • 2 posts
  • Corona SDK

I want to use timer.performWithDelay in a loop but it doesn't work here is the code:

local function here(i)
	print("here" .. tostring(i))
end
for i = 1,10,1 
do 
	timer.performWithDelay(3000, here(i))
end


[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,925 posts
  • Enterprise

You should find this post helpful: https://coronalabs.com/blog/2019/04/10/using-functions-for-oncomplete-listeners/

 

Rob


  • han7 likes this

[TOPIC: post.html]
#3

Quantumwave

[GLOBAL: userInfoPane.html]
Quantumwave
  • Contributor

  • 103 posts
  • Corona SDK

  Best Answer

If all you need is to pass the loop count to the function every 3 seconds for 10 times, this would work too:

 

timer.performWithDelay(3000, function(e) return here(e.count) end, 10)

 

Dave

 


  • han7 likes this

[TOPIC: post.html]
#4

han7

[GLOBAL: userInfoPane.html]
han7
  • Observer

  • 2 posts
  • Corona SDK

Thank you very much. 




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: timer, delay, timer.performwithdelay