saving issue regarding scripts run in place of text room descriptions

I am having an issue regarding restoring game states online. All my room descriptions are scripts, and I use HTML to play music as well. When a game is saved in a room and then restored, there's nothing but a blank screen with no sound. I'm aware of why this might be, but I am looking for a solution. I tried remedying it by running the ShowRoomDescription function in the initialization script (only on restores, not on new games) via a boolean variable. I also attempted using a variable change script, where a counter in the player object is increased by one in the initialization script, and then the corresponding change script runs ShowRoomDescription.

I thought about trying a turn script that runs ShowRoomDescription and then suppresses turn scripts afterward, but if that doesn't work, I'm not entirely sure what the solution may be. Any ideas? I'm sure others have run into this problem. If you use text descriptions instead of scripts, the issue seems to disappear. When restoring save files on the desktop version, the issue is non-existent; the sound and room description restore without any problems.


Hello.

This test game restores the text when playing online.

https://textadventures.co.uk/games/view/qj_s6-ceq0e5kkge1puztg/restore-text-after-save-online


Here is the same game, without the game.inituserinterface script that applies the fix:

https://textadventures.co.uk/games/view/lqfhxymqieeudkt8ywij7w/will-this-restore-text-after-save-online


The important bits are:

game.inituserinterface

      JS.eval ("function doSave() {ASLEvent(\"BackupDivOutput\", $(\"#divOutput\").html()); UIEvent(\"Save\", $(\"#divOutput\").html());}")
      if (HasAttribute(game, "saveddivoutput")) {
        JS.eval ("setTimeout(function(){$(\"#divOutput\").append(\"" + game.saveddivoutput + "\");}, 500); oldDivOutput = '" + game.saveddivoutput + "';")
      }

  <function name="BackupDivOutput" parameters="s">
    game.saveddivoutput = s
  </function>

The test game's code:

>CLICK HERE to view the code.
<!--Saved by Quest 5.8.7753.35184-->
<asl version="580">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="Restore Text After Save Online">
    <gameid>2aca063f-0a79-43d3-95de-1e3c77f42a37</gameid>
    <version>1.0.3</version>
    <firstpublished>2024</firstpublished>
    <feature_advancedscripts />
    <inituserinterface type="script">
      JS.eval ("function doSave() {ASLEvent(\"BackupDivOutput\", $(\"#divOutput\").html()); UIEvent(\"Save\", $(\"#divOutput\").html());}")
      if (HasAttribute(game, "saveddivoutput")) {
        JS.eval ("setTimeout(function(){$(\"#divOutput\").append(\"" + game.saveddivoutput + "\");}, 500); oldDivOutput = '" + game.saveddivoutput + "';")
      }
    </inituserinterface>
    <author>KV</author>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <isroom />
    <description type="script"><![CDATA[
      msg ("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.<br/><br/>{command:LOOK}")
    ]]></description>
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
  </object>
  <function name="BackupDivOutput" parameters="s">
    game.saveddivoutput = s
  </function>
</asl>

If you use text descriptions instead of scripts, the issue seems to disappear. When restoring save files on the desktop version, the issue is non-existent; the sound and room description restore without any problems.

I was looking at this issue yesterday, and the problem seems to be the displayed text is saved to the game file as a walkthrough when you save the game.

The desktop player loads that old text from the walkthrough when it loads the saved game, but the online player can't run a walkthrough.

I just uploaded a third test game, using a text room description rather than a script, and it still doesn't restore the text when I load a saved game. So, I couldn't recreate what you describe in that bit.


I tried remedying it by running the ShowRoomDescription function in the initialization script (only on restores, not on new games) via a boolean variable.

I bet that didn't work because the page wasn't loaded yet (maybe?).

I had to put a 500ms setTimeout() in the script before it worked for me, and someone has slower internet than me (which would be sad), that might not be long enough.

I don't know, though. Just guessing.


So you did you call ShowRoomDescription in the function InitUserInterface? What happened then?


Log in to post a reply.

Support

Forums