Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local event = require("event")
- local component = require("component")
- local gpu = component.gpu
- local nano = require("nanomachines")
- local boolStr = { [false]="false", [true]="true" }
- local stateNames = {
- "Strength",
- "Particle: Fire (big)",
- "???",
- "Particle: Fire (feet)",
- "Resistance",
- "???",
- "!Poison!",
- "???",
- "!Hunger!",
- "!Slow!",
- "???",
- "???",
- "Fire Resistance",
- "???",
- "Particle: Runes",
- "???",
- "???",
- "???",
- }
- local states = {
- false, false, false, false,
- false, false, false, false,
- false, false, false, false,
- false, false, false, false,
- false, false,
- }
- local setInput = function(index, state)
- nano.send("setInput", tonumber(index), state)
- end
- local getInput = function(index)
- nano.send("getInput", tonumber(index))
- end
- local printRow = function(index)
- local w,h = gpu.getResolution()
- gpu.fill(1, index, w, 1, " ")
- gpu.set(2, index, string.format("%25s: %s", stateNames[index], states[index]))
- end
- local updateInputs = function()
- for i=1,#states do
- printRow(i)
- end
- end
- local clearScreen = function()
- local w,h = gpu.getResolution()
- gpu.fill(1, 1, w, h, " ")
- end
- nano.init(222)
- nano.listen(function(command, p1, p2)
- if (command == "input") then
- states[p1] = p2
- updateInputs()
- end
- end)
- clearScreen()
- for i=1,#states do
- getInput(i)
- end
- while (true) do
- local event, uuid, x, y, button, player = event.pullMultiple("interrupted", "touch")
- if (event == "interrupted") then
- return
- elseif (event == "touch") then
- if ((y > 0) and (y <= #states)) then
- setInput(y, not states[y])
- end
- end
- end
- clearScreen()
Advertisement
Add Comment
Please, Sign In to add comment