Модуль:Prototypes/Хранилище/Предмет: различия между версиями

мНет описания правки
мНет описания правки
Строка 28: Строка 28:
     if content.prob then
     if content.prob then
         local percentage = content.prob * 100
         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))
         if percentage >= 1 then
        prob = string.format(" <div>%." .. precision .. "f%%</div>", percentage)
            prob = string.format(" <div>%d%%</div>", math.floor(percentage))
        else
            local precision = 0
            if percentage >= 0.1 then
                precision = 2
            elseif percentage >= 0.01 then
                precision = 3
            else
                precision = 4
            end
            prob = string.format(" <div>%." .. precision .. "f%%</div>", percentage)
        end
     end
     end