Jump to content




I dont want to wait on os.pullEvent


  • You cannot reply to this topic
1 reply to this topic

#1 Tjakka5

  • Members
  • 256 posts

Posted 31 January 2013 - 07:48 AM

Hi guys,


I'm working on a small minigame (Guitar Hero!) and I wanted to let os.pullEvent(key) check if I pressed a key.
However, os.pullEvent doesnt work that way and it just waits 'till I press the key...

Is there anyway it will not wait, and just see that I pressed a key or not, AND return what key I pressed?

Thanks in advantage.

#2 ikke009

  • Members
  • 224 posts
  • LocationSliding between sunbeams

Posted 31 January 2013 - 08:04 AM

use an ingame timer that updates the pixels in the game (in your case the guitar tab thingys..)
refreshTime = 0.18
gtID = os.startTimer(refreshTime)
ev,p1 = os.pullEvent()
if ev == "key" then
  if p1 == keys.a then
	--insert code here
  end
elseif ev == "timer" and p1 == gtID then
  gtID = os.startTimer(refreshTime)
  --insert code here to update game
end

edit: forgot something..





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users