Name: | Timer |
Author: | imamelia |
Added: | |
Type: | Level |
Includes GFX: | No |
Includes Hijack: | No |
Featured: | No |
Description: | This code will create a timer on the status bar that ticks up or down depending on its settings. You can also set "effects" that happen when the time drops to 0, such as teleporting or killing the player. Credit to Iceguy for the idea, even though I didn't use his code. |
Tags: | clock effect lorom sa-1 status bar stopwatch timer |
Comments: | 5 (jump to comments) |
Rating: |
Download
3.33 KiB | 530 downloads
Comments (5)
This timer is geared towards simplicity to use, mine, however is geared towards advance use of it that most other users are unlikely to use this (it's less user-friendly because it requires learning how to code).
Mine is mainly based on converting a single number, which is the 4-byte (32-bit) frame counter into HH:MM:SS:CC format via a routine (this routine alone merely converts, it does not increment or decrement the frame counter), the input is scratch RAM, so you can have a frame counter stored that is less than 32-bit. The benefit of this is in rare cases you wanted to add a gimmick you can add/subtract time (add 20 seconds, for example), this is much easier to handle a single number than every “time unit” should you exceed the 0-59 range of all units. Once the routine is done, you then need to take the outputs in !Scratchram_Frames2TimeOutput+0 to !Scratchram_Frames2TimeOutput+3, convert the number to decimal (HexDec), and write them to the status bar (I recommend using the colon for all numbers, but before the centisecond, put a period symbol).
2020-09-03 Edit: This tutorial covers on how to make a 32-bit timer (and a proper display).
During the moderation, I fixed a mathematical expression in the level code which made the defines at the top pretty much useless and I added SA-1 compatibility. For future references, Asar does math left-to-right (a leftover quirk form xkas), but the expression relied on proper order of operations (and also inverted only one of the defines when it made sense to invert both). While correct behavior for can be turned on with math pri on, I wouldn't recommend it as it might break code which expects Asar's normal behavior.
BTW, can this work with the UberASM patch?
man I live a sad life