Posted 13 March 2016 - 01:13 PM
-- Functions
local function cprint(text)
local x,y = term.getSize()
local x2,y2 = term.getCursorPos()
term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
write(text)
end
local function clear()
term.clear()
term.setCursorPos(1,1)
end
local function drawscreen()
write(user"@Reactor 1> ")
input = read()
end
local function main()
drawscreen()
if input == "help" then
write("List of avaiable commands:\n")
write(" start - Start the Reactor ( Requires Elevated Privileges )\n")
write(" stop - Stop the Reactor ( Requires Elevated Privileges )\n")
write(" state - Reload Reactor State \n")
write(" networkoff - Disconnect the Reactor from the network ( Requires Super-Elevated Privileges )\n")
write(" reboot - Reboot this computer \n")
write(" version - Display the version number and copyright information\n")
end
if input == "start" then
end
if input == "stop" then
end
if input == "state" then
end
if input == "networkoff" then
clear()
cprint("Are you SURE you wish to perform this?")
write("\n")
cprint("N/y>")
input2 = read()
if input2 == "y" then
print("boom")
else
print("Nothing was done")
sleep(2)
clear()
end
end
if input == "reboot" then
write("Goodbye")
os.reboot()
end
if input == "version" then
write("Hiperbolt HiperReactor 0.1\n")
write("\n")
write("Copyright (C) 2016 hiperbolt\n")
write("\n")
end
main()
end
-- init
local tArgs = { ... }
if #tArgs < 1 then
user = guest
clear()
main()
end
local sUser = tArgs[1]
if sUser == "root" then
clear()
write("Enter root password:")
input = read("*")
if input == "root" then
clear()
user = root
main()
end
elseif sUser == "heda" then
clear()
write("Enter heda password:")
input = read("*")
if input == "heda" then
clear()
user = heda
main()
end
end
Why is user nil in main() if its set as gues or root or heda in init?