Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --this program acts as both a local circulation and national circulation ATM system for the SCS3 Project
- Settings_ATMID = "0"
- Settings_Access = "local"
- Settings_Bank = "Guest"
- Settings_State = "Locked"
- Settings_AdminAccount = "Admin"
- Settings_CurrencyName = "Credit"--Use the word for a single of it
- Settings_AllowedAmounts[false,true,false,true,true]--five, ten, twenty, one hundred, one thousand
- --User
- Client_Username = "Guest"
- Client_UserCode = 0
- Client_HostServer = -1
- Client_Transfer = 0
- Client_Balance = 0
- --Program
- start()
- function start()
- print("Checking Files")
- if fs.exists(".Accounts") == false then
- CreateFiles("Accounts")
- end
- if fs.exists(".Balance") == false then
- CreateFiles("Balance")
- end
- if fs.exists(".SystemSettings") == false then
- CreateFile("Settings")
- end
- SetupSettings()
- Login()
- end
- function CreateFiles(File)
- local h = 0
- if File == "Accounts" then
- h = fs.open(".Accounts","w")
- h.write("This FIle is for Accounts")
- h.close()
- else if File == "Balance" then
- h = fs.open(".Balance","w")
- h.write("This file is for Balance")
- h.close()
- else if File == "Settings" then
- end
- end
- function SetupSettings()
- end
- function LogOut()
- term.clear()
- Client_Username = "Guest"
- Client_UserCode = 0
- Client_HostServer = -1
- Client_Transfer = 0
- Client_Balance = 0
- Login()
- end
- function Login()
- term.setCursorPos(1,1)
- term.write("Please Login")
- local User = read()
- local event, key = os.pullEvent("key")
- while true do
- if key == keys.enter then
- if User == Settings_AdminAccount then
- AdminMenu()
- break
- else
- CheckAccounts(User)
- break
- end
- end
- end
- end
- function CheckAccounts(User)
- if Settings_Access == "local" then
- local h = fs.open(".Accounts","r")
- local i = 2
- while true do
- if h.read(i) == User then
- h.close()
- Client_Username = User
- Client_UserCode = i
- break
- Menu()
- else
- i = i+1
- end
- end
- else if Settings_Access == "Server" then
- Network("Confirm","Account",User)
- else if Settings_Access == "Disabled" then
- end
- end
- function Menu()
- term.clear()
- term.setCursorPos(1,1)
- term.write("----------MENU-----------")
- term.setCursorPos(1,2)
- term.write("Options")
- term.setCursorPos(1,3)
- term.write(" 1 - Account Details")
- term.setCursorPos(1,4)
- term.write(" 2 - Deposit")
- term.setCursorPos(1,5)
- term.write(" 3 - WithDraw")
- term.setCursorPos(1,6)
- term.write(" 4 - ")
- term.setCursorPos(1,7)
- term.write(" X - Log Out")
- local event, key = os.pullEvent("key")
- while true do
- if key == keys.1 then
- break
- else if key == keys.2 then
- break
- TransferMenu("Deposit")
- else if key == keys.3 then
- break
- TransferMenu("WithDraw")
- else if key == keys.4 then
- else if key == keys.x then
- break
- LogOut()
- end
- end
- end
- function TransferMenu(Type)
- term.clear()
- term.setCursorPos(1,1)
- term.write(Type)
- term.setCursorPos(1,2)
- if Type == "Deposit" then
- term.write("Please Place Cash in Container, then press Enter")
- else if Type == "WithDraw" then
- term.write("Please Enter Amount, then Press Enter")
- end
- local Amount = read()
- local event, key = os.pullEvent("key")
- while true do
- if key == keys.enter then
- if Type == "Deposit" then
- break
- CountCash()
- else if Type == "WithDraw" then
- Transfer("WithDraw",Amount)
- end
- end
- end
- end
- function CountCash()
- local Container = peripheral.find("minecraft:Despenser")
- local DetectedAmount = 0
- for slot, item in pairs(Container.list()) do
- if item.name == "1 " + Settings_CurrencyName then
- DetectedAmount = DetectedAmount+1
- else if item.name == "5 " + Settings_CurrencyName + "s" && Settings_AllowedAmounts[0] == true then
- DetectedAmount = DetectedAmount + 5
- else if item.name == "10 " + Settings_CurrencyName + "s" && Settings_AllowedAmounts[1] == true then
- DetectedAmount = DetectedAmount + 10
- else if item.name == "20 " + Settings_CurrencyName + "s" && Settings_AllowedAmounts[2] == true then
- DetectedAmount = DetectedAmount + 20
- else if item.name == "100 " + Settings_CurrencyName + "s" && Settings_AllowedAmounts[3] == true then
- DetectedAmount = DetectedAmount + 100
- else if item.name == "1000 " + Settings_CurrencyName + "s" && Settings_AllowedAmounts[4] == true then
- DetectedAmount = DetectedAmount + 1000
- end
- end
- Client_Transfer = DetectedAmount
- Transfer("Deposit",DetectedAmount)
- end
- function Transfer(Method,Amount)
- if Method == "Deposit" then
- if Settings_Access == "Local" then
- local h = fs.open(".Balances","a")
- h.setCursorPos(0,Client_UserCode)
- Client_Balance = h.readLine()
- Client_Balance = Client_Balance + Amount
- h.clearLine()
- h.write(Client_Balance)
- h.close()
- else if Settings_Access == "Network" then
- end
- else if Method == "WithDraw" then
- end
- term.setCursorPos(0,9)
- term.write("New Balance = "+Client_Balance+" "+Settings_CurrencyName)
- term.write("Amount Processed, Logging Out")
- sleep(10)
- LogOut()
- end
- function Network(Mode,Item,ID)
- if Mode == "Confirm" then
- else if Mode == "Change" then
- else if Mode == "Create" then
- end
- end
- function AdminMenu()
- end
Add Comment
Please, Sign In to add comment