Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function startup()
- connected_pcs={}
- rednet.open("top")
- connections=fs.open("connections","a")
- connections.close()
- if not fs.exists("connection_code") then
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.green)
- print("Please enter the name you want to use to connect")
- print("to other PC´s")
- print()
- term.setTextColor(colors.white)
- connection_name=read()
- connection_code=fs.open("connection_code","w")
- connection_code.writeLine(connection_name)
- connection_code.flush()
- connection_code.close()
- end
- assign_name()
- assign_connections()
- if connected_pcs["name"][1]==nil then
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.green)
- print("Please enter the name of the PC you want to")
- print("connect to")
- print()
- term.setTextColor(colors.white)
- connecting_to=read()
- connections=fs.open("connections","w")
- connections.writeLine(connecting_to)
- connections.flush()
- connections.close()
- end
- for i=1,250 do
- rednet.send(i,{["connecting_to"]=connecting_to,["name"]=connection_name})
- end
- assign_connections()
- end
- function pull()
- while true do
- info_1, info_2, info_3, info_4 = os.pullEvent()
- if info_1=="rednet_message" and info_3["sending_to"]==connection_name then
- if info_3["status"]=="on" then
- redstone.setOutput("bottom",true)
- redstone.setOutput("top",true)
- redstone.setOutput("back",true)
- redstone.setOutput("front",true)
- redstone.setOutput("right",true)
- redstone.setOutput("left",true)
- else
- redstone.setOutput("bottom",false)
- redstone.setOutput("top",false)
- redstone.setOutput("back",false)
- redstone.setOutput("front",false)
- redstone.setOutput("right",false)
- redstone.setOutput("left",false)
- end
- end
- end
- end
- function assign_connections()
- connections=fs.open("connections","r")
- connected_pcs["name"]={}
- connected_pcs["len"]=0
- connected_pcs["id"]={}
- connected_pcs["id"][0]="0"
- i=0
- while tonumber(connected_pcs["id"][i])~=nil do
- i=i+1
- connected_pcs["name"][i] = connections.readLine()
- connected_pcs["id"][i] = connections.readLine()
- if tonumber(connected_pcs["id"][i])~=nil then
- connected_pcs["len"]=connected_pcs["len"]+1
- end
- end
- connections.close()
- end
- function assign_name()
- connection_code = fs.open("connection_code","r")
- connection_name = connection_code.readLine()
- connection_code.close()
- end
- startup()
- pull()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement