Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- arg={...}
- p="default"
- --config
- ip="auto"
- --set manually to friend's ip for long distance connections
- if ip=="auto" then
- http.request("http://212.1.211.216/network/get_ip.php")
- url, body, stuff=os.pullEvent("http_success")
- ip=stuff.readAll()
- end
- function ctn_wait()
- while true do
- evt, id, message, protocol, toid=os.pullEvent("creepertech_network_receive")
- if toid=="default" then
- if protocol==p then
- return id, message, protocol
- end
- end
- if toid==tostring(os.getComputerID()) then
- if protocol==p then
- return id, message, protocol
- end
- end
- end
- end
- function ctn_dowait()
- sleep(s)
- end
- function receive(pf, xf)
- if xf then
- s=xf
- p=pf
- parallel.waitForAny(ctn_dowait, ctn_wait)
- return id, message, protocol
- end
- if pf then
- p=pf
- return wait()
- end
- return wait()
- end
- function send(recid, msg, proto)
- if proto then
- ip=textutils.urlEncode(ip)
- msg=textutils.urlEncode(msg)
- proto=textutils.urlEncode(proto)
- recid=textutils.urlEncode(recid)
- http.request("http://212.1.211.216/network/packet_send.php?ip="..ip.."&data="..msg.."&id="..os.getComputerID().."&protocol="..proto.."&toid="..recid)
- return true
- end
- http.request("http://212.1.211.216/network/packet_send.php?ip="..ip.."&data="..msg.."&id="..os.getComputerID().."&toid="..recid)
- end
- function broadcast(msg, proto)
- if proto then
- ip=textutils.urlEncode(ip)
- msg=textutils.urlEncode(msg)
- proto=textutils.urlEncode(proto)
- --recid=textutils.urlEncode(recid)
- http.request("http://212.1.211.216/network/packet_send.php?ip="..ip.."&data="..msg.."&id="..os.getComputerID().."&protocol="..proto)
- return true
- end
- http.request("http://212.1.211.216/network/packet_send.php?ip="..ip.."&data="..msg.."&id="..os.getComputerID())
- end
- broadcast(arg[0], "1")
Advertisement
Add Comment
Please, Sign In to add comment