Модуль:Prototypes/Хранилище/Предмет: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 56: | Строка 56: | ||
local amount = (amountNumber and amountNumber ~= 1) and string.format(" [%d]", amountNumber) or "" | local amount = (amountNumber and amountNumber ~= 1) and string.format(" [%d]", amountNumber) or "" | ||
local prob = "" | |||
local probValue = nil | |||
if content.prob then | |||
-- Если значение вероятности указано в формате десятичной дроби (например, 0.5) | |||
probValue = content.prob * 100 -- перевод в проценты | |||
elseif content.weight then | |||
probValue = content.weight | |||
end | |||
if probValue then | |||
prob = string.format(" <div>%s%%</div>", probValue >= 1 and math.floor(probValue) or probValue) | |||
end | |||
return string.format( | return string.format( | ||
-- <span></span> - костыль, без него ломается все почему-то | |||
'{{#invoke:Предмет|main|%s|%s<span>%s</span>|repository=1|wrapper=1}}', | '{{#invoke:Предмет|main|%s|%s<span>%s</span>|repository=1|wrapper=1}}', | ||
id, amount, prob | id, amount, prob | ||
| Строка 376: | Строка 380: | ||
return frame:preprocess('{{СollapsibleMenu|' .. getContainedOutput(itemDataIndex, id) .. '}}') | return frame:preprocess('{{СollapsibleMenu|' .. getContainedOutput(itemDataIndex, id) .. '}}') | ||
elseif subMode == "slot" then | elseif subMode == "slot" then | ||
local itemDataEntry = findDataById(itemSlotsData, id) | |||
if not itemDataEntry then return "" end | |||
local startingItem = nil | |||
if itemDataEntry.ItemSlots and itemDataEntry.ItemSlots.slots then | |||
for _, slot in pairs(itemDataEntry.ItemSlots.slots) do | |||
if slot.startingItem and slot.startingItem ~= "" then | |||
startingItem = slot.startingItem | |||
break | |||
end | |||
end | |||
end | |||
if not startingItem then return "" end | |||
return frame:preprocess('{{СollapsibleMenu|color=#71702a|' .. formatContent(startingItem) .. '}}') | |||
elseif subMode == "stack" then | elseif subMode == "stack" then | ||
local count = getStackCount(id) | local count = getStackCount(id) | ||