Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- API = require("buttonAPI")
- local event = require("event")
- local computer = require("computer")
- local term = require("term")
- local component = require("component")
- local serialization = require("serialization")
- local modem = component.modem
- local gpu = component.gpu
- local GUI = {}
- local colors = require("colors")
- local side = require("sides")
- local h, w = gpu.getResolution()
- PORT = 666
- KX = h/160
- KY = w/50
- function API.fillTable()
- API.setTable("LAUNCH", launchtnt, math.floor(60*KX),math.floor(100*KX),math.floor(30*KY),math.floor(35*KY))
- API.setTable("Close", close, math.floor(60*KX), math.floor(100xKX), math.floor(38*KY), math.floor(41*KY))
- API.screen()
- end
- function GUI.getClick()
- local _, _, x, y = event.pull(1,touch)
- if x == nil or y == nil then
- local h, w = gpu.getResolution()
- gpu.set(h, w, ".")
- gpu.set(h, w, " ")
- else
- API.checkxy(x,y)
- end
- end
- function launchtnt()
- API.flash("LAUNCH",0.1)
- local payload = {}
- payload["type"] = "launch"
- payload["sender"] = modem.address
- payload["id"] = math.random(0,9999)
- modem.send(_G.data["serveraddr"], PORT, serialization.serialize(payload))
- end
- function disconnect()
- local payload = {}
- payload["type"] = "disconnect"
- payload["sender"] = modem.address
- payload["id"] = math.random(0,9999)
- modem.send(_G.data["serveraddr"], PORT, serialization.serialize(payload))
- end
- function close()
- API.flash("Close", 0.1)
- disconnect()
- os.exit(1)
- end
- function GUI.mainLoop()
- term.setCursorBlink(false)
- gpu.setResolution(h, w)
- API.clear()
- API.fillTable()
- API.heading("TNT Wireless Launcher V.1.0")
- while true do
- GUI.getClick()
- end
- end
- return GUI
- --eof
Add Comment
Please, Sign In to add comment