Maris Posted July 5, 2020 Share Posted July 5, 2020 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) tm:setTimeOfDay(current) end Events.OnCreatePlayer.Add(function() makeRealTime() end) 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? Link to comment Share on other sites More sharing options...
Maris Posted July 5, 2020 Author Share Posted July 5, 2020 Nevermind. I've got it. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now