@@ -13,13 +13,9 @@ local Description = "Oh no, it's morning again :)"
1313local rect
1414local res
1515local defaultPosition
16- local currentDate
17- local currentTime = ' '
18- local date
1916local AllowMoving
2017local player
2118
22-
2319function Clock .initialize ()
2420 if onClient () then
2521 player = Player ()
@@ -32,19 +28,13 @@ function Clock.initialize()
3228 -- MoveUI - Dirtyredz|David McClain
3329 defaultPosition = vec2 (res .x * 0.7 ,res .y * 0.07 )
3430 rect .position = MoveUI .CheckOverride (player , defaultPosition ,OverridePosition ,Title )
35- Clock .getCurrentDate ()
3631 end
3732end
3833
3934function Clock .buildTab (tabbedWindow )
4035 -- TODO: add alarm settings in here
4136end
4237
43-
44- function Clock .onSectorEntered ()
45- Clock .getCurrentDate () -- sync time with server on sector change
46- end
47-
4838function Clock .onPreRenderHud ()
4939 if OverridePosition then
5040 rect .position = OverridePosition
@@ -59,41 +49,11 @@ function Clock.onPreRenderHud()
5949 drawTextRect (Title , rect , 0 , 0 ,ColorRGB (1 ,1 ,1 ), 10 , 0 , 0 , 0 )
6050 return
6151 end
62-
63- drawTextRect (currentTime , rect ,0 , 0 ,ColorRGB (1 ,1 ,1 ), 15 , 0 , 0 , 0 )
64- end
65-
66- function Clock .getCurrentDate (date )
67- if onClient () then
68- if date then
69- currentDate = date
70- return
71- end
72- invokeServerFunction (' getCurrentDate' )
73- return
74- end
75-
76- local cDate = os.date (" *t" )
77- invokeClientFunction (Player (callingPlayer ),' getCurrentDate' , cDate )
52+ local DateTime = os.date (" *t" )
53+ drawTextRect (DateTime .hour .. " :" .. DateTime .min .. " :" .. DateTime .sec , rect ,0 , 0 ,ColorRGB (1 ,1 ,1 ), 15 , 0 , 0 , 0 )
7854end
7955
8056function Clock .updateClient (timeStep )
81- if currentDate then
82- currentDate .sec = math.floor (currentDate .sec + timeStep )
83- if currentDate .sec >= 60 then
84- currentDate .sec = 0
85- currentDate .min = currentDate .min + 1
86- if currentDate .min >= 60 then
87- currentDate .min = 0
88- currentDate .hours = currentDate .hour + 1
89- -- TODO: add 12/24hr support
90- if currentDate .hour >= 24 then
91- currentDate .hour = 0
92- end
93- end
94- end
95- currentTime = string.format (" %02d:%02d:%02d" , currentDate .hour , currentDate .min , currentDate .sec )
96- end
9757 AllowMoving = MoveUI .AllowedMoving ()
9858end
9959
0 commit comments