Moving with the arrow keys

Jay had a version of this posted, but this one seems to run more smoothly on my machine.

This also includes a lazy version of mrangel's JS room description script.

http://textadventures.co.uk/games/view/tqzlizkiqeyhcnhtbdbk1w/move-with-arrows


<!--Saved by Quest 5.7.6404.15496-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="Move with Arrows">
    <gameid>c58c2002-f4f5-46cd-bc00-5154f654e125</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>
    <start type="script"><![CDATA[
      js = Replace(js.description, "<br/>", "")
      JS.eval (js)
    ]]></start>
    <commandpane />
    <feature_advancedscripts />
    <inituserinterface type="script">
      JS.setCommands ("GET ALL")
    </inituserinterface>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
    <exit alias="north" to="another room">
      <inherit name="northdirection" />
    </exit>
    <exit alias="west" to="western wing">
      <inherit name="westdirection" />
    </exit>
    <exit alias="east" to="eastern wing">
      <inherit name="eastdirection" />
    </exit>
  </object>
  <object name="js">
    <inherit name="editor_room" />
    <description><![CDATA[$("input").bind("keyup",function(e){<br/>    var value = (e.keyCode);<br/>    if(value === 38){<br/>        addTextAndScroll('>n<br>');ASLEvent('HandleSingleCommand', 'n');<br/>    }<br/>    else if(value ===  40){<br/>        addTextAndScroll('>s<br>');ASLEvent('HandleSingleCommand', 's');<br/>    }<br/>    else if(value === 37){<br/>        addTextAndScroll('>w<br>');ASLEvent('HandleSingleCommand', 'w');<br/>    }<br/>    else if (value === 39){<br/>        addTextAndScroll('>e<br>');ASLEvent('HandleSingleCommand', 'e');<br/>    }<br/>});]]></description>
  </object>
  <object name="another room">
    <inherit name="editor_room" />
    <exit alias="south" to="room">
      <inherit name="southdirection" />
    </exit>
    <object name="widget">
      <inherit name="editor_object" />
      <look>An ordinary widget.</look>
      <take />
      <feature_usegive />
      <use type="script">
        i = ListCount(AllCommands())
        foreach (cmd, AllCommands()) {
          i = i - 1
          msg (i)
        }
      </use>
    </object>
  </object>
  <object name="western wing">
    <inherit name="editor_room" />
    <exit alias="east" to="room">
      <inherit name="eastdirection" />
    </exit>
    <object name="puzzle">
      <inherit name="editor_object" />
      <solve type="script"><![CDATA[
        msg ("<center><h1>YOU WIN!  YOU SOLVED THE PUZZLE!!!</h1></center>")
        finish
      ]]></solve>
    </object>
  </object>
  <object name="eastern wing">
    <inherit name="editor_room" />
    <exit alias="west" to="room">
      <inherit name="westdirection" />
    </exit>
    <object name="tegdiw">
      <inherit name="editor_object" />
      <feature_usegive />
      <use type="script">
        i = 0
        foreach (cmd, AllCommands()) {
          msg (i)
          i = i + 1
        }
      </use>
      <take />
      <look>A backwards widget.</look>
    </object>
  </object>
  <verb>
    <property>solve</property>
    <pattern>solve</pattern>
    <defaultexpression>"You can't solve " + object.article + "."</defaultexpression>
  </verb>
</asl>

Nice, it just needs to clear the text box...


Ah!

document.getElementById('txtCommand').value = '';


That does strange things...

I admit it: During testing I was just using arrow keys and hyperlinks.

I'm on it now, though.

Good catch, DL!


That is why every game needs play testers... Because there is always that one ^%#[email protected]@#[email protected] that will do something "wrong"!!!
Normally I just click the links too, but this time tried the "typing on the keyboard" thing...


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums