Модуль:Prototypes/Хранилище/Предмет: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 24: | Строка 24: | ||
local image = string.format('%s.png', content.id) | local image = string.format('%s.png', content.id) | ||
local amount = content.amount and string.format(" [%d]", content.amount) or "" | local amount = content.amount and string.format(" [%d]", content.amount) or "" | ||
local prob = content.prob and string.format(" <div>%. | local prob = "" | ||
if content.prob then | |||
local percentage = content.prob * 100 | |||
local precision = percentage >= 1 and 1 or (percentage >= 0.1 and 2 or (percentage >= 0.01 and 3 or 4)) | |||
prob = string.format(" <div>%." .. precision .. "f%%</div>", percentage) | |||
end | |||
return string.format('{{LinkСard|SideStyle=1|background-color=#d7d7ff0b|image=%s|name=%s%s%s }}', image, name, amount, prob) | return string.format('{{LinkСard|SideStyle=1|background-color=#d7d7ff0b|image=%s|name=%s%s%s }}', image, name, amount, prob) | ||
end | end | ||