Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rs = component.proxy( component.list("redstone")() );
- nc = component.proxy( component.list("modem")() );
- --ch = component.proxy( component.list("chat")() );
- si = component.proxy( component.list("sign")() )
- rs.setOutput( 4,4 )
- local sides = { bottom = 0, top = 1, back = 2, front = 3, right = 4, left = 5 }
- local aspects = { "red", "yellow", "d-yellow", "green" }
- local direct = { "towards", "away"}
- ID = si.getValue() -- Sign should be on the font of the MCU and have a 2 digit number on the first line
- if ID == nil then error("No sign, you tit!", 0) end
- ID = ID:sub(1,2)
- nc.open(2222)
- function decodeNetwork( e, l, r, p, d, ... )
- local excess = table.pack( ... )
- return e, l, r, p, d, excess
- end
- while true do
- a = table.pack( computer.pullSignal() )
- if a[1] == "modem_message" then
- e,l,r,p,d,m = decodeNetwork( table.unpack( a ) ) -- Parameters: EventName, LocalAddress, RemoteAddress, Port, Distance, Message
- if m[1]:sub(1,2) == ID then -- m[1] will be a number represented in string form like "3212"
- dir,asp = m[1]:sub(3,3), m[1]:sub(4,4)
- if m[1]:sub(3,3) == 1 then
- rs.setOutput(sides.right, asp )
- elseif m[1]:sub(3,3) == 0 then
- rs.setOutput(sides.left, asp )
- end
- 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
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement