Improve prompts

master
D4VID 10 months ago
parent a4550b6f2b
commit 06aee93cc7

@ -69,11 +69,12 @@ end
---@return boolean ---@return boolean
local function confirm() local function confirm()
while true do while true do
print("Proceed? [y/n]") print("Proceed? [Y/n]")
-- local _, _, ascii, _, _ = term.pull("key_down")
-- local ch = string.char(ascii)
local ch = io.read() local ch = io.read()
if ch == 'y' then if not ch then
return false -- interrupted
end
if ch == 'y' or ch == 'Y' or ch == '' then
return true return true
elseif ch == 'n' then elseif ch == 'n' then
return false return false
@ -369,6 +370,7 @@ local function craft_item(search)
selected = matches[index] selected = matches[index]
end end
clear_crafting_space()
local recipe = recipes[selected] local recipe = recipes[selected]
@ -405,17 +407,15 @@ local function craft_item(search)
return false return false
end end
print('\nCrafting in order:') -- print('\nCrafting in order:')
for i, rec in ipairs(crafting_order) do -- for i, rec in ipairs(crafting_order) do
print(i, rec.result) -- print(i, rec.result)
end -- end
if not confirm() then
print('Operation cancelled')
return false
end
clear_crafting_space() -- if not confirm() then
-- print('Operation cancelled')
-- return false
-- end
-- proceed to crafting the things -- proceed to crafting the things
for i, rec in ipairs(crafting_order) do for i, rec in ipairs(crafting_order) do

Loading…
Cancel
Save