Difference between revisions of "Talk:love.timer"

m
m (Added missing signature from Darkfrei)
 
Line 12: Line 12:
 
end
 
end
 
</source>
 
</source>
 
+
--[[User:Darkfrei|Darkfrei]] ([[User talk:Darkfrei|talk]]) 16:32, 24 February 2021 (CET) ‎
 
[http://w3.impa.br/~diego/software/luasocket/socket.html#gettime socket.gettime()] return time in seconds relative to origin of the universe (1 Jan 1970) with microseconds precision
 
[http://w3.impa.br/~diego/software/luasocket/socket.html#gettime socket.gettime()] return time in seconds relative to origin of the universe (1 Jan 1970) with microseconds precision
 
<source lang="lua">
 
<source lang="lua">

Latest revision as of 15:44, 25 February 2021

Is here some way to get time from 1970 in seconds with milliseconds? Like this:

local starting_time = os.time() -- time in seconds

function love.timer.getTime()
	return starting_time + os.clock () -- time in seconds and time from game start
end

function love.draw()
	love.graphics.print(love.timer.getTime(), 32,32)
end

--Darkfrei (talk) 16:32, 24 February 2021 (CET) ‎ socket.gettime() return time in seconds relative to origin of the universe (1 Jan 1970) with microseconds precision

socket = require 'socket'

function love.draw()
	love.graphics.print(('%.4f seconds passed since origin of the universe (1 Jan 1970)'):format(socket.gettime()), 32, 32)
	-- Prints something like: 1614267059.6269 seconds passed since origin of the universe (1 Jan 1970)
	-- string.format is used to fix number of digits after decimal point
end

--Andlac028 (talk) 16:41, 25 February 2021 (CET)