Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function split(str, pat)
- local t = {} -- NOTE: use {n = 0} in Lua-5.0
- local fpat = "(.-)" .. pat
- local last_end = 1
- local s, e, cap = str:find(fpat, 1)
- while s do
- if s ~= 1 or cap ~= "" then
- table.insert(t,cap)
- end
- last_end = e+1
- s, e, cap = str:find(fpat, last_end)
- end
- if last_end <= #str then
- cap = str:sub(last_end)
- table.insert(t, cap)
- end
- return t
- end
- rednet.open("top")
- while true do
- id, msg=rednet.receive()
- if msg=="torlist;" then
- rednet.send(id,os.getComputerID())
- print("LOG: Got tor list")
- elseif msg:sub(1,5)=="cast:" then
- rednet.broadcast(msg:sub(6))
- print("LOG: Used broadcast")
- elseif msg:sub(1,5)=="send:" then
- args=split(msg,":")
- sendid=args[2]
- sendmsg=args[3]
- rednet.send(sendid,sendmsg)
- print("LOG: Used send")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement