Family Day update

This commit is contained in:
Ingy döt Net 2020-02-17 23:21:07 -08:00
parent aac6731f2c
commit 9ad63ea473
2442 changed files with 39761 additions and 8255 deletions

View file

@ -1,12 +1,18 @@
function choice(choices)
for i, v in ipairs(choices) do print(i, v) end
print"Enter your choice"
local selection = io.read() + 0
if choices[selection] then print(choices[selection])
else choice(choices)
end
function select (list)
if not list or #list == 0 then
return ""
end
local last, sel = #list
repeat
for i,option in ipairs(list) do
io.write(i, ". ", option, "\n")
end
io.write("Choose an item (1-", tostring(last), "): ")
sel = tonumber(string.match(io.read("*l"), "^%d+$"))
until type(sel) == "number" and sel >= 1 and sel <= last
return list[math.floor(sel)]
end
choice{"fee fie", "huff and puff", "mirror mirror", "tick tock"}
print("Nothing:", select {})
print()
print("You chose:", select {"fee fie", "huff and puff", "mirror mirror", "tick tock"})