how to do something frequently ?

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
justatest
Posts: 10
Joined: Mon Dec 19, 2005 5:56 pm

how to do something frequently ?

Post by justatest »

i hope to do a thing in every 2 sec . or some how .

but lua seem have no interrupt etc . i read some codes . but still not get the meaning .

screen.waitVblankStart(4) seem some like this . some one pls give me some more detail ?
romero126
Posts: 200
Joined: Sat Dec 24, 2005 2:42 pm

Post by romero126 »

screen.waitVblankStart(4) is a timer that halts all code for x ammount of time. Each numerical digit works in MS so if you wanted it to wait 2 seconds you would give it a timeout of 200(or 2000) depending on how long you wanted to wait. 200 I believe is 2 seconds.
MikeHaggar
Posts: 116
Joined: Mon Jul 18, 2005 2:20 am

Post by MikeHaggar »

Um... VBlanking happens 60 times a second me thinks (60FPS/60Hz or whatever), so screen.waitVblankStart(120) would be 2 seconds?
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

Use system.sleep(x) function instead, x in milliseconds.
Geo Massar
Retired Engineer
romero126
Posts: 200
Joined: Sat Dec 24, 2005 2:42 pm

Post by romero126 »

Waiting a specific time i always use a timer only because its far more relyable to do it that way vs halting everything going on.
LordCthulu
Posts: 11
Joined: Thu Dec 29, 2005 12:32 am

Post by LordCthulu »

Hey romero can you give me a quick example of using a timer like that?
I tried using a timer for animation but I couldn't get it to work. Thanks in advance ^^;
romero126
Posts: 200
Joined: Sat Dec 24, 2005 2:42 pm

Post by romero126 »

for a limitation do.. if timer:start() > 30 then
pretty much.. it limites that timer to 30ms .. giving you a fps based animation or etc.. timer:reset() resets the timer.. the rest of the information can be found on the wiki
LordCthulu
Posts: 11
Joined: Thu Dec 29, 2005 12:32 am

Post by LordCthulu »

Ok I was checking for something other than timer:start(), probably why. Thanks ^^;
Post Reply