TwoThe

buffcontrol

Jan 28th, 2016
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.67 KB | None | 0 0
  1. local event = require("event")
  2. local component = require("component")
  3. local gpu = component.gpu
  4. local nano = require("nanomachines")
  5.  
  6. local boolStr = { [false]="false", [true]="true" }
  7.  
  8. local stateNames = {
  9.   "Strength",
  10.   "Particle: Fire (big)",
  11.   "???",
  12.   "Particle: Fire (feet)",
  13.   "Resistance",
  14.   "???",
  15.   "!Poison!",
  16.   "???",
  17.   "!Hunger!",
  18.   "!Slow!",
  19.   "???",
  20.   "???",
  21.   "Fire Resistance",
  22.   "???",
  23.   "Particle: Runes",
  24.   "???",
  25.   "???",
  26.   "???",
  27. }
  28.  
  29. local states = {
  30.   false, false, false, false,
  31.   false, false, false, false,
  32.   false, false, false, false,
  33.   false, false, false, false,
  34.   false, false,
  35. }
  36.  
  37. local setInput = function(index, state)
  38.   nano.send("setInput", tonumber(index), state)
  39. end
  40.  
  41. local getInput = function(index)
  42.   nano.send("getInput", tonumber(index))
  43. end
  44.  
  45. local printRow = function(index)
  46.   local w,h = gpu.getResolution()
  47.   gpu.fill(1, index, w, 1, " ")
  48.   gpu.set(2, index, string.format("%25s: %s", stateNames[index], states[index]))
  49. end
  50.  
  51. local updateInputs = function()
  52.   for i=1,#states do
  53.     printRow(i)
  54.   end
  55. end
  56.  
  57. local clearScreen = function()
  58.   local w,h = gpu.getResolution()
  59.   gpu.fill(1, 1, w, h, " ")
  60. end
  61.  
  62. nano.init(222)
  63. nano.listen(function(command, p1, p2)
  64.   if (command == "input") then
  65.     states[p1] = p2
  66.     updateInputs()
  67.   end
  68. end)
  69.  
  70. clearScreen()
  71. for i=1,#states do
  72.   getInput(i)
  73. end
  74.  
  75. while (true) do
  76.   local event, uuid, x, y, button, player = event.pullMultiple("interrupted", "touch")
  77.   if (event == "interrupted") then
  78.     return
  79.   elseif (event == "touch") then
  80.     if ((y > 0) and (y <= #states)) then
  81.       setInput(y, not states[y])
  82.     end
  83.   end  
  84. end
  85.  
  86. clearScreen()
Advertisement
Add Comment
Please, Sign In to add comment