Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- component=require("component")
- term=require("term")
- io=require("io")
- local function irisChange(iris_state)
- if iris_state == "Open" then
- component.stargate.closeIris()
- else
- component.stargate.openIris()
- end
- end
- names={}
- name = io.open("/usr/name.txt")
- i = 1
- namet =" "
- while namet ~= nill do
- namet = name:read()
- if namet ~= nill then
- table.insert(names,namet)
- i = i+1
- end
- end
- addr={}
- add = io.open("/usr/add.txt")
- i = 1
- addt =" "
- while addt ~= nill do
- addt = add:read()
- if addt ~= nill then
- table.insert(addr,addt)
- i = i+1
- end
- end
- i_max =tostring(i-1)
- on = "on"
- while on == "on" do
- term.clear()
- sta = component.stargate.address
- loc = component.stargate.localAddress()
- iris = component.stargate.irisState()
- state = component.stargate.stargateState()
- energie = component.stargate.energyAvailable()
- energie_max = 24576000
- if energie ~= 0 then
- energie_p = energie / energie_max * 100
- end
- print("========================")
- print("Adresse locale : ",loc)
- print("Iris : ",iris)
- print("Etat : ",state)
- print("Energie : ",math.floor(energie_p),"%")
- print("========================")
- if state == "Idle" then
- for i = 1,i_max do
- print(i,names[i])
- end
- print("=====================")
- print("iris")
- print("manual")
- print("help")
- print("exit")
- print("=======================")
- input = io.read()
- if input == "exit" then
- on = "off"
- end
- if input>="1" and input<=i_max then
- component.stargate.dial(addr[tonumber(input)])
- end
- if input == "iris" then
- irisChange(iris)
- end
- if input == "manual" then
- print("Adresse ? :")
- addresse = io.read()
- component.stargate.dial(addresse)
- end
- if input == "help" then
- print("Coming soon")
- end
- end
- if state == "Dialling" or state == "Connected" or state == "Opening" then
- print("Connected to : ",component.stargate.remoteAddress())
- print("=====================")
- print("disconnect")
- print("iris")
- print("=====================")
- input = io.read()
- if input == "disconnect" then
- component.stargate.disconnect()
- end
- if input == "iris" then
- irisChange(iris)
- end
- end
- end
Add Comment
Please, Sign In to add comment