Advertisement
TheTrickster

It no working :/

Mar 28th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.43 KB | None | 0 0
  1. rs = component.proxy( component.list("redstone")() );
  2. nc = component.proxy( component.list("modem")() );
  3. --ch = component.proxy( component.list("chat")() );
  4. si = component.proxy( component.list("sign")() )
  5. rs.setOutput( 4,4 )
  6. local sides = { bottom = 0, top = 1, back = 2, front = 3, right = 4, left = 5 }
  7. local aspects = { "red", "yellow", "d-yellow", "green" }
  8. local direct = { "towards", "away"}
  9.  
  10. ID = si.getValue() -- Sign should be on the font of the MCU and have a 2 digit number on the first line
  11. if ID == nil then error("No sign, you tit!", 0) end
  12. ID = ID:sub(1,2)
  13.  
  14. nc.open(2222)
  15. function decodeNetwork( e, l, r, p, d, ... )
  16.   local excess = table.pack( ... )
  17.   return e, l, r, p, d, excess
  18. end
  19.  
  20.  
  21. while true do
  22.   a = table.pack( computer.pullSignal() )
  23.   if a[1] == "modem_message" then
  24.     e,l,r,p,d,m = decodeNetwork( table.unpack( a ) ) -- Parameters: EventName, LocalAddress, RemoteAddress, Port, Distance, Message
  25.     if m[1]:sub(1,2) == ID then -- m[1] will be a number represented in string form like "3212"
  26.       dir,asp = m[1]:sub(3,3), m[1]:sub(4,4)
  27.       if m[1]:sub(3,3) == 1 then
  28.         rs.setOutput(sides.right, asp )
  29.       elseif m[1]:sub(3,3) == 0 then
  30.         rs.setOutput(sides.left, asp )
  31.       end
  32.       si.setValue( string.format("%q\nLast Message\n%q\n%q", ID, direct[dir+1], tostring(asp)) ) -- the last paramiter here is supposed to be aspects[asp] but it doesn't want to work
  33.     end
  34.   end
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement