Änderungen

Zur Navigation springen Zur Suche springen
1.032 Bytes hinzugefügt ,  18:19, 27. Feb. 2023
create
local p = {}

--ceh = calculate edibility (energy/health)
function p.ce(frame)
local item = string.lower(frame.args.im)
local edibility = tonumber(frame.args.ed)
local quality = tonumber(frame.args.q)
local ulang = string.upper(frame.args.ll)
local result, formattedresult, temp, length

if edibility == 0 then return 0 end

if item == "energy" then
result = math.floor(math.ceil(edibility*2.5) + edibility*quality)
else
result = math.floor(math.floor(math.ceil(edibility*2.5) + edibility*quality)*0.45)
end

formattedresult = mw.language.getContentLanguage():formatNum(result)

if ((result < 1000) or (ulang ~= "ES")) then return formattedresult end

--replace space with dot
--Problem: ES doesn't add a space for 4 digits, only for 5+

if (result < 10000) then
length = #(tostring(result))
temp = string.sub(tostring(result), -3)
return string.sub(tostring(result), 1, (length-3)) .. "." .. temp
else
temp = {mw.ustring.gsub(tostring(formattedresult), "%s" , ".")}
return temp[1]
end
end

return p
106.467

Bearbeitungen

Navigationsmenü