1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-08 06:59:55 +00:00

gametime available in formulas

This commit is contained in:
Zeno Rogue 2024-05-28 15:09:18 +02:00
parent 99bc842c57
commit 727ae8a260
3 changed files with 7 additions and 1 deletions

View File

@ -26,6 +26,10 @@ EX int getgametime() {
return (int) (savetime + (timerstopped ? 0 : (time(NULL) - timerstart))); return (int) (savetime + (timerstopped ? 0 : (time(NULL) - timerstart)));
} }
EX ld getgametime_precise() {
return savetime + (timerstopped ? 0 : (ticks - tickstart) / 1000.);
}
EX string getgametime_s(int timespent IS(getgametime())) { EX string getgametime_s(int timespent IS(getgametime())) {
return hr::format("%d:%02d", timespent/60, timespent % 60); return hr::format("%d:%02d", timespent/60, timespent % 60);
} }

View File

@ -54,7 +54,7 @@ EX int truelotus;
EX int asteroids_generated, asteroid_orbs_generated; EX int asteroids_generated, asteroid_orbs_generated;
EX time_t timerstart, savetime; EX time_t timerstart, savetime, tickstart;
EX bool timerstopped; EX bool timerstopped;
EX int savecount; EX int savecount;
EX int save_turns; EX int save_turns;
@ -378,6 +378,7 @@ EX void initgame() {
if(!safety) { if(!safety) {
usedSafety = false; usedSafety = false;
timerstart = time(NULL); turncount = 0; rosewave = 0; rosephase = 0; timerstart = time(NULL); turncount = 0; rosewave = 0; rosephase = 0;
tickstart = ticks;
noiseuntil = 0; noiseuntil = 0;
sagephase = 0; hardcoreAt = 0; sagephase = 0; hardcoreAt = 0;
timerstopped = false; timerstopped = false;

View File

@ -393,6 +393,7 @@ cld exp_parser::parse(int prio) {
else if(number == "mousey") res = mousey; else if(number == "mousey") res = mousey;
else if(number == "turncount") res = turncount; else if(number == "turncount") res = turncount;
else if(number == "framecount") res = frameid; else if(number == "framecount") res = frameid;
else if(number == "gametime") res = getgametime_precise();
else if(number == "last_a") res = anims::last_anim_vars[0]; else if(number == "last_a") res = anims::last_anim_vars[0];
else if(number == "last_b") res = anims::last_anim_vars[1]; else if(number == "last_b") res = anims::last_anim_vars[1];
else if(number == "last_c") res = anims::last_anim_vars[2]; else if(number == "last_c") res = anims::last_anim_vars[2];