This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Tjakka5's profile picture

I dont want to wait on os.pullEvent

Started by Tjakka5, 31 January 2013 - 06:48 AM
Tjakka5 #1
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.
ikke009 #2
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..