Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Username = "guest"
- local BankScript = "os/System/Programs/BankingSystem-banking_public2"
- local BankFile = "os/System/Files/.Banking"
- local function Clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- function CUI(m) --declare function
- n=1
- local l = #m
- while true do
- term.setCursorPos(1,5)
- for i=1, #m, 1 do --traverse the table of options
- if i==n then term.clearLine() print(i, ">",m[i]) else term.clearLine() print(i, "-", m[i]) end --print them
- end
- a, b= os.pullEvent("key") --wait for keypress
- if b==keys.w and n>1 then n=n-1 end
- if b==keys.s and n<l then n=n+1 end
- if b==keys.enter then break end
- end
- return n --return the value
- end
- function TransferScreen()
- Clear()
- print("please choose action")
- local options = {"send","exit"}
- local n = CUI(options)
- if options[n] == "exit" then
- Menu()
- elseif options[n] == "send" then
- Clear()
- print("enter Amount")
- local input
- while true do
- local event = {os.pullEvent("key")}
- if event[2] == keys.enter then break end
- input = read()
- end
- local Amount = input
- Clear()
- print("enter Target")
- while true do
- local event = {os.pullEvent("key")}
- if event[2] == keys.enter then break end
- input = read()
- end
- shell.run(BankScript,"Transfer", Amount,input)
- os.sleep(2)
- TransferScreen()
- end
- end
- function Menu()
- Clear()
- print("hello ",Username)
- local options = {"Details","Transfer","exit"}
- local n = CUI(options)
- if options[n] == "exit" then
- elseif options[n] == "Transfer" then
- TransferScreen()
- elseif options[n] == "Details" then
- Clear()
- print("press enter to exit")
- shell.run(BankScript,"details")
- repeat
- local event, key = os.pullEvent("key")
- until key == keys.enter
- Menu()
- end
- end
- function FirstStart()
- Clear()
- print("hello! And welcome to Imperial Banking Net")
- local options = {"Login","create account","exit"}
- local n = CUI(options)
- if options[n] == "Login" then
- LoginScreen()
- elseif options[n] == "create account" then
- CreateAccount()
- elseif options[n] == "exit" then
- end
- end
- function LoginScreen()
- Clear()
- print("please enter Username")
- local input
- while true do
- local event = {os.pullEvent("key")}
- if event[2] == keys.enter then break end
- input = read()
- end
- shell.run(BankScript,"Login",input)
- if fs.exists(BankFile) then
- Menu()
- else
- FirstStart()
- end
- end
- function CreateAccount()
- Clear()
- print("please enter username")
- local input
- while true do
- local event = {os.pullEvent("key")}
- if event[2] == keys.enter then break end
- input = read()
- end
- print("contacting servers")
- shell.run(BankScript,"CreateAccount")
- if fs.exists(BankFile) then
- Menu()
- else
- FirstStart()
- end
- end
- if fs.exists(BankFile) then
- Menu()
- else
- FirstStart()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement