Update startup.lua
This commit is contained in:
26
startup.lua
26
startup.lua
@@ -157,6 +157,32 @@ local function input()
|
|||||||
db.setWorth(added_currency_name,added_currency_worth)
|
db.setWorth(added_currency_name,added_currency_worth)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
elseif event[2] == keys.i then
|
||||||
|
sleep(0)
|
||||||
|
local added_item_name = nil
|
||||||
|
local added_item_price = nil
|
||||||
|
local x,y = term.getSize()
|
||||||
|
term.setCursorPos(1,y)
|
||||||
|
term.write("item name > ")
|
||||||
|
local materials = db.getMaterials()
|
||||||
|
added_item_name = read(nil,nil, function(text) return completion.choice(text, materials) end)
|
||||||
|
if added_item_name == "" then
|
||||||
|
added_item_name = nil
|
||||||
|
else
|
||||||
|
repeat
|
||||||
|
print("price in items per 1 "..unit_name)
|
||||||
|
term.write("item price > ")
|
||||||
|
added_item_price = 1/tonumber(read())
|
||||||
|
until added_item_price ~= nil
|
||||||
|
if added_item_price <= 0 then
|
||||||
|
added_item_name = nil
|
||||||
|
added_item_price = nil
|
||||||
|
else
|
||||||
|
---@cast added_item_price number
|
||||||
|
db.setPrice(added_item_name,added_item_price)
|
||||||
|
price_map[added_item_name] = db.getPrice(added_item_name)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user