Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- PRO BANK
- os.pullEvent = os.pullEventRaw
- rednet.open("bottom")
- serverID = 1
- printer = peripheral.wrap("bottom")
- w, h = term.getSize()
- select1 = {"[ Login ]", 6}
- select2 = {"Create Account", 9}
- loginItems = {"Username: ", "Password: "}
- newAccountItems = {"New Username: ", "New Password: "}
- bankItems = {"[ Deposit ]", " Withdraw ", " Transfer ", " Logout "}
- bankSel = 1
- selection = 1
- showMain = 1
- showExtra = 0
- balance = 0
- function printSel()
- term.setBackgroundColor(colors.black)term.clear()
- paintutils.drawLine(1,1,w,1, colors.cyan)
- term.setCursorPos(1,1)
- term.setTextColor(colors.white)
- print("ProBank V0.1 Created By Actiquack")
- term.setBackgroundColor(colors.black)
- if showMain == 3 then
- term.setCursorPos(12, 7)
- print(newAccountItems[1])
- term.setCursorPos(12, 8)
- print(newAccountItems[2])
- term.setCursorPos(26, 7)
- end
- if showMain == 1 then
- term.setCursorPos(26-select1[2],7)
- print(select1[1])
- term.setCursorPos(26-select2[2],8)
- print(select2[1])
- end
- if showMain == 0 then
- term.setCursorPos(16,7)
- print(loginItems[1])
- term.setCursorPos(16,8)
- print(loginItems[2])
- term.setCursorPos(26,7)
- end
- if showMain == 2 then
- term.setCursorPos(1,3)
- print("---------------------------------------------------")
- term.setCursorPos(25-#username/2,3)
- print(username)
- term.setCursorPos(1,4)
- if bankSel == 1 then
- bankItems = {"[ Deposit ]", " Withdraw ", " Transfer ", " Logout "}
- end
- if bankSel == 2 then
- bankItems = {" Deposit ", "[ Withdraw ]", " Transfer ", " Logout "}
- end
- if bankSel == 3 then
- bankItems = {" Deposit ", " Withdraw ", "[ Transfer ]", " Logout "}
- end
- if bankSel == 4 then
- bankItems = {" Deposit ", " Withdraw ", " Transfer ", "[ Logout ]"}
- end
- print(bankItems[1])
- print(bankItems[2])
- print(bankItems[3])
- print(bankItems[4])
- print("---------------------------------------------------")
- print("Balance: " .. balance)
- print(" ")
- if showExtra == 1 then
- print("Enter Check Key: ")
- term.setCursorPos(18,11)
- code = read()
- ammountAdded = checkCode(code)
- if ammountAdded == false or type(ammountAdded) == "string" then
- term.setTextColor(colors.red)print("Invalid Code")term.setTextColor(colors.white)
- sleep(3)
- showExtra = 0
- printSel()
- else
- term.setTextColor(colors.lime)print("Code Found! " .. ammountAdded .. " added to account balance")term.setTextColor(colors.white)
- sleep(3)
- balance = balance + ammountAdded
- sendBalance = {"balance", username, password, balance}
- rednet.send(serverID, sendBalance)
- showExtra = 0
- printSel()
- end
- end
- if showExtra == 2 then
- print("Enter Withdraw Ammount: ")
- term.setCursorPos(25,11)
- withAmmount = tonumber(read())
- if withAmmount > balance then
- term.setTextColor(colors.red)print("You're too poor to withdraw this ammount!")term.setTextColor(colors.white)
- sleep(3)
- showExtra = 0
- printSel()
- else
- printer.newPage()
- printer.write("Withdrew from " .. username)
- printer.setCursorPos(1,2)
- printer.write("--------------------------------------")
- printer.setCursorPos(1,3)
- printer.write("Ammount: " .. withAmmount)
- printer.setCursorPos(1,4)
- all = "123456789abcdefghijklmnopqrstuvwrxyz"
- e = ""
- for i=1, 10 do
- r = math.random(#all)
- e = e .. string.sub(all, r, r)
- end
- printer.write("Code: " .. e)
- newCode = {"newCode", e, withAmmount}
- rednet.send(serverID, newCode)
- sleep(2)
- printer.endPage()
- balance = balance - withAmmount
- sendBalance = {"balance", username, password, balance}
- rednet.send(serverID, sendBalance)
- term.setTextColor(colors.lime)print("A check worth " .. withAmmount .. " has been printed!")
- sleep(3)
- showExtra = 0
- printSel()
- end
- end
- end
- end
- printSel()
- function checkLogin(username, password)
- userCred = {"usercred", username, password}
- rednet.send(serverID, userCred)
- id, msg = rednet.receive()
- if msg == false then
- return false
- else
- balance = tonumber(msg)
- end
- end
- function checkCode(code)
- code = {"code", code}
- rednet.send(serverID, code)
- id, msg = rednet.receive()
- if msg == false then
- return false
- else
- return msg
- end
- end
- while true do
- _,key = os.pullEvent("key")
- if key == 200 or key == 208 then
- if select1[1] == "[ Login ]" then
- select1 = {"Login", 4}
- select2 = {"[ Create Account ]", 11}
- selection = 2
- printSel()
- else
- select1 = {"[ Login ]", 6}
- select2 = {"Create Account", 9}
- selection = 1
- printSel()
- end
- end
- if key == 28 then
- if selection == 2 then
- showMain = 3
- printSel()
- newUsername = read()
- term.setCursorPos(26,8)
- newPassword = read()
- newCred = {"newUser", newUsername, newPassword}
- rednet.send(serverID, newCred)
- term.setTextColor(colors.lime)
- term.setCursorPos(18,9)
- id, msg = rednet.receive()
- if msg == true then
- print("Account Created!")
- elseif msg == false then
- term.setTextColor(colors.red)
- print("Account Exists")
- end
- term.setTextColor(colors.white)
- sleep(3)
- os.reboot()
- end
- if selection == 1 then
- showMain = 0
- printSel()
- username = read()
- term.setCursorPos(26,8)
- password = read("*")
- if checkLogin(username, password) == false then
- term.setCursorPos(18,9)
- term.setTextColor(colors.red)print("Login Failed")term.setTextColor(colors.white)
- sleep(3)
- showMain = 1
- printSel()
- else
- showMain = 2
- printSel()
- --BANK
- while showMain == 2 do
- _, key = os.pullEvent("key")
- if key == 200 then
- bankSel = bankSel - 1
- if bankSel <= 0 then
- bankSel = 4
- end
- printSel()
- end
- if key == 208 then
- bankSel = bankSel + 1
- if bankSel >= 5 then
- bankSel = 1
- end
- printSel()
- end
- if key == 28 then
- if bankSel == 4 then
- os.reboot()
- end
- if bankSel == 1 then
- showExtra = 1
- printSel()
- end
- if bankSel == 2 then
- showExtra = 2
- printSel()
- end
- end
- end
- --END BANK
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement