function that pause a loop for x amount of time
Moderators: Shine, Insert_witty_name
- 
				my psprecious
- Posts: 24
- Joined: Fri Feb 17, 2006 5:08 am
function that pause a loop for x amount of time
Ok, I'm working on an animation in lua for the intro of my game
and I'm trying to do a pause in the loop as a function
so I can use it anywhere I need a pause and just change the value of my pause like something like this
function sleep(wait)
if i <= to wait do
i = i + 1
something missing here to pause it I was suggested waitvblank() but I don't think it exist
end
and everytime I call it I would have something like this sleep(30), 30 been the amount I need for that pause at that momment
could someone help I'm pretty lost
			
			
									
									
						and I'm trying to do a pause in the loop as a function
so I can use it anywhere I need a pause and just change the value of my pause like something like this
function sleep(wait)
if i <= to wait do
i = i + 1
something missing here to pause it I was suggested waitvblank() but I don't think it exist
end
and everytime I call it I would have something like this sleep(30), 30 been the amount I need for that pause at that momment
could someone help I'm pretty lost
- 
				yossistarz2
- Posts: 21
- Joined: Mon Apr 10, 2006 5:26 am
- Contact:
- 
				my psprecious
- Posts: 24
- Joined: Fri Feb 17, 2006 5:08 am
- 
				yossistarz2
- Posts: 21
- Joined: Mon Apr 10, 2006 5:26 am
- Contact:
try this on Millisecond timer base.
			
			
									
									
						Code: Select all
function sleep(MT)
	t =  Timer.new(0)
	t:start()
	while (t:time() < MT) do
	end
	t:stop()
end- 
				my psprecious
- Posts: 24
- Joined: Fri Feb 17, 2006 5:08 am
- 
				yossistarz2
- Posts: 21
- Joined: Mon Apr 10, 2006 5:26 am
- Contact:
- 
				my psprecious
- Posts: 24
- Joined: Fri Feb 17, 2006 5:08 am
- 
				DiabloTerrorGF
- Posts: 64
- Joined: Fri Jul 15, 2005 11:44 pm
- 
				yossistarz2
- Posts: 21
- Joined: Mon Apr 10, 2006 5:26 am
- Contact:
I don't know what about that but check this as a proof:
(stops for 1 second)
			
			
									
									
						(stops for 1 second)
Code: Select all
function sleep(MT)
   t =  Timer.new(0)
   t:start()
   while (t:time() < MT) do
   end
   t:stop()
end
screen:clear(Color.new(255,0,0))
screen:flip()
screen:flip()
sleep(1000)
screen:clear(Color.new(255,255,0))
screen:flip()
screen:flip()
sleep(1000)
screen:clear(Color.new(255,0,255))
screen:flip()
screen:flip()
sleep(1000)
screen:clear(Color.new(0,0,255))
screen:flip()
screen:flip()
sleep(1000)
- 
				yossistarz2
- Posts: 21
- Joined: Mon Apr 10, 2006 5:26 am
- Contact: