From 0c78018707136583d69cbe2fecf9a0c3f2c75202 Mon Sep 17 00:00:00 2001 From: Kiritow <1362050620@qq.com> Date: Mon, 3 Dec 2018 20:20:19 +0800 Subject: [PATCH] small update --- .gitignore | 2 +- teleport_calc.lua | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index bafe145..c138f01 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ *.exe - +*.dll diff --git a/teleport_calc.lua b/teleport_calc.lua index 2bc5f9a..a31b49e 100644 --- a/teleport_calc.lua +++ b/teleport_calc.lua @@ -1,17 +1,20 @@ -- Teleport Calculator + local function getEUStr(eu) if(eu<1000) then - return string.format( - elseif(eu<1000*1000) then - return '' .. math.ceil(eu/1000) .. 'K,' .. getEUStr(eu%1000) + return string.format("%d EU",eu) + elseif(eu<1000000) then + return string.format("%.2fK EU",eu/1000) else - return '' .. math.ceil(eu/1000000) .. 'M,' .. getEUStr(eu%1000000) + return string.format("%.2fM EU",eu/1000000) end end -function teleport_calc(dis,item) +local function teleport_calc(dis,item) if(item==nil) then item=40 end local ret=(1000+100*item)*math.pow(dis+10,0.7) - print("Teleport Steve with " .. item .. " items to " .. dis .. "m away needs " .. getEUStr(ret) .. " EU") + print("Teleport Steve with " .. item .. " items to " .. dis .. "m away needs " .. getEUStr(ret)) return ret end + +return teleport_calc \ No newline at end of file