Advertisement
Wyvern67

Nexus

Jul 11th, 2015
471
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.02 KB | None | 0 0
  1. -- Coded by Wyvern
  2. portals = {"Age 1", "Age 2", "Age 3"}
  3. numberOfButtonsPerLine = 1
  4. monitorSide = "left"
  5. modemSide = "top"
  6. nexusTurtleID = 153
  7.  
  8. m = peripheral.wrap(monitorSide)
  9. rednet.open(modemSide)
  10. shell.run("pastebin", "get", "vcRXLMhn", "gui") -- My personnal buttons api
  11. os.loadAPI("gui")
  12.  
  13. print(os.getComputerID()..": Starting to work...")
  14.  
  15. gui.registerPeripheral(monitorSide)
  16. gui.setBackgroundColor("white")
  17.  
  18. sWidth, sHeight = m.getSize()
  19. width = math.floor((sWidth-5)/numberOfButtonsPerLine)
  20. btn = {}
  21. for i=0, #portals-1 do
  22.     x = math.floor( (sWidth/numberOfButtonsPerLine) * (i%3) + 2)
  23.     --2,14,26,2,14,26,2,14,26,2,14,26...
  24.     y = math.floor(i/numberOfButtonsPerLine)*6+2 --2,2,2,8,8,8,14,14,14,20,20,20...
  25.     btn[i+1] = gui.guiCreateButton(portals[i+1], x, y, width, 4)
  26. end
  27.  
  28. function sendTonexusTurtleID(text)
  29.     rednet.send(nexusTurtleID, text)
  30. end
  31.  
  32. while true do
  33.     nMsg = gui.guiGetMsg()
  34.     for i=1, #btn do
  35.         if nMsg == btn[i] then
  36.             print(i)
  37.             sendTonexusTurtleID(i)
  38.         end
  39.     end
  40.     sleep(0.1)
  41. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement