Jump to content

OS.time


Marcousik
 Share

Recommended Posts

os.time works but it requires that lua sandbox be disabled. If you are trying to get a number to use with randomseed() and random(), try using Time:Millisecs() as it doesn't require lua sandbox to be disabled.

On a side note: os.date seems to be more user friendly if anyone is trying to obtain time in hours/minutes/seconds... https://www.lua.org/pil/22.1.html

window = Window:Create("CLOCK",0,0,500,500,Window.Titlebar+Window.Center)
context = Context:Create(window)
world = World:Create()
camera = Camera:Create()
light = DirectionalLight:Create()
light:SetRotation(30,35,0)

box1 = Model:Box()
box1:SetPosition(0,0,1.5)
box1:SetColor(1,0.5,0,1)

while not window:KeyHit(Key.Escape) do
	if window:Closed() then return false end
	
	box1:Turn(0,Time:GetSpeed()*0.5,0)

 	Time:Update()
	world:Update()
	world:Render()
	
	local temp = os.time()
	context:SetBlendMode(Blend.Alpha)
	context:DrawText(os.date("%I:%M:%S"),2,2)
	context:DrawText(temp,2,22)
	context:DrawText(os.date("%X", temp),2,42)
	context:SetBlendMode(Blend.Solid)
	context:Sync(true)
end

 

clock.jpg

  • Like 1
  • Thanks 1

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...