Yes I’m using a RealTimeFuse and a RealTimeDaemon right now (code below including testing verbs to start the countdown and stop it etc). I’ve tried several attempts to flush, restore, update the banner etc., without any results. The only thing which did anything was statuslineBanner.clearWindow(); which, of course, zapped all the content including the left-side status bar text.
Here’s what I tried:
statuslineBanner.showStatusRight();
statuslineBanner.showStatusHtml();
statusRightOutputStream.flushStream();
statuslineBanner.flushBanner();
statuslineBanner.flushWin();
statuslineBanner.updateForRestore();
bannerTracker.restoreDisplayState(true);
Here’s my full code. Should be easy to drop into a vanilla project.
[spoiler][code]#include <adv3.h>
#include <en_us.h>
gameCountdown:InitObject
active = nil
timeRemaining = 0
text = “”
fuse = nil
daemon = nil
create(seconds) {
timeRemaining = seconds;
active = true;
onTimeChanged();
}
remove() {
fuse.removeEvent();
daemon.removeEvent();
active = nil;
}
changeTime(secondsChange) {
timeRemaining += secondsChange;
onTimeChanged();
}
onTimeChanged() {
if (fuse) fuse.removeEvent();
if (daemon) daemon.removeEvent();
fuse = new RealTimeFuse(self, &timeout, timeRemaining * 1000);
daemon = new RealTimeDaemon(self, &tick, 1000);
tick();
}
tick() {
text = 'Time Remaining: ’ + timeRemaining;
statuslineBanner.flushBanner();
timeRemaining -= 1;
}
timeout() {
"YOUR TIME HAS RUN OUT. ";
fuse.removeEvent();
daemon.removeEvent();
active = nil;
}
;
// Show the countdown in the top-right of the status line, if it’s active.
modify statusLine
showStatusRight()
{
if (gameCountdown.active != nil) {
“<span class=“countdown”><<gameCountdown.text>>”;
}
else {
// “”;
}
}
;
// Debug verbs for testing it
DefineIAction(Showtimer)
execAction() { gameCountdown.create(5); }
;
VerbRule(Showtimer) ‘showtimer’ : ShowtimerAction;
DefineIAction(Hidetimer)
execAction() { gameCountdown.remove(); }
;
VerbRule(Hidetimer) ‘hidetimer’ : HidetimerAction;
DefineIAction(Addtime)
execAction() { gameCountdown.changeTime(15); }
;
VerbRule(Addtime) ‘addtime’ : AddtimeAction;[/code][/spoiler]
Regarding a JS timer, tomasb, I agree this would be a much better method indeed. I actually started another thread about how I should go about invoking JS from the game: https://intfiction.org/t/invoking-js-directly-from-webui/4955/1
bcressey chimed in with an extension for doing so but I’ve not managed to get it to work yet, because the script frame he includes gets served by the frob webserver as text/plain instead of text/html, which prevents the browser from doing anything with that. After assembling a vanilla test-case of the same issue I actually filed it as a bug (bugdb.tads.org/view.php?id=187). I’m waiting to see if it qualifies as one, or whether it will be thrown back at me…