Advertisement
GauHelldragon

GauRailControl2 v0.3

Apr 16th, 2013
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.92 KB | None | 0 0
  1. rednet.open("right")
  2.  
  3. local Archi,BW,Gau = colors.purple, colors.orange, colors.yellow
  4.  
  5. while true do
  6.   event, ID,message, distance = os.pullEvent("rednet_message")
  7.   if ( string.sub(message,1,4) == "rail" ) then
  8.      local value = tonumber(string.sub(message,5))
  9.      local newColor = 0
  10.      if ( bit.band(value, 1) ~= 0 ) then newColor = colors.combine(newColor,Archi) end
  11.      if ( bit.band(value, 2) ~= 0 ) then newColor = colors.combine(newColor,BW) end
  12.      if ( bit.band(value, 4) ~= 0 ) then newColor = colors.combine(newColor,Gau) end
  13.      rs.setBundledOutput("back",newColor)
  14.   end
  15.   if ( message == "ping" ) then
  16.     os.sleep(1)
  17.     local myColors = rs.getBundledOutput("back")
  18.     local value = 0
  19.     if colors.test(myColors,Archi) then value = value + 1 end
  20.     if colors.test(myColors,BW) then value = value + 2 end
  21.     if colors.test(myColors,Gau) then value = value + 4 end
  22.     rednet.send(ID,"rail" .. value)
  23.   end
  24.  
  25. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement