Problem with wait

Hi guys.

I have problem with a fairly long room description.
It is so long that the top will scroll off the screen.
This is not something the player will be used to seeing as most of my room descriptions are fairly short.
So I want to make sure that they don't miss the info on the first couple of lines.

So I was thinking.
Hey I just stick a "wait" script in somewhere appropriate during the explanation.
Then the player would see the first part of the text, hit a key and then see the rest.
Nice.

Unfortunately it does not really work like that.
When I reach the point of the "wait" statement in the script the exitlist and objectlist is printed, and only then does the printing stop.

So when coding
msg (aaa, aaa, aaa, aaa)
wait (msg (bbb,bbb,bbb)
(Sorry for the syntax, but you get the idea :-))

I had hoped the output would look like this:
aaa
aaa
aaa
aaa
"Continue"
bbb
bbb
bbb
"You see something"
"You can go north"

But instead it is like this:
aaa
aaa
aaa
aaa
"you see something"
"You can go north"
"continue"
bbb
bbb
bbb

Which is not very nice :-(

Any Ideas?


A really messy way to do it off the top of my head:

msg ("aaa aaa aaa aaa")
wait {
  JS.queueJump()
  msg ("bbb bbb bbb bbb")
  JS.resumeAddText()
}
JS.eval ("(function () { if (!window.suppressAddText) { var real_addText = addText; var textBuffer = []; window.addText = function (t) { textBuffer.push(t); }; window.suppressAddText = 1; window.queueJump = function() {window.addText = real_addText; delete window.suppressAddText; }; window.resumeAddText = function () { delete window.suppressAddText; window.addText = real_addText; $.each( textBuffer, function (i, t) { addText(t); }); }}})();")
  • The huge JS.eval line will stop all output from appearing on the screen. It comes after wait to ensure the "Continue..." link appears (I'm not sure if it would work otherwise). Any text printed after this point is put in a queue, to appear later.
  • Calling JS.resumeAddText() causes all the text in the queue to appear onscreen, and future text to appear normally
  • Calling JS.queueJump() means that any text in the queue stays there, but any new msg()s work normally.

(sorry if there's any typos in there, doing this off the top of my head when I should be working)

(If you're using the desktop version, you can probably put a neater version of the code in a javascript file, so you don't have to include the eval line every time)


I'd just put the script on the room's beforeenter script.

<!--Saved by Quest 5.8.6719.26266-->
<asl version="580">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="msg wait msg">
    <gameid>fd9dca70-aa97-4fe9-b8c5-58c5dc0fa701</gameid>
    <version>1.0</version>
    <firstpublished>2018</firstpublished>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <isroom />
    <beforeenter type="script">
      msg ("Before.")
      wait {
        msg ("After.")
      }
    </beforeenter>
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
  </object>
</asl>


Alternatively, you could use the old version of scrollToEnd(), which does not scroll past the text (but may have issues in some browsers):

function scrollToEnd() {
    var scrollTo = _animateScroll ? beginningOfCurrentTurnScrollPosition - 50 - $("#gamePanelSpacer").height() : $(document).height();
    var currentScrollTop = Math.max($("body").scrollTop(), $("html").scrollTop());
    if (scrollTo > currentScrollTop) {
        var maxScrollTop = $(document).height() - $(window).height();
        if (scrollTo > maxScrollTop) scrollTo = maxScrollTop;
        var distance = scrollTo - currentScrollTop;
        var duration = _animateScroll ? distance / 0.4 : 1;
        /* Added by The Pixie on behalf of alexandretorres*/
        if (duration>2000) duration=2000;
        $("body,html").stop().animate({ scrollTop: scrollTo }, duration, "easeInOutCubic");
    }
    $("#txtCommand").focus();
};

Thanks guys.

I am amazed of the level of help I always get in here 🙂

I go with the Before enter script.


I think you can also turn off the 'automatically generate room descriptions' too, but then you got to have your own code that will display the room descriptions, though this does give you control over it, in when it happens and how it looks (formatting), as well.


Log in to post a reply.

Support

Forums