Advertisement
Guest User

startup

a guest
May 1st, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.62 KB | None | 0 0
  1. os.loadAPI("button")
  2. maxSpawner = 0
  3.  
  4. function funcClicked(name)
  5.   print("you clicked on"..name)
  6.   rednet.send(mainMonitor, resolveName[name], "SCREEN")
  7.   button.flash(name)
  8. end
  9.  
  10. function Mreboot(name)
  11.   rednet.send(mainMonitor, "REBOOT", "SCREEN")
  12.   button.flash(name)
  13.   sleep(1)
  14.   os.reboot()
  15. end
  16.  
  17. function drawButton(txt, pos, state)
  18.   x = pos * 11
  19.   y = 0
  20.   while x > 30 do
  21.     y = y + 4
  22.     x = x - 30
  23.   end
  24.   print("button "..txt.." X = "..x.." Y ="..y)
  25.   x = x + 1
  26.   y = y + 4
  27.   button.setTable(txt, funcClicked, x, x + 10, y, y + 3)
  28. end
  29.  
  30. function getClick()
  31.   event, side, x, y = os.pullEvent("monitor_touch")
  32.   print("CLICK!!! = X = "..x.." Y = "..y)
  33.   button.checkxy(x, y)
  34. end
  35.  
  36. rednet.open("back")
  37. term = peripheral.wrap("left")
  38. listSpawners = {}
  39. listSpawnerState = {}
  40. resolveName = {}
  41. mainMonitor = nil
  42.  
  43. while mainMonitor == nil do
  44.   mainMonitor = rednet.receive("SCREEN")
  45. end
  46.  
  47. rednet.send(mainMonitor, "SCREEN", "SCREEN")
  48. tmpTxt = "nope"
  49. pos = 0
  50. useless = 1
  51. tmpTxt2 = "nope"
  52. button.setTable("Reboot", Mreboot, 1, 11, 1, 3)
  53. while tmpTxt ~= "END" do
  54.   useless, tmpTxt = rednet.receive("SCREEN")
  55.   listSpawners[pos] = tmpTxt
  56.   resolveName[tmpTxt] = pos
  57.   if tmpTxt == "END" then break end
  58.   rednet.send(mainMonitor, "SCREEN", "SCREEN")
  59.   useless, tmpTxt2 = rednet.receive("SCREEN")
  60.   listSpawnerState[pos] = tmpTxt2
  61.   rednet.send(mainMonitor, "SCREEN", "SCREEN")
  62.   print("RES = "..tmpTxt.." pos "..pos.." res2 = "..tmpTxt2)
  63.   drawButton(tmpTxt, pos, tmpTxt2)
  64.   pos = pos + 1
  65. end
  66. button.heading("ScreenMobSoul")
  67. button.screen()
  68. while true do
  69.   getClick()
  70. end
  71. -- TODO : send if click
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement