Advertisement
mast3rillusion

[Server] Ultimate Redstone Control (Adv PC)

Apr 12th, 2016
3,028
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.26 KB | None | 0 0
  1. local function addcol(col, side)
  2.   rs.setBundledOutput(side, colors.combine(rs.getBundledOutput(side),col))
  3. end
  4. local function remcol(col, side)
  5.   rs.setBundledOutput(side, colors.subtract(rs.getBundledOutput(side),col))
  6. end
  7. local count = 0
  8. redstone.setBundledOutput("back", 0)
  9. rednet.open("top")
  10. term.clear()
  11. term.setCursorPos(1,1)
  12. term.write("Server id is: "..os.getComputerID())
  13. term.setCursorPos(1,2)
  14. term.write("Waiting for a host computer to send commands...")
  15. while true do
  16.   event, id, text, protocol = os.pullEvent()
  17.   if event == "rednet_message" then
  18.     if protocol == "BaseControl" then
  19.         count = count + 1
  20.         term.setCursorPos(1,count+3)
  21.         term.clearLine()
  22.         term.write(text)
  23.         color = ""
  24.         state = ""
  25.         num = 1
  26.         for i in string.gmatch(text, "([^/]+)") do
  27.             if num == 1 then
  28.                 color = i
  29.             elseif num == 2 then
  30.                 state = i
  31.             end
  32.             num = num + 1
  33.         end
  34.         if color == "blue" then
  35.             if state == "Off" then
  36.                 remcol(colors.blue,"back")
  37.             else
  38.                 addcol(colors.blue,"back")
  39.             end
  40.         elseif color == "pink" then
  41.             if state == "Off" then
  42.                 remcol(colors.pink,"back")
  43.             else
  44.                 addcol(colors.pink,"back")
  45.             end
  46.         elseif color == "lime" then
  47.             if state == "Off" then
  48.                 remcol(colors.lime,"back")
  49.             else
  50.                 addcol(colors.lime,"back")
  51.             end
  52.         elseif color == "white" then
  53.             if state == "Off" then
  54.                 remcol(colors.white,"back")
  55.             else
  56.                 addcol(colors.white,"back")
  57.             end
  58.         elseif color == "orange" then
  59.             if state == "Off" then
  60.                 remcol(colors.orange,"back")
  61.             else
  62.                 addcol(colors.orange,"back")
  63.             end
  64.         elseif color == "magenta" then
  65.             if state == "Off" then
  66.                 remcol(colors.magenta,"back")
  67.             else
  68.                 addcol(colors.magenta,"back")
  69.             end
  70.         elseif color == "lightblue" then
  71.             if state == "Off" then
  72.                 remcol(colors.lightBlue,"back")
  73.             else
  74.                 addcol(colors.lightBlue,"back")
  75.             end
  76.         elseif color == "yellow" then
  77.             if state == "Off" then
  78.                 remcol(colors.yellow,"back")
  79.             else
  80.                 addcol(colors.yellow,"back")
  81.             end
  82.         elseif color == "cyan" then
  83.             if state == "Off" then
  84.                 remcol(colors.cyan,"back")
  85.             else
  86.                 addcol(colors.cyan,"back")
  87.             end
  88.         elseif color == "purple" then
  89.             if state == "Off" then
  90.                 remcol(colors.purple,"back")
  91.             else
  92.                 addcol(colors.purple,"back")
  93.             end
  94.         elseif color == "brown" then
  95.             if state == "Off" then
  96.                 remcol(colors.brown,"back")
  97.             else
  98.                 addcol(colors.brown,"back")
  99.             end
  100.         elseif color == "green" then
  101.             if state == "Off" then
  102.                 remcol(colors.green,"back")
  103.             else
  104.                 addcol(colors.green,"back")
  105.             end
  106.         elseif color == "red" then
  107.             if state == "Off" then
  108.                 remcol(colors.red,"back")
  109.             else
  110.                 addcol(colors.red,"back")
  111.             end
  112.         elseif color == "black" then
  113.             if state == "Off" then
  114.                 remcol(colors.black,"back")
  115.             else
  116.                 addcol(colors.black,"back")
  117.             end
  118.         elseif color == "lightgray" then
  119.             if state == "Off" then
  120.                 remcol(colors.lightGray,"back")
  121.             else
  122.                 addcol(colors.lightGray,"back")
  123.             end
  124.         elseif color == "gray" or color == "Gray" then
  125.             if state == "Off" then
  126.                 remcol(colors.gray,"back")
  127.             else
  128.                 addcol(colors.gray,"back")
  129.             end
  130.         elseif color == "alloff" or color == "AllOff" then
  131.             redstone.setBundledOutput("back", 0)
  132.         end
  133.     end
  134.   end
  135. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement