Advertisement
Guest User

vend.lua

a guest
May 17th, 2021
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.36 KB | None | 0 0
  1. local id = 95
  2. local m = peripheral.wrap("top")
  3.  
  4. function button(food,price)
  5. m.setBackgroundColor(colors.lime)
  6. m.write(" ")
  7. m.setBackgroundColor(colors.black)
  8. m.write(" "..food.." x64 "..price.." Diamonds")
  9. local x,y = m.getCursorPos()
  10. m.setCursorPos(2,y+2)
  11. end
  12.  
  13. m.setBackgroundColor(colors.black)
  14. m.clear()
  15. m.setCursorPos(2,3)
  16. button("Cooked Beef","10")
  17. button("Pork","7")
  18. m.setCursorPos(2,1)
  19. m.write("Current Balance:$ ")
  20.  
  21. function getCash()
  22.  for i = 1,100 do
  23.  m.setCursorPos(i+17,1)
  24.  m.write(" ")
  25.  end
  26.  if fs.exists("disk/accountInfo.lua") then
  27.  print("Found Card")
  28.  account = fs.open("disk/accountInfo.lua","r")
  29.  local name = account.readLine()
  30.  print(name)
  31.  local num = bank.requestStatement("greenblock",name,id)
  32.  money = tonumber(num)
  33.  print(money)
  34.  m.setCursorPos(18,1)
  35.  m.write("$")
  36.  m.setCursorPos(19,1)
  37.  m.write(money)
  38.  else
  39.  m.setCursorPos(18,1)
  40.  m.write("Card Not Loaded")
  41.  end
  42. end
  43.  
  44. function printButtons()
  45. button("Cooked Beef","10")
  46. button("Pork","7")
  47. end
  48.  
  49. function giveItem(Nom,price)
  50.  if money >= price then
  51.  local sum = money - price
  52.  rednet.send(91,"beef")
  53.  bank.sendTransaction("greenblock",account,sum,id)
  54.  end
  55. end
  56. printButtons()
  57.  
  58. while true do
  59. local event, button, bx, by = os.pullEvent()
  60. getCash()
  61.  
  62. if bx == 2 and by == 3 then
  63. giveItem("beef",10)
  64. elseif bx == 2 and by == 5 then
  65. giveitem("pork",7)
  66. end
  67.  
  68. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement