Línea 1: |
Línea 1: |
| local p = {} | | local p = {} |
| | | |
− | --ceh = calculate energy or health | + | --ceh = calculate edibility (energy/health) |
− | function p.ceh(frame) | + | function p.ce(frame) |
| local item = string.lower(frame.args.im) | | local item = string.lower(frame.args.im) |
| local edibility = tonumber(frame.args.ed) | | local edibility = tonumber(frame.args.ed) |
Línea 12: |
Línea 12: |
| | | |
| if item == "energy" then | | if item == "energy" then |
− | result = calcenergy(edibility, quality) | + | result = math.floor(math.ceil(edibility*2.5) + edibility*quality) |
| else | | else |
− | result = calchealth(edibility, quality) | + | result = math.floor(math.floor(math.ceil(edibility*2.5) + edibility*quality)*0.45) |
| end | | end |
| + | |
| formattedresult = mw.language.getContentLanguage():formatNum(result) | | formattedresult = mw.language.getContentLanguage():formatNum(result) |
| | | |
Línea 26: |
Línea 27: |
| length = #(tostring(result)) | | length = #(tostring(result)) |
| temp = string.sub(tostring(result), -3) | | temp = string.sub(tostring(result), -3) |
− | return string.sub(temp, 1, (length-3)) .. "." .. temp | + | return string.sub(tostring(result), 1, (length-3)) .. "." .. temp |
| else | | else |
| temp = {mw.ustring.gsub(tostring(formattedresult), "%s" , ".")} | | temp = {mw.ustring.gsub(tostring(formattedresult), "%s" , ".")} |
| return temp[1] | | return temp[1] |
| end | | end |
− | end
| |
− |
| |
− | function calcenergy(edib, qualmult)
| |
− | return math.floor(math.ceil(edib*2.5) + (edib*qualmult))
| |
− | end
| |
− |
| |
− | function calchealth(edib, qualmult)
| |
− | return math.floor(math.floor(math.ceil(edib*2.5) + (edib*qualmult))*0.45)
| |
| end | | end |
| | | |
| return p | | return p |