Advertisement
Marlingaming

Cc Tweaked Vending Machine 2

Dec 19th, 2023
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. local Storages = {}--dispenser, access, products, payment
  2. local Display
  3.  
  4. local Products = {}--itemname,itemid, price
  5. local Currency = {{"createdeco:brass_coin",64},{"createdeco:iron_coin",16},{"createdeco:copper_coin",1}}
  6.  
  7. local Mode = 0-- -1 disabled, 0 setup, 1 normal, 2 debug, 3 admin
  8.  
  9. local Cart = {}
  10. function boot()
  11.  
  12. end
  13.  
  14. function UI()
  15. local Monitor = peripheral.wrap(Display)
  16. local function ProductBox(I,image)
  17. local Y = math.floor(I/3+0.7)
  18. local X = I - (Y*3)
  19. local file = fs.open(image,"r")
  20. local Line
  21. repeat
  22. Line = file.readLine()
  23. if Line ~= nil then Monitor.setCursorPos(X,Y) for x = 1, string.len(Line) do Monitor.setCursorPos((X-1)+x,Y) Monitor.blit("0",string.sub(Line,x,1),string.sub(Line,x,1)) end Y = Y + 1 end
  24. until Line == nil
  25. file.close()
  26. end
  27. local function Stats()
  28. local Cost = 0
  29. for I = 1, #Cart do
  30. Cost = Cost + (Cart[I][1]*Cart[I][2])
  31. end
  32. Monitor.setCursorPos(1,25)
  33. Monitor.write(Cost)
  34. Monitor.setCursorPos(1,26)
  35. Monitor.write("Purchase?")
  36. Monitor.setCursorPos(1,27)
  37. Monitor.write("Y/N")
  38. end
  39. Monitor.clear()
  40. for i = 1, #Products do
  41. ProductBox(i,"default.npf")
  42. end
  43. Stats()
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement