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
- adress={}
- adr=http.get("http://imgood.hostoi.com/otherstuff/stargates")
- src=adr.readAll()
- adress=textutils.unserialize(src)
- sg=peripheral.wrap("front")
- p=peripheral.wrap("right")
- while true do
- ev,usr,msg=os.pullEvent("chat")
- args=split(msg," ")
- if usr=="justync7" or usr=="Imgoodisher" or usr=="wired2coffee" and args[1]==".sg" then
- if args[2]=="dial" then
- if sg.isConnected() then sg.disconnect() end
- if adress[args[3]] then
- dial=sg.connect(adress[args[3]].add)
- else
- dial=sg.connect(args[3])
- end
- if dial=="true" then
- p.say("Dialing...")
- else
- p.say("Failed.")
- end
- elseif args[2]=="disconnect" then
- sg.disconnect()
- end
- end
- end
Add Comment
Please, Sign In to add comment