Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- drivePerf = peripheral.find("drive")
- speaker = peripheral.find("speaker")
- function LoadDrive()
- local waiting = true
- WaitingForDriveDisplay()
- while waiting do
- if drivePerf.isDiskPresent() then
- if fs.exists("disk/bal.txt") then
- speaker.playNote("bit", 1, 24)
- DisplayBal()
- return
- end
- speaker.playNote("bit", 1, 0)
- drivePerf.setDiskLabel("Lotto Card")
- local file = fs.open("disk/bal.txt", "w")
- file.write(0)
- file.close()
- DisplayBal()
- end
- sleep(0)
- end
- end
- function WaitingForDriveDisplay()
- term.clear()
- term.setCursorPos(1,1)
- paintutils.drawFilledBox(1, 1, 51, 19, colors.lightGray)
- paintutils.drawFilledBox(11, 5, 41, 15, colors.gray)
- paintutils.drawFilledBox(20, 9, 32, 11, colors.white)
- term.setCursorPos(21,10)
- term.setTextColor(colors.black)
- term.write("Insert Disk")
- while not(drivePerf.isDiskPresent()) do
- sleep(0)
- end
- term.clear()
- term.setCursorPos(1,1)
- end
- function DisplayBal()
- local file = fs.open("disk/bal.txt", "r")
- local bal = file.readLine()
- term.clear()
- term.setCursorPos(1,1)
- paintutils.drawFilledBox(1, 1, 51, 19, colors.lightGray)
- paintutils.drawFilledBox(11, 5, 41, 15, colors.gray)
- paintutils.drawFilledBox(15, 7, 38, 9, colors.white)
- term.setCursorPos(17,8)
- term.setTextColor(colors.black)
- term.write("Bal: ")
- term.write(bal)
- paintutils.drawFilledBox(15, 11, 25, 13, colors.green)
- term.setCursorPos(17,12)
- term.setTextColor(colors.black)
- term.write("Deposit")
- paintutils.drawFilledBox(27, 11, 38, 13, colors.red)
- term.setCursorPos(29,12)
- term.setTextColor(colors.black)
- term.write("Withdraw")
- while drivePerf.isDiskPresent() do
- local event, button, x, y = os.pullEvent()
- if event == "mouse_click" then
- --deposit
- if x >= 15 and x <= 25 and y >= 11 and y <= 13 then
- speaker.playNote("bit", 1, 20)
- Deposit()
- return
- end
- --withdraw
- if x >= 27 and x <= 38 and y >= 11 and y <= 13 then
- speaker.playNote("bit", 1, 5)
- Withdraw()
- return
- end
- end
- if event == "timer" then
- sleep(0)
- end
- sleep(0)
- end
- speaker.playNote("bit", 1, 0)
- term.clear()
- term.setCursorPos(1,1)
- end
- function GetDiamonds()
- local totalDiamonds = 0
- for i = 1, 27 do
- local item = results[i]
- if item ~= nil then
- if item.name == "minecraft:diamond" then
- totalDiamonds = totalDiamonds + item.count
- end
- end
- end
- return totalDiamonds
- end
- function Deposit()
- end
- function Withdraw()
- end
- while true do
- LoadDrive()
- sleep(0)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement