Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.pullEvent = os.pullEventRaw
- local ControlChannel = 101
- local ListenChannel = 103
- local TransferChest = 1
- local UserDetails = {}
- local TerminalNum = 1
- local function SystemInteraction(Key1,Key2,Action,Amount)
- local modem = peripheral.find("modem")
- local DT
- if Action == "signin" then DT = {Key1,Key2,Action} elseif Action == "Transfer" then DT = {Key1,Key2,Action,tonumber(Amount)} elseif Action == "Admin" then DT = {Key1,0,Action,Key2} elseif Action == "Details" then DT = {Key1,0,Action} end
- modem.transmit(ControlChannel, ListenChannel, textutils.serialize(DT))
- local a, b, c, d, e
- modem.open(103)
- repeat
- a, b, c, d, e = os.pullEvent()
- until c == 103
- return textutils.unserialize(e)
- end
- local function TextField()
- local input
- local TX, TY = term.getCursorPos()
- TY = TY - 1
- while true do
- term.setCursorPos(TX,TY)
- term.clearLine()
- term.write()
- local e, a, b, c = os.pullEvent("key")
- if a == keys.enter then break elseif e == "key" then input = read(C) end
- end
- return input
- end
- local function Page(title,text)
- term.setBackgroundColor(colors.cyan)
- term.setTextColor(colors.white)
- term.clear()
- term.setCursorPos(1,1)
- print(title.." == Banking Terminal #"..TerminalNum)
- if text ~= nil and #text > 0 then
- print("[text]")
- for i = 1, #text do
- print(text[i])
- end
- end
- print("[options]")
- end
- local function OptionList(y,options)
- local I
- local n = 1
- repeat
- for i = 1, #options do
- term.setCursorPos(1,(y - 1) + i)
- term.clearLine()
- if n == i then term.write(">> "..options[i]) else term.write(options[i]) end
- end
- local a, b = os.pullEvent("key")
- if b == keys.w and n > 1 then n = n - 1 end
- if b == keys.s and n < #options then n = n + 1 end
- if b == keys.enter then I = n end
- until I ~= nil
- return options[I]
- end
- local function TransMenu(Key)
- Page("Transaction",{"Enter Amount, use Negatives for withdraw"})
- local Text = TextField()
- SystemInteraction(Key,TransferChest,"Transfer",Text)
- MMenu(Key)
- end
- function MMenu(Key)
- local AccountDetails = {}
- AccountDetails = SystemInteraction(Key,0,"Details",0)--Balance,Username
- Page("User Menu",{"Welcome, "..AccountDetails[2],AccountDetails[1]})
- local Opt = OptionList(5,{"Transaction","logout"})
- if Opt == "logout" then os.reboot() else TransMenu(Key) end
- end
- local function AdminLogin()
- end
- local function Signin()
- Page("Welcome",{"Please Either Signin using your key","or create a new account by contacting a administrator"})
- local d, Y = term.getCursorPos()
- Y = Y + 1
- local Opt = OptionList(Y,{"Signin","admin"})
- if Opt == "admin" then
- AdminLogin()
- end
- Page("Signin")
- print("Key")
- print("|")
- local Key = TextField()
- local DE = SystemInteraction(Key,1,"signin",0)
- if DE[1] == true then MMenu(Key) else print("failed") os.sleep(1) os.reboot() end
- end
- local function Start()
- Signin()
- end
- Start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement