It looks like you're new here. If you want to get involved, click one of these buttons!
(link: "Main menu")[(goto: "main menu")] <div id="stats">[Save]<save| | [Restore]<restore| (click: ?save)[It's saved(savegame: "A","Test Save")] (click: ?restore)[It is being restored(loadgame: "A")] </div>
Comments
Add the following to your Story Javascript area: ... it adds a Javascript function named customScripts.updateNamedHook which you can use to update a named hook with the value entered into either a text input or text box (textarea) field.
Replace your example from above with the following: The above works by doing the following:
a. The Update Note button stores the current contents of the savenote textarea into the savenote named hook.
b. The (live:) macro stores the contents of the savenote named hook into the $savenote variable. Which will be saved along with all the other story variables which you use the (savegame:) macro.
warning: The timer event created by the (live:) macro is firing every 0.5 of a second, and this can cause a delay in the way the story handles things like the player clicking on a link.
note: The customScripts.updateNamedHook function can handle both textarea and text input fields, so if you decide you want a text input field instead do the following:
"The game's variables contain a complex data structure; the game can no longer be saved."
Additionally, I'd like all notes to be printed in a running list of all notes in a single passage.
In my tests, even when putting the text box in each passage individually the note isn't saved anywhere.
I also forgot that Harlowe only saves the value that a variable had at the time the passage was displayed, so the value of any dynamically changed variable like $savenote will not be included in a save created via a link on the same passage.
So the problem consists of two parts:
1. You want a journal that the Reader can add entries to:
Add the following to a passage, it allows journal entries to be added to a $journal array, it also shows the array. ... the above requires the following code to initialise the $journal variable, you place it within your startup tagged passage. If you don't have one then create a new passage, name it something like Startup and assign the new passage a startup tag.
2. You need to call the (savegame:) macro after changing to a different passage.
Thanks for following up! I'll test it out now.
Here is what I have just testing it out.
(the bottom links and saves were to see if that would help but it didn't)
What exactly do you mean when you save "I can't seem to make the additions stay in the passage." ??
Is there a way to recall them or are they simply gone?
Also, now I can't seem to add any additions at all, I get an error
Attached is a screenshot of the error.
The error message is indicating that the system can not find the customScripts related code, that is the Javascript code I included in my first comment under the Add the following to your Story Javascript area: title. Check your Story Javascript area to make sure the code is still there and if it is not then re-add it again.
If you are unsure where the Story Javascript area is then click on the blue upward pointing triangle in the bottom left corner of the Story Passage Map (blue screen with grid) and select the Edit Story Javascript option.
I moved the (set $journal to (array:)) to the startup passage (and it was there to begin with - I just didn't understand what that code was actually doing, thanks for explaining that.)
The entries stay put now, however I'm now getting this error again:
If you only get the error after adding journal entries, then:
a. do you get the error after adding one entry, two entries, etc?
b. what type of text are you adding in the journal entries?
eg. Are you adding only letters and number, are you adding other types of characters, are you cut-n-pasting text from other software like MS Word, etc...
I have tested the code and Harlowe had no problems saving the journal array, with or without entries.
"Testing" and then "again"
It's printed out kinda funny too:
"Testing,again" But from what I gather thats a normal thing with arrays?
So if that's the case, that it doesn't work with more than one entry, how do I fix that?
Replace the code in your Story Javascript area with the following:
I have tested a story HTML created from attached Archive file in both Firefox and Chrome and did not have the error you are getting although I do get an error when restoring a save in Internet Explorer and Edge but that happens with all Harlowe based story HTML files I create.
You can use Twine 2's Import From File option to import the Archive and run the tests yourself.
I had it something like this:
I changed it to:
The latter holds the same effect and resolves the complex variable error I was getting.
Thanks for your help, Greyelf!
The Harlowe overview states:
Thanks again.
Is there anything else I should be adding to the javascript?
This is what I have in it right now, as you mentioned I should have for the publish feature to work:
So any variables you dynamically changed (like $journal) since the passage was displayed will be reverted back to their original value at the time the saved passage was displayed when you do a restore. For the dynamically changed values to be saved you need to first move to a different passage (which can be the same passage) before calling (savegame:)
I took the option to save out of the journal passage and now it's working, like you said.
Interesting quirk of the (savegame:) macro.