Guest User

Without logging

a guest
Mar 16th, 2013
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.76 KB | None | 0 0
  1. output = 0
  2.  
  3. rednet.open('left')
  4.  
  5. while true do
  6.   -- get our message
  7.   local sender, msg, dist = rednet.receive()
  8.   if sender == 45 and #msg == 2 then
  9.  
  10.     -- get the first part of our message and convert it from hex (base16) to decimal (base10)
  11.     local num = tonumber(msg:sub(1,1), 16)
  12.  
  13.     -- if it was not hexadecimal
  14.     if num then
  15.       -- decide which function we should use based on if the second character is a t (for true)
  16.       action = (msg:sub(2,2) == 't') and colors.combine or colors.subtract
  17.  
  18.       -- call out action with the current output and the one we just got
  19.       output = action(output, 2 ^ num)
  20.  
  21.       -- everything is valid now lets output
  22.       rs.setBundledOutput('back', output)
  23.     end
  24.   end
  25. end
  26.  
  27. rednet.close('left')f
Advertisement
Add Comment
Please, Sign In to add comment