View difference between Paste ID: PWcPyQ9K and LqxTzbQ7
SHOW: | | - or go back to the newest paste.
1
tArgs = {...}
2
3
os.loadAPI("nerdtalk")
4
5
sgb = peripheral.wrap("stargate_base_4")
6
7
function isInit()
8
 return peripheral.call("stargate_base_4", "isInitiator")=="true"
9
end
10
11
locked = true
12
13
function lockGate()
14
locked = true
15
 repeat
16
  sleep(1)
17
  if isInit()==false then
18
   sgb.disconnect()
19
  elseif isInit()==true then
20
  
21
  end
22
 until locked==false
23
end
24
25
function unlock()
26
 locked = false
27
end
28
29
local function main()
30
  local hadd = sgb.getHomeAddress()
31
  local isconn = sgb.isConnected()
32
  local isini = sgb.isInitiator()
33
  local diaadd = sgb.getDialledAddress()
34
35
  nerdtalk.clearPage()
36
  nerdtalk.centerPrint("Stargate Prompt V0.1")
37
  nerdtalk.centerPrint("----------------------")
38
  nerdtalk.leftWrite("   Home Address: ")
39
  nerdtalk.rightPrint(hadd.."     ")
40
  nerdtalk.leftWrite("      Is Locked: ")
41
  nerdtalk.rightPrint(isLocked().."       ")
42
  nerdtalk.leftWrite("   Is Connected: ")
43
  nerdtalk.rightPrint(isconn.."       ")
44
  nerdtalk.leftWrite("   Is Initiator:")
45
  nerdtalk.rightPrint(isini.."       ")
46
  nerdtalk.leftWrite("Dialled Address:")
47
  nerdtalk.rightPrint(diaadd.."     ")
48
  nerdtalk.centerPrint(" ")
49
  nerdtalk.centerPrint("----------------")
50
  nerdtalk.centerPrint("Command Prompt")
51
  nerdtalk.centerPrint("----------------")
52
  passwordofthegods = bukkake11
53
 command()
54
end
55
56
running = true
57
function command()
58
  while running do
59
    write(">")
60
    input = read()
61
    if input == "terminalock" then
62
      nerdtalk.centerPrint("Terminal Locked")
63
      lockingterm = true
64
      while lockingterm do
65
        inputw = read()
66
        if input == passwordofthegods then
67
          print("unlocked terminal!")
68
          lockingterm=false
69
        end
70
      end
71
    end
72
    if input == "exit" or (input == "exit()") then
73
      nerdtalk.centerPrint("Exiting...")
74
      sleep(1)
75
      running = false
76
    elseif input == "connect" or (input == "c") then
77
      nerdtalk.leftWrite("Address: ")
78
      newinput1 = read()
79
      newinput = string.upper(newinput1)
80
      if pcall(sgb.connect,newinput) then
81
        nerdtalk.leftWrite("Connecting to: ")
82
        nerdtalk.rightPrint(newinput)
83
      else
84
         nerdtalk.leftPrint("Failed to connect!")
85
      end
86
    elseif input == "disconnect" or (input == "dc") then
87
      nerdtalk.leftPrint("Disconnecting From Peer ")
88
      sgb.disconnect()
89
    elseif input == "help" then
90
      nerdtalk.leftPrint("list, ls. connect, c. disconnect, dc. refresh. help. exit")
91
    elseif input == "refresh" then
92
      main() 
93
    elseif input == "list" or (input == "ls") then
94
      nerdtalk.centerPrint("ERROR: None found")
95
    elseif input == "lock" then
96
      parallel.waitForAny(lockGate, main)
97
    elseif input == "unlock" then
98
      unlock()
99
      main()
100
    else
101
      print("Error: Command not recognized")   
102
    end
103
  end
104
end
105
106
function isLocked()
107
 return tostring(locked)
108
end
109
110
main()