Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- vend.lua
- local id = 95
- local m = peripheral.wrap("top")
- local account, name
- function button(food, price)
- m.setBackgroundColor(colors.lime)
- m.write(" ")
- m.setBackgroundColor(colors.black)
- m.write(food .. " x64 " .. price .. " Diamonds")
- local x, y = m.getCursorPos()
- m.setCursorPos(2,y+2)
- end
- m.setBackgroundColor(colors.black)
- m.clear()
- m.setCursorPos(2,3)
- button("Cooked Beef","10")
- button("Pork","7")
- m.setCursorPos(2,1)
- m.write("Current Balance:$ ")
- function getCash()
- for i = 1,100 do
- m.setCursorPos(i+17,1)
- m.write(" ")
- end
- if fs.exists("disk/accountInfo.lua") then
- print("Found Card")
- account = fs.open("disk/accountInfo.lua", "r")
- name = account.readLine()
- account.close()
- print(name)
- local num = bank.requestStatement("greenblock", name, id)
- money = tonumber(num)
- print(money)
- m.setCursorPos(18, 1)
- m.write("$")
- m.setCursorPos(19, 1)
- m.write(money)
- else
- m.setCursorPos(18, 1)
- m.write("Card Not Loaded")
- end
- end
- function printButtons()
- button("Cooked Beef", "10")
- button("Pork", "7")
- end
- function giveItem(Nom, price)
- if money >= price then
- local sum = money - price
- rednet.send(91,"beef")
- bank.sendTransaction("greenblock", name, sum, id)
- end
- end
- printButtons()
- while true do
- local event, button, bx, by = os.pullEvent()
- getCash()
- if bx == 2 and by == 3 then
- giveItem("beef", 10)
- elseif bx == 2 and by == 5 then
- giveitem("pork", 7)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement