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

Simple Menu

Started by Matt21, 26 November 2012 - 03:31 AM
Matt21 #1
Posted 26 November 2012 - 04:31 AM
This is my simple menu:



menuStat = 0

repeat


term.clear() -- Clear the screen
term.setCursorPos(1,1) -- Set the cursor pos

print "Select your langauge" -- Message to print above the menu

pressedOk = false

if menuStat == 1 then
print[[> Francais - French]] -- Text to show if the cursor is on the first choice
print[[  English - Anglais]]
elseif menuStat == 2 then
print[[  Francais - French]] -- Text to show if the cursor is on the second choice
print[[> English - Anglais]]
end

event, param1 = os.pullEvent("key")
if param1 == 208 then menuStat = menuStat + 1
elseif param1 == 200 then menuStat = menuStat - 1
elseif param1 == 28 then pressedOk = true end
if menuStat == 3 then menuStat = 1
elseif menuStat == 0 then menuStat = 2 end
until pressedOk == true
menuStat = tostring(menuStat)


After the menu touch the end, the variable menuStat can be:
"1" if the choice is the frist
"2" if the choice is the second
Dlcruz129 #2
Posted 26 November 2012 - 05:02 AM
Good job!
billysback #3
Posted 26 November 2012 - 05:03 AM
This isn't a tutorial, this is just a program.
Also your signature contains a really easy to fix virus, I'm pretty sure that's against the rules (sharing malware)
Dlcruz129 #4
Posted 26 November 2012 - 07:33 AM
This isn't a tutorial, this is just a program. Also your signature contains a really easy to fix virus, I'm pretty sure that's against the rules (sharing malware)

Its not a virus :D/>/>/>. It never even does anything. 1 will never equal 2.

EDIT: Fail, I thought you were talking about me. Yeah Matt, that's against the rules.
Matt21 #5
Posted 27 November 2012 - 04:58 AM
Oops,i wanted to post this article in the "Programs" but I was wrong, a moderator can move it? For my signature, I do not think it would be considered a malware, I removed it.
Kristaps220 #6
Posted 04 August 2013 - 07:06 AM
This really helped me out with my first menu! Thank you :)/>
Cranium #7
Posted 07 August 2013 - 11:37 AM
Moved to Programs and locked.
Why was there a need to bring this topic back up?