Any Tips for Using localStorage for Transcript Data in the Web Player?

Hello,

I now have Quest saving the transcript to a .txt file in the desktop player, and I am about to begin writing code to have the web player use localStorage to save its transcript data.

Every time addText() is called, that text is converted to plain text and written to the transcript file. I bet it isn't too difficult to have that text save to localStorage in the web player in much the same way.

I'm hoping this won't effect the performance?

(I worry about this because I didn't think to worry about performance while setting saveClearedText to true by default or creating the constantly concatenating transcriptString in Quest 5.8.)


Any comments or suggestions are more than welcome.


I forgot the important part:

Making it so the player can open the web player's transcript and/or have it print from their browser is the part I'm not quite sure how to handle.

I know how to retrieve the data from localStorage, but I have no vision concerning what should be done with that data. (I'm now thinking maybe just create a new document for it and open that in a new tab?)

I'm also wondering if I should add a small button which is only displayed somewhere on the screen when a transcript exists in localStorage.


EDIT

(I'm now thinking maybe just create a new document for it and open that in a new tab?)

I believe I may be "getting this idea" based upon a vague memory of an old idea mrangel once shared, haha.


Should I be creating a new item for a new transcript entry each time it adds a bit of text instead of doing the following?

  var oldData = localStorage.getItem("transcriptData") || "";
  localStorage.setItem("transcriptData", oldData + data);

Or is this way already the best practice when using localStorage?


EDIT

Aha! I also need to make it save a separate item for each specific transcript name, as this code will append every game to one transcript, haha!

I know how to do that.

Now, I'm mainly just worried about using one item per transcript. Should it be one localStorage item per transcript, with no worries about how big that string gets -- and whether that will effect game performance? (I am retrieving that string and adding to it when saving to localStorage every time text is printed. That seems like it's probably not the best practice here.)


Okay...

I've changed things up a little. Now there is a localStorage item for each transcript. I only need to create a list of links to print so the player can click to select which of their transcripts they wish to view.

(I actually think this might work!)


First working version (dirty):

It won't let me post the code here.

OLD CODE REMOVED


I need to:

  • make this into a nice-looking table (or something)

If anyone has any input, I'm checking this post every 5 or 10 minutes. I'm learning as I go at this point! :p


Online Transcript Tester

https://textadventures.co.uk/games/view/3r90vfn9su6mcpprpy4arg/online-transcript-tester-20240915


For online testing only.

The transcript is enabled already when play begins.

In the browser on desktop, you should see the ugly Transcripts button next to the Save button.

On mobile, you have to click the "[+]" button by the text input box, then "More" to see the ugly Transcripts button.

To disable the transcript, enter SCRIPT OFF.

To enable the transcript, enter SCRIPT ON.

Somebody try to break this, please.


Log in to post a reply.

Support

Forums