read if gay
This commit is contained in:
parent
4f2631b349
commit
61eefcba8c
24 changed files with 21871 additions and 4224 deletions
93
computer/20/menu.lua
Normal file
93
computer/20/menu.lua
Normal file
|
@ -0,0 +1,93 @@
|
|||
gui = require("gridgui")
|
||||
ccstrings = require("cc.strings")
|
||||
|
||||
local burger_storage = peripheral.wrap("minecraft:chest_0")
|
||||
|
||||
local menu_options = {
|
||||
hamburger = {
|
||||
id = "hamburger",
|
||||
name = "Steamed Hams",
|
||||
description = "normal boring burger, required to be on the menu for legal reasons",
|
||||
price = 13.12,
|
||||
},
|
||||
the_slab = {
|
||||
id = "the_slab",
|
||||
name = "The Slab",
|
||||
description = "Carefully curated human meat (for humans)",
|
||||
price = 0.31,
|
||||
},
|
||||
mega_mega_stack = {
|
||||
id = "mega_mega_stack",
|
||||
name = "Mega Mega Stack",
|
||||
description = "WOW",
|
||||
price = 1,
|
||||
},
|
||||
pickle = {
|
||||
id = "pickle",
|
||||
name = "Just Pickles",
|
||||
description = "Soft on the outside crunchy on the inside",
|
||||
price = 70,
|
||||
},
|
||||
sour_cream = {
|
||||
id = "sour_cream",
|
||||
name = "Sour cream in a cone",
|
||||
price = 50,
|
||||
description = "Aged sour cream left out to aerate for 30 hours",
|
||||
}
|
||||
}
|
||||
|
||||
local menu_layout = {
|
||||
{ menu_options.the_slab, menu_options.hamburger },
|
||||
{ menu_options.mega_mega_stack, menu_options.pickle },
|
||||
{ menu_options.sour_cream },
|
||||
{ "checkout", "clear" }
|
||||
}
|
||||
|
||||
local in_checkout = false
|
||||
local basket = {}
|
||||
|
||||
function draw_menu_item(menu_item, x, y, width, height)
|
||||
if type(menu_item) == "table" then
|
||||
writeAt(menu_item.name, x + 1, y + 1)
|
||||
writeAt(" $" .. tostring(menu_item.price), x + 1, y + 2)
|
||||
for i, line in pairs(ccstrings.wrap(menu_item.description, width - 1)) do
|
||||
writeAt(line, x + 1, y + 2 + i)
|
||||
end
|
||||
elseif menu_item == "checkout" then
|
||||
writeAt("checkout (" .. #basket .. " items)", x + 1, y + 1)
|
||||
elseif menu_item == "clear" then
|
||||
writeAt("clear", x + 1, y + 1)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function menu_gui()
|
||||
gui.setLayout(menu_layout, { 25, 24 }, { 6, 6, 6, 2 })
|
||||
while true do
|
||||
term.clear()
|
||||
term.setCursorPos(1, 1)
|
||||
if in_checkout then
|
||||
print("checkout:")
|
||||
gui.draw(30,3, function(i,x,y) writeAt(i,x+2,y+2) end)
|
||||
gui.handleInput(function (c)
|
||||
|
||||
end)
|
||||
else
|
||||
print("Welcome to Spudsy's!")
|
||||
print("menu:")
|
||||
gui.draw(0, 2, draw_menu_item)
|
||||
gui.handleInput(
|
||||
function(button)
|
||||
if button.id then
|
||||
table.insert(basket, button.id)
|
||||
elseif button == "cancel" then
|
||||
basket = {}
|
||||
elseif button == "checkout" then
|
||||
in_checkout = true
|
||||
gui.setLayout({{1,2,3},{4,5,6},{9,8,7},{".",0}}, {4,4,4}, {4,4,4,4})
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue