read if gay
This commit is contained in:
parent
4f2631b349
commit
61eefcba8c
24 changed files with 21871 additions and 4224 deletions
32
computer/20/display.lua
Normal file
32
computer/20/display.lua
Normal file
|
@ -0,0 +1,32 @@
|
|||
local display = peripheral.wrap("create_source_1")
|
||||
|
||||
local update_interval = 4
|
||||
local messages = {
|
||||
{ "Try the new MEGA MEGA STACK", "2x MEGA! 1$ only! - WOW" },
|
||||
{ "Don't miss our opening day 50% off!" },
|
||||
{ "The best vegan* fast food available", "Guaranteed less than 20% blood content" },
|
||||
}
|
||||
|
||||
local message_index = 1
|
||||
|
||||
function update_display()
|
||||
display.clear()
|
||||
local top_row = messages[message_index][1]
|
||||
local bottom_row = messages[message_index][2]
|
||||
if top_row then
|
||||
display.setCursorPos(1, 1)
|
||||
display.write(top_row)
|
||||
end
|
||||
if bottom_row then
|
||||
display.setCursorPos(1, 2)
|
||||
display.write(bottom_row)
|
||||
end
|
||||
message_index = (message_index % #messages) + 1
|
||||
end
|
||||
|
||||
function display_loop()
|
||||
while true do
|
||||
update_display()
|
||||
sleep(update_interval)
|
||||
end
|
||||
end
|
39
computer/20/fakeread.lua
Normal file
39
computer/20/fakeread.lua
Normal file
|
@ -0,0 +1,39 @@
|
|||
local buffer = ""
|
||||
local completion_index = nil
|
||||
local completion_fn = nil
|
||||
local hide_input = false
|
||||
|
||||
KEY_BACKSPACE = 259
|
||||
KEY_ENTER = 257
|
||||
|
||||
function do_event(etype, edata)
|
||||
if etype == "char" then
|
||||
buffer = buffer .. edata
|
||||
if hide_input then
|
||||
write("*")
|
||||
else
|
||||
write(edata)
|
||||
end
|
||||
elseif etype == "key" then
|
||||
if edata == KEY_BACKSPACE and #buffer > 0 then
|
||||
x, y = term.getCursorPos()
|
||||
x = x - 1
|
||||
term.setCursorPos(x, y)
|
||||
write(" ")
|
||||
term.setCursorPos(x, y)
|
||||
buffer = string.sub(buffer, 1, string.len(buffer) - 1)
|
||||
elseif edata == KEY_ENTER then
|
||||
local b = buffer
|
||||
buffer = ""
|
||||
return b
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
do_event = do_event,
|
||||
get_buffer = function() return buffer end,
|
||||
reset_buffer = function() buffer = "" end,
|
||||
set_completion = function(f) completion_fn = f end,
|
||||
hide_input = function(hide) hide_input = hide end,
|
||||
}
|
76
computer/20/gridgui.lua
Normal file
76
computer/20/gridgui.lua
Normal file
|
@ -0,0 +1,76 @@
|
|||
require("keybinds")
|
||||
ccstrings = require("cc.strings")
|
||||
|
||||
local row_heights = { 5 }
|
||||
local col_widths = { 5 }
|
||||
local layout = {}
|
||||
|
||||
local sel = {
|
||||
row = 1,
|
||||
col = 1,
|
||||
}
|
||||
|
||||
function writeAt(text, x, y)
|
||||
term.setCursorPos(x, y)
|
||||
write(text)
|
||||
end
|
||||
|
||||
function draw(x_offset, y_offset, draw_cell)
|
||||
local y = 1 + (y_offset or 0)
|
||||
for row = 1, #layout do
|
||||
local height = row_heights[row]
|
||||
local x = 1 + (x_offset or 0)
|
||||
for col = 1, #layout[row] do
|
||||
local width = col_widths[col]
|
||||
|
||||
writeAt("+", x, y)
|
||||
writeAt("+", x + width, y)
|
||||
writeAt("+", x + width, y + height)
|
||||
writeAt("+", x, y + height)
|
||||
|
||||
if sel.col == col and sel.row == row then
|
||||
writeAt(string.rep("-", width - 1), x + 1, y)
|
||||
writeAt(string.rep("-", width - 1), x + 1, y + height)
|
||||
for r = y + 1, y + height - 1 do
|
||||
writeAt("|", x, r)
|
||||
writeAt("|", x + width, r)
|
||||
end
|
||||
end
|
||||
menu_item = layout[row][col]
|
||||
if draw_cell then
|
||||
draw_cell(menu_item, x, y, width, height)
|
||||
elseif type(menu_item) == "string" then
|
||||
writeAt(menu_item, x + 1, y + 1)
|
||||
end
|
||||
x = x + width
|
||||
end
|
||||
y = y + height
|
||||
end
|
||||
end
|
||||
|
||||
function handleInput(confirm_fn)
|
||||
local _event, key = os.pullEvent("key")
|
||||
if nav.down[key] then
|
||||
sel.row = math.min(sel.row + 1, #layout)
|
||||
elseif nav.up[key] then
|
||||
sel.row = math.max(sel.row - 1, 1)
|
||||
elseif nav.right[key] then
|
||||
sel.col = sel.col + 1
|
||||
elseif nav.left[key] then
|
||||
sel.col = math.max(sel.col - 1, 1)
|
||||
elseif nav.confirm[key] then
|
||||
button = layout[sel.row][sel.col]
|
||||
confirm_fn(button)
|
||||
end
|
||||
sel.col = math.min(sel.col, #layout[sel.row])
|
||||
end
|
||||
|
||||
return {
|
||||
handleInput = handleInput,
|
||||
draw = draw,
|
||||
setLayout = function (grid, widths, heights)
|
||||
layout = grid
|
||||
col_widths = widths
|
||||
row_heights = heights
|
||||
end,
|
||||
}
|
14
computer/20/keybinds.lua
Normal file
14
computer/20/keybinds.lua
Normal file
|
@ -0,0 +1,14 @@
|
|||
nav = { up = {}, down = {}, left = {}, right = {}, confirm = {} }
|
||||
nav.up[keys.up] = 1
|
||||
nav.up[keys.w] = 1
|
||||
nav.up[keys.f] = 1
|
||||
nav.left[keys.left] = 1
|
||||
nav.left[keys.a] = 1
|
||||
nav.left[keys.r] = 1
|
||||
nav.down[keys.down] = 1
|
||||
nav.down[keys.s] = 1
|
||||
nav.right[keys.right] = 1
|
||||
nav.right[keys.d] = 1
|
||||
nav.right[keys.t] = 1
|
||||
nav.confirm[keys.enter] = 1
|
||||
nav.confirm[keys.space] = 1
|
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
|
|
@ -1,48 +1,59 @@
|
|||
screen = peripheral.wrap("create_source_1")
|
||||
require("display")
|
||||
require("menu")
|
||||
-- fakeread = require("fakeread")
|
||||
-- robot = peripheral.wrap("animatronic_1")
|
||||
|
||||
robot = peripheral.wrap("animatronic_1")
|
||||
parallel.waitForAny(menu_gui, display_loop)
|
||||
return
|
||||
--[[
|
||||
display_update_interval = 4
|
||||
|
||||
messages = {
|
||||
"Menu coming soon!",
|
||||
"Don't miss our opening day 50% off!",
|
||||
"The best vegan* fast food available"
|
||||
}
|
||||
rotations = {360-40, 360-20, 0, 360+20, 360+40}
|
||||
--return
|
||||
|
||||
n=1
|
||||
function update_rot()
|
||||
n = n%5 + 1
|
||||
target_rot = 180 + rotations[n]
|
||||
if target_rot > 180 then
|
||||
target_rot = target_rot - 360
|
||||
end
|
||||
robot.setBodyRot(0, target_rot, 0)
|
||||
robot.setFace("sad")
|
||||
robot.push()
|
||||
-- sleep(1.5)
|
||||
-- for i = 1, 5 do
|
||||
|
||||
-- end
|
||||
function start_screen()
|
||||
term.clear()
|
||||
term.setCursorPos(1, 1)
|
||||
term.setCursorBlink(true)
|
||||
print("Welcome to Spudsy's!")
|
||||
fakeread.hide_input(false)
|
||||
fakeread.reset_buffer()
|
||||
fakeread.set_completion(menu_autocomplete)
|
||||
end
|
||||
start_screen()
|
||||
|
||||
display_timer_id = os.startTimer(display_update_interval)
|
||||
|
||||
message_time = 5
|
||||
message_index = 1
|
||||
pose_time = 0
|
||||
dt = 0.1
|
||||
while true do
|
||||
sleep(dt)
|
||||
pose_time = pose_time + dt
|
||||
if pose_time > 0.4 then
|
||||
pose_time = 0
|
||||
--
|
||||
local etype, edata = os.pullEventRaw()
|
||||
if etype == "timer" then
|
||||
if edata == display_timer_id then
|
||||
update_display()
|
||||
display_timer_id = os.startTimer(display_update_interval)
|
||||
end
|
||||
elseif etype == "terminate" then
|
||||
fakeread.hide_input(true)
|
||||
fakeread.reset_buffer()
|
||||
fakeread.set_completion(nil)
|
||||
write("\ninput password to exit: ")
|
||||
local password
|
||||
repeat
|
||||
etype, edata = os.pullEventRaw()
|
||||
password = fakeread.do_event(etype, edata)
|
||||
until password
|
||||
if password == "password" then
|
||||
print()
|
||||
break
|
||||
else
|
||||
print("\nwrong password")
|
||||
sleep(2)
|
||||
start_screen()
|
||||
end
|
||||
else
|
||||
typed = fakeread.do_event(etype, edata)
|
||||
if typed then
|
||||
print("")
|
||||
end
|
||||
end
|
||||
message_time = message_time + dt
|
||||
if message_time > 4 then
|
||||
message_time = 0
|
||||
screen.clear()
|
||||
screen.setCursorPos(1, 1)
|
||||
screen.write(messages[message_index])
|
||||
message_index = (message_index % #messages) + 1
|
||||
end
|
||||
update_rot()
|
||||
end
|
||||
]]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue