Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function receive()
- marg={os.pullEvent()}
- if marg[1] == "modem_message" then
- return true
- else
- return false
- end
- end
- function getside()
- return marg[2]
- end
- function getall()
- return marg
- end
- function getfromchan()
- return marg[3]
- end
- function getreplychan()
- return marg[4]
- end
- function getmsg()
- return marg[5]
- end
- function getdistance()
- return marg[6]
- end
- function open(side, chan)
- if peripheral.isPresent(side) and peripheral.getType(side) == "modem" then
- local modems = peripheral.wrap(side)
- modems.open(chan)
- else
- print("Modem not present on "..side.."")
- end
- end
- function transmit(chan, replychan, msgtosend)
- local newchan = tonumber(chan)
- local newreplychan = tonumber(replychan)
- sidepresent = nil
- for c = 1, 7 do
- if c == 1 then
- sidetocheck = "right"
- end
- if c == 2 then
- sidetocheck = "left"
- end
- if c == 3 then
- sidetocheck = "back"
- end
- if c == 4 then
- sidetocheck = "front"
- end
- if c == 5 then
- sidetocheck = "top"
- end
- if c == 6 then
- sidetocheck = "bottom"
- end
- if c == 7 then
- if sidepresent == nil then
- return false
- end
- else
- if peripheral.isPresent(sidetocheck) and peripheral.getType(sidetocheck) == "modem" then
- sidepresent = sidetocheck
- end
- end
- end
- local modems = peripheral.wrap(sidepresent)
- modems.transmit(newchan, newreplychan, msgtosend)
- end
- function seperate()
- toreturn = {}
- for a, b in string.gmatch(marg[5], "(%S+)") do
- toreturn[a] = b
- end
- return toreturn
- end
Advertisement
Add Comment
Please, Sign In to add comment