mercwear

cc_vend

Jun 22nd, 2025 (edited)
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.71 KB | None | 0 0
  1. --This script expects the basalt lib directory to be one directory above it (it should live in the startup directory in the root of the computer)
  2. local basalt = require("/basalt") --UI Library for cc tweaked
  3.  
  4. -- Get a reference to the monitor
  5. local monitor = peripheral.find("monitor")
  6. -- Or specific side: peripheral.wrap("right")
  7.  
  8. local bridge = peripheral.wrap("meBridge_1")
  9. local dropper = peripheral.wrap("justdirethings:droppert1_1")
  10.  
  11.  
  12. -- Create frame for monitor
  13. local monitorFrame = basalt.createFrame():setTerm(monitor) -- :setTerm is the important method here
  14.  
  15. local button_bg_color = colors.green
  16. local button_bg_color_on_click = colors.red
  17. local toggle_status = true
  18.  
  19.  
  20.  
  21.  
  22. local function vend(item_name)
  23.  
  24. status_label:setText("Vending "..item_name)
  25.  
  26. if item_name == "Bread" then
  27. bridge.exportItemToPeripheral({name = "minecraft:bread", count=1}, peripheral.getName(dropper))
  28. end
  29. if item_name == "Helmet" then
  30. bridge.exportItemToPeripheral({name = "minecraft:iron_helmet", count=1}, peripheral.getName(dropper))
  31. end
  32. if item_name == "Sword" then
  33. bridge.exportItemToPeripheral({name = "minecraft:iron_sword", count=1}, peripheral.getName(dropper))
  34. end
  35.  
  36. if item_name == "Boots" then
  37. bridge.exportItemToPeripheral({name = "minecraft:iron_boots", count=1}, peripheral.getName(dropper))
  38. end
  39. if item_name == "Chest" then
  40. bridge.exportItemToPeripheral({name = "minecraft:iron_chestplate", count=1}, peripheral.getName(dropper))
  41. end
  42. if item_name == "Legs" then
  43. bridge.exportItemToPeripheral({name = "minecraft:iron_leggings", count=1}, peripheral.getName(dropper))
  44. end
  45. if item_name == "Patch" then
  46. bridge.exportItemToPeripheral({name = "bhc:red_heart_patch", count=1}, peripheral.getName(dropper))
  47. end
  48. if item_name == "Neck" then
  49. bridge.exportItemToPeripheral({name = "bhc:heart_amulet", count=1}, peripheral.getName(dropper))
  50. end
  51. if item_name == "Canister" then
  52. bridge.exportItemToPeripheral({name = "bhc:red_heart_canister", count=1}, peripheral.getName(dropper))
  53. end
  54.  
  55. status_label:setText("Left Click On Button To Vend Item")
  56.  
  57. end
  58.  
  59.  
  60. -- Add elements like normal
  61. top_banner = monitorFrame:addLabel()
  62. :setText(utf8.char(127).." Mercs Free Vending "..utf8.char(127))
  63. :setPosition(4, 1)
  64.  
  65. status_label = monitorFrame:addLabel()
  66. :setText("Left Click On Button To Vend Item")
  67. :setPosition(1, 17)
  68.  
  69. first_button = monitorFrame:addButton()
  70. :setText("Bread")
  71. :setWidth(9)
  72. :setPosition(1, 3)
  73. :setBackground(button_bg_color)
  74. :onClick(function()
  75. vend("Bread")
  76. end)
  77.  
  78. second_button = monitorFrame:addButton()
  79. :setText(" Helmet")
  80. :setWidth(9)
  81. :setPosition(11, 3)
  82. :setBackground(button_bg_color)
  83. :onClick(function()
  84. vend("Helmet")
  85. end)
  86.  
  87. third_button = monitorFrame:addButton()
  88. :setText("Sword")
  89. :setWidth(9)
  90. :setPosition(21, 3)
  91. :setBackground(button_bg_color)
  92. :onClick(function()
  93. status_label:setText("Vending Sword")
  94. vend("Sword")
  95. end)
  96.  
  97. fourth_button = monitorFrame:addButton()
  98. :setText("Legs")
  99. :setWidth(9)
  100. :setPosition(1, 7)
  101. :setBackground(button_bg_color)
  102. :onClick(function()
  103. status_label:setText("Vending Legs")
  104. vend("Legs")
  105. end)
  106.  
  107. fifth_button = monitorFrame:addButton()
  108. :setText("Chest")
  109. :setWidth(9)
  110. :setPosition(11, 7)
  111. :setBackground(button_bg_color)
  112. :onClick(function()
  113. status_label:setText("Vending Chest")
  114. vend("Chest")
  115. end)
  116.  
  117. sixth_button = monitorFrame:addButton()
  118. :setText("Boots")
  119. :setWidth(9)
  120. :setPosition(21, 7)
  121. :setBackground(button_bg_color)
  122. :onClick(function()
  123. status_label:setText("Vending Boots")
  124. vend("Boots")
  125. end)
  126.  
  127. seventh_button = monitorFrame:addButton()
  128. :setText(utf8.char(3).."Patch"..utf8.char(3))
  129. :setWidth(9)
  130. :setPosition(1, 11)
  131. :setBackground(button_bg_color)
  132. :onClick(function()
  133. status_label:setText("Vending Heal Patch")
  134. vend("Patch")
  135. end)
  136.  
  137. eighth_button = monitorFrame:addButton()
  138. :setText(utf8.char(3).."Neck"..utf8.char(3))
  139. :setWidth(9)
  140. :setPosition(11, 11)
  141. :setBackground(button_bg_color)
  142. :onClick(function()
  143. status_label:setText("Vending Neck")
  144. vend("Neck")
  145. end)
  146.  
  147. ninth_button = monitorFrame:addButton()
  148. :setText(utf8.char(3).."Canister".. utf8.char(3))
  149. :setWidth(9)
  150. :setPosition(21, 11)
  151. :setBackground(button_bg_color)
  152. :onClick(function()
  153. status_label:setText("Vending Canister")
  154. vend("Canister")
  155. end)
  156. -- Start Basalt
  157. basalt.run()
Advertisement
Add Comment
Please, Sign In to add comment