Advertisement
Guest User

hallo

a guest
Oct 21st, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.71 KB | None | 0 0
  1. os.loadAPI("button")
  2. local m = peripheral.wrap("right")
  3. local rsOut = {}
  4. local buttonColors = {}
  5.    
  6. function fillMainTable()
  7.    m.clear()
  8.    button.clearTable()
  9.      button.setTable("Button1", mob1, "", 4, 17, 2, 4)
  10.      button.setTable("Button2", mob2, "", 20, 33, 2, 4)
  11.      button.setTable("Button3", mob3, "", 4, 17, 6, 8)
  12.      button.setTable("Button4", mob4, "", 20, 33, 6, 8)
  13.      button.setTable("Button5", mob5, "", 4, 17, 10, 12)
  14.      button.setTable("Button6", mob6, "", 20, 33, 10, 12)
  15.      button.setTable("Button7", mob7, "", 4, 17, 14, 16)
  16.      button.setTable("Button8", mob8, "", 20, 33, 14, 16)
  17.    print("Programm gestartet...")
  18.    button.screen()
  19.    
  20.    m.setTextScale(1,6)
  21.    m.setCursorPos(14,1)
  22.    m.write("MOB SPAWNER")
  23. end
  24.  
  25. function initRS()
  26.    rsOut[colors.white] = true
  27.    rsOut[colors.orange] = true
  28.    rsOut[colors.magenta] = true
  29.    rsOut[colors.lightBlue] = true
  30.    rsOut[colors.yellow] = true
  31.    rsOut[colors.lime] = true
  32.    rsOut[colors.brown] = true
  33.    rsOut[colors.green] = true
  34.    buttonColors["Button1"] = colors.white
  35.    buttonColors["Button2"] = colors.orange
  36.    buttonColors["Button3"] = colors.magenta
  37.    buttonColors["Button4"] = colors.lightBlue
  38.    buttonColors["Button5"] = colors.yellow
  39.    buttonColors["Button6"] = colors.lime
  40.    buttonColors["Button7"] = colors.brown
  41.    buttonColors["Button8"] = colors.green
  42. end
  43.  
  44. function setRS()
  45.    local colorOutput = 0
  46.    for i,j in pairs(rsOut) do
  47.       if j then colorOutput = colorOutput + i end
  48.     end
  49.     rs.setBundledOutput("back", colorOutput)
  50. end
  51.  
  52. function mob1()
  53.    button.toggleButton("Button1")
  54.    rsOut[colors.white] = not rsOut[colors.white]
  55.    setRS()
  56. end
  57.  
  58. function mob2()
  59.    button.toggleButton("Button2")
  60.    rsOut[colors.orange] = not rsOut[colors.orange]
  61.    setRS()
  62. end
  63.  
  64. function mob3()
  65.    button.toggleButton("Button3")
  66.    rsOut[colors.magenta] = not rsOut[colors.magenta]
  67.    setRS()
  68. end
  69.  
  70. function mob4()
  71.    button.toggleButton("Button4")
  72.    rsOut[colors.lightBlue] = not rsOut[colors.lightBlue]
  73.    setRS()
  74. end
  75.  
  76. function mob5()
  77.    button.toggleButton("Button5")
  78.    rsOut[colors.yellow] = not rsOut[colors.yellow]
  79.    setRS()
  80. end
  81.  
  82. function mob6()
  83.    button.toggleButton("Button6")
  84.    rsOut[colors.lime] = not rsOut[colors.lime]
  85.    setRS()
  86. end
  87.  
  88. function mob7()
  89.    button.toggleButton("Button7")
  90.    rsOut[colors.brown] = not rsOut[colors.brown]
  91.    setRS()
  92. end
  93.  
  94. function mob8()
  95.    button.toggleButton("Button8")
  96.    rsOut[colors.green] = not rsOut[colors.green]
  97.    setRS()
  98. end
  99.  
  100.  
  101. function getClick()
  102.    local event,side,x,y = os.pullEvent()
  103.    if event=="monitor_touch" then
  104.      button.checkxy(x,y)
  105.    end
  106. end
  107.  
  108.  
  109.  
  110. initRS()
  111. setRS()
  112. fillMainTable()
  113. while true do getClick() end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement