Jump to content

Really Real Time?

Recommended Posts

I'm trying to set current real time.

local SEC_TO_HOUR = 1 / (60 * 60)

function makeRealTime()
	local tm = getGameTime()
	local t = os.time() --utc

	local day = tm:getDay() --8
	local month = tm:getMonth() -- 6
	local year = tm:getYear() -- 1993
	local current = tm:getTimeOfDay() --in hours
	local hour = round(current) --9
	local game_t = os.time{year=year, month=month+1, day=day+1, hour=0, min=0} --utc

	local diff = round(t - game_t) --in seconds
	current = current + diff * SEC_TO_HOUR -- OK to increment days (tested)


But it doesn't work:

zombie.ui.UIManager render
SEVERE: null
java.lang.ArrayIndexOutOfBoundsException: 16425
	at zombie.ui.Clock.render(Clock.java:153)
	at zombie.ui.UIManager.render(UIManager.java:431)
	at zombie.gameStates.IngameState.renderFrameUI(IngameState.java:1126)
	at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71)
	at zombie.gameStates.IngameState.renderframeui(IngameState.java:1114)
	at zombie.gameStates.IngameState.renderInternal(IngameState.java:1266)
	at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71)
	at zombie.gameStates.IngameState.render(IngameState.java:1217)
	at zombie.gameStates.GameStateMachine.render(GameStateMachine.java:37)
	at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71)
	at zombie.GameWindow.renderInternal(GameWindow.java:327)
	at zombie.GameWindow.frameStep(GameWindow.java:726)
	at zombie.GameWindow.run_ez(GameWindow.java:640)
	at zombie.GameWindow.mainThread(GameWindow.java:467)
	at java.lang.Thread.run(Thread.java:745)

What am I doing wrong?

Share this post

Link to post
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.

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.


  • Create New...