Wait Issue with Game Panes

I've had problems with the use of 'wait' before but usually in complex situations. Here is a simple case that may help detect an underlying problem. Failing that, can anyone suggest a workaround?

The code is so simple I've given it completely below. In essence, there is an item in a room which when looked at executes:

msg ("Blah!")
wait {
  msg ("Blah!")

To trigger the problem select 'look at' for the item in the game pane, and then hit the space bar or return when 'continue' appears. The error message is "Error running script: Only one wait can be in progress at a time." Clicking on 'continue' is okay, as is accessing the item in the main window or typing commands?

<!--Saved by Quest 5.8.6809.15141-->
<asl version="580">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="Wait Problem">
  <object name="room">
    <inherit name="editor_room" />
    <isroom />
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    <object name="item">
      <inherit name="editor_object" />
      <look type="script">
        msg ("Blah!")
        wait {
          msg ("Blah!")

I assume that after you clicked the pane command button, it still has focus, so further keypresses trigger it again rather than cascading normally.

One possible solution:

function paneButtonClick(target, button) {
    if (_waitMode) return false;
    var selectedListItem = $(target + " .ui-selected");
    var selectedObject = selectedListItem.text();
    var selectedElementId = selectedListItem.data("elementid");
    var selectedElementName = selectedListItem.data("elementname");
    var verb = button.data("verb");
    var metadata = new Object();
    metadata[selectedElementName] = selectedElementId;
    var metadataString = JSON.stringify(metadata);

    if (selectedObject.length > 0) {
        var cmd = verb.toLowerCase() + " " + selectedElementName;
        sendCommand(cmd, metadataString);

(though this may confuse the player, as they press a key and nothing happens)

Or you could make sure that the focus is in a sensible place by changing:

function beginWait() {
    _waitMode = true;

(3 functions copied from playercore.js; my changes to them highlighted in each case. Top of my head, not tested, usual disclaimer)

Many thanks mrangel, but after posting I tried using the fix provided previously for a nested wait problem (https://textadventures.co.uk/forum/quest/topic/fi7rs8pxxkmfgb6z2xk5eg/unexpected-error-messages-with-nested-wait) , and that seems to solve the problem as well!

The code provided by K.V. at the end of that discussion (as an insert to initusinterface) was:

// Apply WAIT fix
JS.eval("$(window).on('keydown',function(e){     if(_waitMode){     	endWait();     	e.preventDefault();     	e.stopPropagation();     } });  $('#divOutuput').on('click',function(e){     if(_waitMode){     	endWait();     	e.preventDefault();     	e.stopPropagation();     } });")

I think I'll just put this code into all games I work on!! Sorry for not thinking of this earlier.

Log in to post a reply.