Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- component = require("component")
- gpu = component.gpu
- e = require("event")
- m = component.modem
- string = require("string")
- term = require("term")
- table = require("table")
- c = false
- x, y, length, n, l = 3, 3, 0, 3, 3
- j = 1
- m.open(2)
- m.broadcast(1, "nanomachines", "setResponsePort", 2)
- e.pull("modem_message")
- maxX, maxY, oX, oY = term.getViewport()
- inList = {}
- function clear()
- gpu.fill(1, 1, maxX, maxY, " ")
- end
- function printToMon(str, x, y)
- gpu.set(x, y, str)
- end
- function Input(num)
- m.broadcast(1, "nanomachines", "getInput", num)
- _, c, j = e.pull("msg_recieved")
- if c == true then
- m.broadcast(1, "nanomachines", "setInput", num, false)
- print("Turning input "..num.." off")
- e.pull("msg_recieved")
- elseif c == false then
- m.broadcast(1, "nanomachines", "setInput", num, true)
- e.pull("msg_recieved")
- print("Getting effects of input "..num.." now")
- m.broadcast(1, "nanomachines", "getActiveEffects")
- print("cont")
- e.push("effects_table", inList)
- _, inList = e.pull("effects_updated")
- end
- end
- function inputList()
- m.broadcast(1, "nanomachines", "getTotalInputCount")
- e.pull("updated_inputs")
- for i=1, inputs do
- num = tostring(i)
- msg = "Input: "..num
- print(msg.." registered")
- Input(i)
- Input(i)
- end
- end
- inputList()
- function list()
- clear()
- x, y, length = 3, 3, 0
- for i,v in pairs(inList) do
- z, t = maxX - oX, maxY - oY
- if x + string.len(v) >= z then
- y = y + 2
- x = 3
- length = 0
- end
- printToMon(v, x + length, y)
- x = x + 3 + length
- length = string.len(v)
- end
- end
- function mainScreen()
- list()
- end
- while true do
- mainScreen()
- printToMon("x", 3, 3)
- _, s, x, y, b, user = e.pull("touch")
- printToMon("t", x, y)
- for i,v in pairs(inList) do
- if l <= x and string.len(v) >= x and n == y then
- Input(i)
- end
- length = string.len(v)
- l = l + 3 + length
- if l >= maxX then
- l = 3
- n = n + 2
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment