From 847b9e439e006ce0e4134a5e20ccec4bf31f263a Mon Sep 17 00:00:00 2001 From: Kiritow <1362050620@qq.com> Date: Fri, 9 Nov 2018 23:38:21 +0800 Subject: [PATCH] Better output --- teleport_calc.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/teleport_calc.lua b/teleport_calc.lua index acdca73..5bf3211 100644 --- a/teleport_calc.lua +++ b/teleport_calc.lua @@ -1,7 +1,17 @@ -- Teleport Calculator +local function getEUStr(eu) + if(eu<1000) then + return '' .. math.ceil(eu) + elseif(eu<1000*1000) then + return '' .. math.ceil(eu/1000) .. 'K,' .. getEUStr(eu%1000) + else + return '' .. math.ceil(eu/1000000) .. 'M,' .. getEUStr(eu%1000000) + end +end + 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)) + print("Teleport Steve with " .. item .. " items to " .. dis .. "m away needs " .. getEUStr(ret) .. " EU") return ret end