Module:Products: Difference between revisions
x -> × simplify single value / table of values implementation; allow quantity to have a decimal point (like when it's "0.05")
The Gaffer (talk | contribs) No edit summary |
(x -> × simplify single value / table of values implementation; allow quantity to have a decimal point (like when it's "0.05")) |
||
Line 46:
for _, product in ipairs(products) do
local usesItems = product["Uses item and quantity"]
if type(usesItems) == "
-- Extract item name and quantity from the "item,#" format▼
for _, item in ipairs(usesItems) do
local itemName, quantity =
▲ end
▲ elseif type(usesItems) == "string" then
quantity = tonumber(quantity) or 1 -- Default to 1 if quantity is missing
Line 90 ⟶ 70:
-- Update the product with the formatted string and total price
product[itemName .. "_Shop_buy_price"] = totalPrice > 0 and totalPrice or "N/A"
product[itemName .. "_Formatted"] = tostring(quantity) .. "
end
end
|