Difference between revisions of "Talk:love.timer"
(Created page with "Is here some way to get time from 1970 in seconds with milliseconds? Like this: <source lang="lua"> local starting_time = os.time() -- time in seconds function love.timer.get...") |
m (Added missing signature from Darkfrei) |
||
(One intermediate revision by the same user not shown) | |||
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 | ||
+ | <source lang="lua"> | ||
+ | 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 | ||
+ | </source> | ||
+ | --[[User:Andlac028|Andlac028]] ([[User talk:Andlac028|talk]]) 16:41, 25 February 2021 (CET) |
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