forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

function that pause a loop for x amount of time

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
my psprecious



Joined: 17 Feb 2006
Posts: 24

PostPosted: Tue Apr 18, 2006 10:35 am    Post subject: function that pause a loop for x amount of time Reply with quote

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
Back to top
View user's profile Send private message
yossistarz2



Joined: 10 Apr 2006
Posts: 21

PostPosted: Tue Apr 18, 2006 11:48 am    Post subject: Reply with quote

The function you are asking for is this I hope...

function sleep(Wait)
i = 0
while i <= Wait do
i = i + 1
end
end

But you will need a very large amount of Wait number in order to see a difference.
Back to top
View user's profile Send private message Visit poster's website
my psprecious



Joined: 17 Feb 2006
Posts: 24

PostPosted: Tue Apr 18, 2006 12:06 pm    Post subject: Reply with quote

BIG thanx

this is gona be useful


EDIT


Doesn't work, I tried with 300000 and finally saw a difference, but what it did is not pause my loop since the loop continues, what it does it slows the loop
Back to top
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Tue Apr 18, 2006 5:55 pm    Post subject: Reply with quote

Is System.sleep(milliseconds) what do you need?
Back to top
View user's profile Send private message
yossistarz2



Joined: 10 Apr 2006
Posts: 21

PostPosted: Tue Apr 18, 2006 5:56 pm    Post subject: Reply with quote

try this on Millisecond timer base.

Code:

function sleep(MT)
   t =  Timer.new(0)
   t:start()
   while (t:time() < MT) do

   end
   t:stop()
end
Back to top
View user's profile Send private message Visit poster's website
my psprecious



Joined: 17 Feb 2006
Posts: 24

PostPosted: Wed Apr 19, 2006 2:01 am    Post subject: Reply with quote

Well what it does is pause my script on start not when I call the function

When I think that all this was to simplify my life hehehe
Back to top
View user's profile Send private message
yossistarz2



Joined: 10 Apr 2006
Posts: 21

PostPosted: Wed Apr 19, 2006 2:42 am    Post subject: Reply with quote

I am not shore what you are talking about.
When you call it it pause the program to X milliseconds and then continue.
Pause means dead time nothing is doing for x milliseconds.

If i hope i understands what you want.
Back to top
View user's profile Send private message Visit poster's website
my psprecious



Joined: 17 Feb 2006
Posts: 24

PostPosted: Wed Apr 19, 2006 8:41 am    Post subject: Reply with quote

yes exactly do nothing for x amount of time

I'm able to do it another way but it would have been useful to have a function pause(time) that I can call when I need a x amount of pause
Back to top
View user's profile Send private message
DiabloTerrorGF



Joined: 15 Jul 2005
Posts: 64

PostPosted: Wed Apr 19, 2006 10:28 am    Post subject: Reply with quote

System.sleep(milliseconds)

Should work...
Back to top
View user's profile Send private message
yossistarz2



Joined: 10 Apr 2006
Posts: 21

PostPosted: Wed Apr 19, 2006 10:38 am    Post subject: Reply with quote

I don't know what about that but check this as a proof:
(stops for 1 second)

Code:


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)

Back to top
View user's profile Send private message Visit poster's website
KawaGeo



Joined: 27 Aug 2005
Posts: 191
Location: Calif Mountains

PostPosted: Wed Apr 19, 2006 11:13 am    Post subject: Reply with quote

What is wrong with System.sleep(ms)? It should do the job.
_________________
Geo Massar
Retired Engineer


Last edited by KawaGeo on Wed Apr 19, 2006 11:23 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
yossistarz2



Joined: 10 Apr 2006
Posts: 21

PostPosted: Wed Apr 19, 2006 11:18 am    Post subject: Reply with quote

Maybe, But it jest for the question.
Your answer should solve it but it is good thing to now how to implement things in more then one way (it never harms).
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group