Skip to content

Commit

Permalink
Added "Battery Timer" support
Browse files Browse the repository at this point in the history
  • Loading branch information
rater193 committed Apr 19, 2018
1 parent 9f35590 commit d9ec04f
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions baseglasses/baseglasses.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,25 @@ function shortText(val)
return ret
end

function convertToDateString(val)
local ret = tostring(val) .. " seconds")
if(val>60) then
val = tostring(math.ceil(val/60)) .. " minutes"
end
if(val>60*60) then
val = tostring(math.ceil(val/(60*60))) .. " hrs"
end
if(val>60*60*24) then
val = tostring(math.ceil(val/(60*60*24))) .. " days"
end
if(val>60*60*24*30) then
val = tostring(math.ceil(val/(60*60*24*30))) .. " months"
end
if(val>60*60*24*30*12) then
val = tostring(math.ceil(val/(60*60*24*30*12))) .. " years"
end
end

--Update thread
thread.create(function()
while true do
Expand All @@ -122,7 +141,7 @@ thread.create(function()
if(generated==0) then

else
print("Time remaining: " .. tostring(math.abs(math.floor(remaining/generated))) .. " seconds")
print("Time remaining: " .. convertToDateString(math.abs(math.floor(remaining/generated)))
end

v.previouslyCheckedEnergy = energyStored
Expand Down Expand Up @@ -168,7 +187,7 @@ thread.create(function()
if(tps>0) then
tps = 20
end

tps = tostring(tps)
tpsText.setText("tps: " .. tostring(tps))
os.sleep(1)
Expand Down

0 comments on commit d9ec04f

Please sign in to comment.