Advertisement
Metalhead33

ComputerCraft Menu Test

Nov 2nd, 2016
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.83 KB | None | 0 0
  1. os.loadAPI("menusys")
  2.  
  3. choice_state = {
  4.     [1] = { false, false },
  5.     [2] = { false, false },
  6. }
  7.  
  8.  
  9.  
  10. function choice_concat(text,x,y)
  11. if choice_state[x][y] == true then
  12.     return text .. " " .. x .. "-" .. y .. " [ON]"
  13. else
  14.     return text .. " " .. x .. "-" .. y .. " [OFF]"
  15. end
  16. end
  17.  
  18. choices = { }
  19. for xkey,xvalue in ipairs(choice_state) do
  20.     choices[xkey] = { }
  21.     for ykey,yvalue in ipairs(xvalue) do
  22.         choices[xkey][ykey] = function() return choice_concat("NODE",xkey,ykey) end
  23.     end
  24. end
  25.  
  26. x = 1
  27. y = 1
  28.    
  29. while true do
  30.     x,y = menusys.displayMenuMult(choices,"Test Functions","Test Functions",x,y)
  31.     if x == 0 then
  32.         exit()
  33.     else
  34.         if choice_state[x][y] == true then
  35.             choice_state[x][y] = false
  36.             else choice_state[x][y] = true
  37.         end
  38.     end
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement