Jump to content




[Question] Detecting key strokes


  • You cannot reply to this topic
2 replies to this topic

#1 Stormkrow

  • Members
  • 50 posts
  • LocationSouth Africa

Posted 05 July 2012 - 08:15 PM

Hi all,
I've been messing around with keystrokes and cant figure a problem out.
What i wanna do is have a program standardly print out:
>YES<NO
and when the enter is pressed it executes a step or if the user right arrow button is pressed it changes to:
YES>NO<
and if enter is pressed at that stage the program is ended/cancelled

My code is:

a = >YES<NO
b = YES>NO<

local sEvent, param = os.pullEvent("key")
if (sEvent == "key") then
if(param == 205) then
print( b )

if (sEvent == "key") then
if(param == 28) then
shell.run("startup")
else

if (sEvent == "key") then
if(param == 203) then
print(a)
then

if (sEvent == "key") then
if(param == 28) then
function frame()
end
end
end
end

So thats it. I wanna make it so that the program wont effectively end and it can change between the Variable A or B until enter is pressed. Would a loop work? If so how? and then how would i have it so that Variable A is shown standardly and the print for variable will change in the same position where the previous text was if a key stroke is pressed?

Any help is most appreciated:P
Thanks!

#2 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 05 July 2012 - 08:31 PM

There's a tutorial to make a menu like that in the tutorials forum, check it out.

#3 Stormkrow

  • Members
  • 50 posts
  • LocationSouth Africa

Posted 05 July 2012 - 08:49 PM

Ahhh thanks sorry i didnt see it untill i took a second look:P





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users