beenii
Well-Known Member
- Joined
- Jul 26, 2010
- Messages
- 580
- Solutions
- 1
- Reaction score
- 57
hi i want adapted this function:
here on item.cpp:
any have idea?
Code:
function timeString(timeDiff)
local dateFormat = {
{"day", timeDiff / 60 / 60 / 24},
{"hour", timeDiff / 60 / 60 % 24},
{"minut", timeDiff / 60 % 60},
{"second", timeDiff % 60}
}
local out = {}
for k, t in ipairs(dateFormat) do
local v = math.floor(t[2])
if(v > 0) then
table.insert(out, (k < #dateFormat and (#out > 0 and ', ' or '') or ' y ') .. v .. ' ' .. t[1] .. (v ~= 1 and 's' or ''))
end
end
local ret = table.concat(out)
if ret:len() < 16 and ret:find("second") then
local a, b = ret:find(" y ")
ret = ret:sub(b+1)
end
return ret
end
here on item.cpp:
Code:
if(it.showDuration)
{
if(item && item->hasIntegerAttribute("duration"))
{
int32_t duration = item->getDuration() / 1000;
s << " that has energy for ";
if(duration >= 120)
s << duration / 60 << " minutes left";
else if(duration > 60)
s << "1 minute left";
else
s << " less than a minute left";
}
else
s << " that is brand-new";
}
any have idea?