View source for How to make a clock - EDukeWiki

# View source for How to make a clock

← How to make a clock

You do not have permission to edit this page, for the following reasons:

- The action you have requested is limited to users in the group: Users.
- You must confirm your email address before editing pages. Please set and validate your email address through your user preferences.

You can view and copy the source of this page.

In this tutorial we will create an in-game clock that displays the users current desktop time in the top right hand corner of the screen. We will need the following [[gamevar]] definitions: <pre> gamevar sec 0 1 gamevar min 0 1 gamevar hour 0 1 gamevar mday 0 1 gamevar mon 0 1 gamevar year 0 1 gamevar wday 0 1 gamevar yday 0 1 </pre> Next, the code itself which must be used in an event because [[digitalnumberz]] and [[rotatesprite]] only work during display events. We will be using [[EVENT_DISPLAYREST]] in this case. <pre> onevent EVENT_DISPLAYREST gettimedate sec min hour mday mon year wday yday ifvarl hour 20 ifvarg hour 9 { digitalnumberz 2992 285 16 hour 0 0 0 0 0 xdim ydim 65536 } ifvarg hour 19 { digitalnumberz 2992 282 16 hour 0 0 0 0 0 xdim ydim 65536 } ifvarl hour 10 { digitalnumberz 2992 288 16 hour 0 0 0 0 0 xdim ydim 65536 rotatesprite 269 16 65536 0 2992 0 0 0 0 0 xdim ydim } ifvarg min 9 { digitalnumberz 2992 308 16 min 0 0 0 0 0 xdim ydim 65536 } ifvarl min 10 { digitalnumberz 2992 315 16 min 0 0 0 0 0 xdim ydim 65536 rotatesprite 296 16 65536 0 2992 0 0 0 0 0 xdim ydim } endevent </pre> The uses for this code are just about endless, it could be used to make certain events trigger at a certain time during the day. For example, if we add the following code to our example it will display a special message for the end user exactly at midnight for one minute. Try it out and see what it is. :) <pre> ifvare hour 0 ifvare min 0 { quote 28 } </pre> It should be noted that the end user can change their in-game clock time by changing their desktop time. [[Category: Tutorials]]

Return to How to make a clock.

Retrieved from "http://wiki.eduke32.com/wiki/How_to_make_a_clock"