Indicator

I found a document on how to make an indicator bar. Unfortunately, it is (in span style) not being read correctly by my game engine. The part I put into the script tab is not loading. I can't do anything with it. I don't know if the advanced script is doing anything or not, but it is loading correctly. That's all I know.
How can I make the indicator bar that works as described?
http://docs.textadventures.co.uk/quest/custom_panes.html


I tried it and it might be working, when you enter room1, the player loses 1 hitpoints

Sample code (Customize according to what you need)

To paste the code

  1. Startup your quest gamebook/textadventure, on the right side of the big play button, you can see a code view button </>
  2. Copy my code to replace the code in the text box, click code view button again.
  3. Viola, it is done, press play button to test out the game and modify the code to your preference.
<!--Saved by Quest 5.8.6836.13983-->
<asl version="580">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="test6">
    <gameid>dcc925f3-5b1c-40c8-b8fd-e24434d9e3aa</gameid>
    <version>1.0</version>
    <firstpublished>2024</firstpublished>
    <feature_advancedscripts />
    <inituserinterface type="script"><![CDATA[
      s = "<table width=\"100%\"><tr>"
      s = s + "   <td style=\"text-align:right;\" width=\"50%\">Hit points:</td>"
      s = s + "   <td style=\"text-align:left;\" width=\"50%\"><span id=\"hits-span\">---</span></td>"
      s = s + " </tr>"
      s = s + " <tr>"
      s = s + "   <td colspan=\"2\" style=\"border: thin solid;background:white;text-align:left;\">"
      s = s + "   <span id=\"hits-indicator\" style=\"background-color:black;padding-right:200px;\"></span>"
      s = s + "   </td>"
      s = s + " </tr>"
      s = s + "</table>"
      JS.setCustomStatus (s)
      if (HasScript(player, "changedhitpoints")) {
        do (player, "changedhitpoints")
      }
    ]]></inituserinterface>
    <start type="script"><![CDATA[
      player.changedhitpoints => {
        JS.eval ("$('#hits-span').html('" + game.pov.hitpoints + "/" + game.pov.maxhitpoints + "');")
        JS.eval ("$('#hits-indicator').css('padding-right', '" + (200 * game.pov.hitpoints / game.pov.maxhitpoints) + "px');")
      }
      player.maxhitpoints = 70
      player.hitpoints = 70
    ]]></start>
    <showhealth type="boolean">false</showhealth>
    <customstatuspane />
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <isroom />
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
    <exit alias="south" to="room1">
      <inherit name="southdirection" />
    </exit>
  </object>
  <object name="room1">
    <inherit name="editor_room" />
    <enter type="script">
      player.hitpoints = player.hitpoints-1
    </enter>
    <exit alias="north" to="room">
      <inherit name="northdirection" />
    </exit>
  </object>
</asl>

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

Support

Forums