Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- yellow = uranium
- gray = empty
- blue = ice
- green = on/off
- ]]--
- function tabRem(tab, item)
- for k,v in pairs(tab) do
- if v == item then
- table.remove(tab, k)
- end
- end
- end
- function notify(text, timeout)
- term.setCursorPos(2, 18)
- term.clearLine()
- term.write(text)
- if tonumber(timeout) then
- sleep(timeout)
- else
- sleep(0.8)
- end
- end
- local users = fs.list("security")
- menu = {"Login"}
- function tabAdd(n)
- tab = {}
- defined = {"Login", "Logout", "Reactor", "Refuel", "Turn On", "Turn Off", "Back",}
- for i=1, #n do
- table.insert(tab, defined[n[i]])
- end
- if selected > 1 then
- selected = #tab
- end
- return tab
- end
- local menuFunc = {
- ["Login"] = function()
- term.clear()
- term.setCursorPos(2, 2)
- term.write("User: ")
- user = read()
- if fs.exists("security/"..user) then
- file = fs.open(("security/"..user), "r")
- data = file.readAll()
- file.close()
- notify("Welcome "..user..", please write your password.")
- else
- notify("This user doesn't exist!")
- os.reboot()
- end
- term.setCursorPos(2, 4)
- term.write("Password: ")
- pass = read("*")
- if pass == data then
- pass, data = nil, nil
- n = {2, 3}
- menu = tabAdd(n)
- notify("Password is correct! Nice to see you!")
- else
- notify("Wrong password, try again later.")
- os.reboot()
- end
- end,
- ["Logout"] = function()
- notify("Logged out!")
- n = {1}
- menu = tabAdd(n)
- end,
- ["Reactor"] = function()
- n = {4,5,6,7}
- menu = tabAdd(n)
- notify("Reactor menu shown!")
- end,
- ["Turn On"] = function()
- rs.setBundledOutput("back", colors.combine(rs.getBundledOutput("back"), colors.green))
- notify("Reactor Turned On!")
- end,
- ["Turn Off"] = function()
- rs.setBundledOutput("back", colors.subtract(rs.getBundledOutput("back"), colors.green))
- notify("Reactor Turned Off!")
- end,
- ["Refuel"] = function()
- rs.setBundledOutput("back", 0)
- notify("Emptying Reactor!")
- for i=1, 54 do
- rs.setBundledOutput("back", colors.combine(rs.getBundledOutput("back"), colors.gray))
- sleep(0.3)
- rs.setBundledOutput("back", colors.subtract(rs.getBundledOutput("back"), colors.gray))
- sleep(0.3)
- end
- sleep(0.1)
- notify("Loading Uranium!")
- for i=1, 45 do
- rs.setBundledOutput("back", colors.combine(rs.getBundledOutput("back"), colors.yellow))
- sleep(0.3)
- rs.setBundledOutput("back", colors.subtract(rs.getBundledOutput("back"), colors.yellow))
- sleep(0.3)
- end
- notify("Waiting 20 sec for the rest of Uranium!")
- sleep(20)
- notify("Pushing antarctica to Reactor!")
- for i=1, 9 do
- rs.setBundledOutput("back", colors.combine(rs.getBundledOutput("back"), colors.blue))
- sleep(0.3)
- rs.setBundledOutput("back", colors.subtract(rs.getBundledOutput("back"), colors.blue))
- sleep(0.3)
- end
- notify("Reactor seems to be stable!")
- end,
- ["Back"] = function()
- notify("Going back!")
- n = {2,3}
- menu = tabAdd(n)
- end,
- }
- selected = 1
- repeat
- term.clear()
- for k,v in pairs(menu) do
- term.setCursorPos(2, k+1)
- if selected == k then
- term.write(string.char(194,59).." "..v)
- else
- term.write(" "..v)
- end
- end
- e, p1 = os.pullEvent()
- if p1 == 200 then
- selected = selected - 1
- if selected < 1 then
- selected = #menu
- end
- end
- if p1 == 208 then
- selected = selected + 1
- if selected > #menu then
- selected = 1
- end
- end
- if p1 == 28 then
- menuFunc[menu[selected]]()
- end
- sleep(0)
- until nil
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement