Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tArgs = {...}
- os.loadAPI("nerdtalk")
- sgb = peripheral.wrap("stargate_base_4")
- function isInit()
- return peripheral.call("stargate_base_4", "isInitiator")=="true"
- end
- locked = true
- function lockGate()
- locked = true
- repeat
- sleep(1)
- if isInit()==false then
- sgb.disconnect()
- elseif isInit()==true then
- end
- until locked==false
- end
- function unlock()
- locked = false
- end
- local function main()
- local hadd = sgb.getHomeAddress()
- local isconn = sgb.isConnected()
- local isini = sgb.isInitiator()
- local diaadd = sgb.getDialledAddress()
- nerdtalk.clearPage()
- nerdtalk.centerPrint("Stargate Prompt V0.1")
- nerdtalk.centerPrint("----------------------")
- nerdtalk.leftWrite(" Home Address: ")
- nerdtalk.rightPrint(hadd.." ")
- nerdtalk.leftWrite(" Is Locked: ")
- nerdtalk.rightPrint(isLocked().." ")
- nerdtalk.leftWrite(" Is Connected: ")
- nerdtalk.rightPrint(isconn.." ")
- nerdtalk.leftWrite(" Is Initiator:")
- nerdtalk.rightPrint(isini.." ")
- nerdtalk.leftWrite("Dialled Address:")
- nerdtalk.rightPrint(diaadd.." ")
- nerdtalk.centerPrint(" ")
- nerdtalk.centerPrint("----------------")
- nerdtalk.centerPrint("Command Prompt")
- nerdtalk.centerPrint("----------------")
- command()
- end
- running = true
- function command()
- while running do
- write(">")
- input = read()
- if input == "terminalock" then
- nerdtalk.centerPrint("Terminal Locked")
- lockingterm = true
- while lockingterm do
- inputw = read()
- if input == passwordofthegods then
- print("unlocked terminal!")
- lockingterm=false
- end
- end
- end
- if input == "exit" or (input == "exit()") then
- nerdtalk.centerPrint("Exiting...")
- sleep(1)
- running = false
- elseif input == "connect" or (input == "c") then
- nerdtalk.leftWrite("Address: ")
- newinput1 = read()
- newinput = string.upper(newinput1)
- if pcall(sgb.connect,newinput) then
- nerdtalk.leftWrite("Connecting to: ")
- nerdtalk.rightPrint(newinput)
- else
- nerdtalk.leftPrint("Failed to connect!")
- end
- elseif input == "disconnect" or (input == "dc") then
- nerdtalk.leftPrint("Disconnecting From Peer ")
- sgb.disconnect()
- elseif input == "help" then
- nerdtalk.leftPrint("list, ls. connect, c. disconnect, dc. refresh. help. exit")
- elseif input == "refresh" then
- main()
- elseif input == "list" or (input == "ls") then
- nerdtalk.centerPrint("ERROR: None found")
- elseif input == "lock" then
- parallel.waitForAny(lockGate, main)
- elseif input == "unlock" then
- unlock()
- main()
- else
- print("Error: Command not recognized")
- end
- end
- end
- function isLocked()
- return tostring(locked)
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment