Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local oldPull = os.pullEvent
- os.pullEvent = os.pullEventRaw
- --this is my newest idea for CC Tweaked to allow a tax Collection system that counts the resources and makes sure its equal to the required amount, then if it is done correctly, it will print a receipt with the date, town taxes paid at, and ATM ID.
- Settings_ATMID = "0001"
- Settings_Settlement = "Test"
- Settings_AdminAccount = "Guest"
- Settings_ReqCredits = 2
- Settings_UseAdvTaxDatabase = false
- Settings_AllowedResources[true,false,false,false]--Resources: Diamonds, Netherite, XPOrbs, Emeralds
- System_State = "Unlocked"
- --Credit Value
- Value_Diamond = 1
- Value_Netherite = 100
- Value_XPOrb = 100
- Value_Emeralds
- --PlayerInput
- PaidAmount = 0
- ReqAmount = 2
- Account = "Guest"
- --Program
- local printer = peripheral.wrap("top")
- local Dispenser = peripheral.find("minecraft:dispenser")
- start()
- function start()
- if fs.exists(".TerminalState") == false then
- SystemSetup()
- else
- local h = fs.open(".AdminAccount","r")
- Settings_AdminAccount = h.readAll()
- h.close()
- local h = fs.open(".TerminalState","r")
- System_State = h.readAll()
- h.close()
- if System_State == "Locked" then
- LockedScreen()
- else if System_State == "Unlocked" then
- if fs.exists("Accounts") == false && Settings_UseAdvTaxDatabase == true then
- ERROR("Accounts", 2)
- else
- term.setCursorPos(0,1)
- term.write("---Tax Dropoff System---")
- term.setCursorPos(0,2)
- term.write("Please Place Payment in the Dispenser Below, then pickup Receipt from Above")
- term.setCursorPos(0,3)
- term.write("Required Credits = "+Settings_ReqCredits)
- term.setCursorPos(0,6)
- term.write("the following is a converstion Sheet")
- term.setCursorPos(0,7)
- term.write("---------------------")
- term.setCursorPos(0,8)
- if Settings_AllowedResources[0] == true then
- term.write("1 Diamond == "+Value_Diamond)
- else
- term.write("Diamonds are not accepted")
- end
- term.setCursorPos(0,9)
- if Settings_AllowedResources[1] == true then
- term.write("1 Netherite == "+Value_Netherite)
- else
- term.write("Netherite are not accepted")
- end
- term.setCursorPos(0,10)
- if Settings_AllowedResources[2] == true then
- term.write("1 XPOrb == "+Value_XPOrb)
- else
- term.write("XPOrb are not accepted")
- end
- term.setCursorPos(0,11)
- if Settings_AllowedResources[3] == true then
- term.write("1 Emerald == "+Value_Emeralds)
- else
- term.write("Emeralds are not accepted")
- end
- term.setCursorPos(0,12)
- term.write("Standing By, waiting for Payment")
- StandBy()
- end
- end
- end
- end
- function Reset()
- PaidResources = "Credits"
- term.clear()
- local Paper == printer.getPaperLevel()
- local INK = printer.getInkLevel()
- if Paper = 0 then
- ERROR("Paper",1)
- else if INK == 0 then
- ERROR("Ink",1)
- else
- start()
- end
- end
- function Standby()
- if Settings_UseAdvTaxDataBase == true then
- term.setCursorPos(0,4)
- term.write("Please Login, press enter to confirm")
- Login()
- else if Settings_UseAdvTaxDataBase == false then
- Input()
- end
- end
- function 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(Account)
- local s = fs.open(".Accounts","r")
- for i=1, #accounts do
- if s.readLine(i*2) == Account then
- ReqAmount = s.readLine((i*2)+1)
- Input()
- end
- end
- end
- function AdminMenu()
- term.clear()
- term.setCursorPos(0,1)
- term.write("-------ADMIN---MENU------")
- term.setCursorPos(19,2)
- term.write("OPTIONS")
- term.setCursorPos(0,3)
- term.write("1 = Accounts")
- term.setCursorPos(0,4)
- term.write("2 = Stop Program")
- term.setCursorPos(0,5)
- term.write("3 = Lock/Unlock Terminal")
- local event, key = os.pullEvent("key")
- while true do
- if key == keys.1 then
- Admin_Accounts()
- else if key == keys.2 then
- shell.stop()
- else if key == keys.3 then
- break
- if System_State == Lock then
- ChangeState("Unlocked")
- else if System_State == Unlocked then
- ChangeState("Locked")
- end
- end
- end
- end
- function Input()
- while true do
- local Items = Dispenser.list()
- if Items.length > 0 then
- PaidAmount = 0
- for slot, item in pairs(Dispenser.list()) do
- local item = Dispenser.getItemDetail(slot)
- if item.name == "Diamond" && Settings_AllowedResources[0] == true then
- PaidAmount = PaidAmount + (item.count*Value_Diamond)
- else if item.name == "Netherite" && Settings_AllowedResources[1] == true then
- PaidAmount = PaidAmount + (item.count*Value_Netherite)
- else if item.name == "-----" && Settings_AllowedResources[2] == true then
- PaidAmount = PaidAmount + (item.count*Value_XPOrbs)
- else if item.name == "Emerald" && Settings_AllowedResources[3] == true then
- PaidAmount = PaidAmount + (item.count*Value_Emeralds)
- else if item.name == "1 Credit" then
- PaidAmount = PaidAmount + item.count
- else if item.name == "10 Credits" then
- PaidAmount = PaidAmount + (item.count*10)
- else if item.name == "100 Credits" then
- PaidAmount = PaidAmount + (item.count*100)
- end
- end
- if PaidAmount >= Settings_ReqCredits && Settings_UseAdvTaxDatabase == false then
- break
- Transaction()
- else if PaidAmount == ReqAmount && Settings_UseAdvTaxDatabase == true then
- break
- Transaction()
- end
- end
- end
- end
- function Transaction()
- local Items = Dispenser.list
- while true do
- setOutput("bottom","on")
- sleep(2)
- setOutput("bottom","off")
- if Items.length == 0 then
- break
- Receipt()
- end
- end
- end
- function Receipt()
- term.setCursorPos(5,12)
- term.write("Printing Receipt")
- printer.newPage()
- printer.setPageTitle(Settings_Settlement+" Tax Receipt")
- printer.setCursorPos(0,1)
- printer.write("Tax Receipt")
- printer.setCursorPos(0,2)
- printer.write("Settlement = "+Settings_Settlement)
- printer.setCursorPos(0,3)
- printer.write("Req Tax Payment: "+Settings_ReqCredits+" Credits")
- printer.setCursorPos(0,4)
- printer.write("Paid Amount = "+PaidAmount)
- printer.setCursorPos(0,5)
- printer.write("Date: "+)
- printer.setCursorPos(0,6)
- printer.write("ATM ID: "+Settings_ATMID)
- printer.endPage()
- sleep(20)
- Reset()
- end
- function ERROR(Item, Cause)
- term.clear
- term.setCursorPos(0,1)
- term.write("----------ERROR---FOUND------------")
- if Cause == 1 then --missing Resource
- term.setCursorPos(0,2)
- term.write("Cant Continue with Operations Due to Lack of Items")
- term.setCursorPos(0,3)
- term.write("Lacking "+Item)
- sleep(15)
- ChangeState("Locked")
- else if Cause == 2 then --missing File
- term.setCursorPos(0,2)
- term.write("cant Continue with operations due to Missing Resources")
- term.setCursorPos(0,3)
- term.write("missing file named: "+Item)
- if Item == "Accounts" then
- term.setCursorPos(0,4)
- term.write("a Example File has Been downloaded to help you make a account file")
- term.setCursorPos(0,5)
- term.write("the file should be named 'EX_Accounts'")
- local h = fs.open("EX_Accounts","w")
- h.setCursorPos(0,1)
- h.writeLine("(keep this blank, but make sure the file is named '.Account')")
- h.writeLine("<Account Name>")
- h.writeLine("<Req Credits>")
- h.writeLine("<Account Name>")
- h.writeLine("<Req Credits")
- h.writeLine("<Account Name>")
- h.writeLine("<Req Credits")
- h.close()
- end
- term.setCursorPos(0,10)
- term.write("program will be set to Locked Screen to prevent anymore Errors")
- sleep(15)
- ChangeState("Locked")
- end
- end
- function SystemSetup()
- term.setCursorPos(0,1)
- term.write("Installing Files for first time Setup")
- term.setCursorPos(0,3)
- term.write("Please enter the desired Name for Admin Account")
- local admin = read()
- local event, key = os.pullEvent("key")
- while true do
- print(admin)
- if key = keys.enter then
- Settings_AdminAccount = admin
- break
- end
- end
- term.setCursorPos(0,5)
- term.write("Admin Account Set, now Installing final Files, then a restart will begin")
- local h = fs.open(".AdminAccount","w")
- h.write(Settings_AdminAccount)
- h.close()
- h = fs.open(".TerminalState","w")
- h.write("Locked")
- h.close()
- os.reboot()
- end
- function AdminAccouts()
- term.clear()
- local h = fs.open(".Accounts","a")
- local AC = h.readAll()
- for i=1, list(h).length, do
- term.setCursorPos(0,i)
- write(h.readLine(i)
- end
- h.close()
- h.open(".Accounts","w")
- read() = AC
- AC = read()
- while true do
- if key == keys.enter then
- break
- h.write(AC)
- end
- end
- AdminMenu()
- end
- function LockedScreen()
- paintutils.drawFilledBox(0,0,51,19,colors.blue)
- term.setCursorPos(0,4)
- term.write("---------LOCKED----TERMINAL-------")
- term.setCursorPos(0,8)
- term.write("this terminal has been locked by an adminstrator. to unlock this terminal")
- term.setCursorPos(0,9)
- term.write("please login to the admin account now")
- local Admin = read()
- local event, key = os.pullEvent("key")
- while true do
- term.setCursorPos(0,10)
- print(Admin)
- if key == keys.enter && Admin == Settings_AdminAccout then
- term.setCursorPos(0,11)
- term.write("Account Accepted, now entering AdminMenu")
- sleep(10)
- term.clear()
- break
- AdminMenu()
- end
- end
- end
- function ChangeState(State)
- local h = fs.open(".TerminalState","w")
- h.write(State)
- h.close()
- sleep(10)
- os.reboot()
- end
- os.pullEvent = oldPull
Add Comment
Please, Sign In to add comment