Pharap

Cranium's Code v0.2

Aug 10th, 2012
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.19 KB | None | 0 0
  1. function menuOpt()
  2. local btn1 = {1,1,"Production"}
  3. local btn2 = {2,1,"Reactor Control"}
  4. local btn3 = {1,2,"Lights"}
  5. local btn4 = {2,2,"Check System Status"}
  6. local curx=btn1[1]
  7. local cury=btn1[2]
  8. while true do
  9. term.clear()
  10. term.setCursorPos(1,7)
  11. print("Options")
  12. term.setCursorPos(1,8)
  13. if curx==btn1[1] and cury==btn1[2] then
  14. print("   [",btn1[3],"]   ",btn2[3]," ")
  15. elseif curx==btn2[1] and cury==btn2[2] then
  16. print("    ",btn1[3],"   [",btn2[3],"]")
  17. else
  18. print("    ",btn1[3],"    ",btn2[3]," ")
  19. end
  20. term.setCursorPos(1,9)
  21. if curx==btn3[1] and cury==btn3[2] then
  22. print("   [",btn3[3],"]   ",btn4[3]," ")
  23. elseif curx==btn4[1] and cury==btn4[2] then
  24. print("    ",btn3[3],"   [",btn4[3],"]")
  25. else
  26. print("    ",btn3[3],"    ",btn4[3]," ")
  27. end
  28. e, k = os.pullEvent("key")
  29. if k==203 then curx = curx - 1 --left
  30. elseif k==205 then curx = curx + 1 --right
  31. elseif k==200 then cury = cury - 1 --up
  32. elseif k==208 then cury = cury + 1 --down
  33. elseif k==28 then break --enter
  34. end
  35. end
  36.  
  37. if curx == 1 and cury == 1 then return "1" end
  38. if curx == 2 and cury == 1 then return "2" end
  39. if curx == 1 and cury == 2 then return "3" end
  40. if curx == 2 and cury == 2 then return "4" end
  41. end
  42.  
  43. menuOpt()
Advertisement
Add Comment
Please, Sign In to add comment