The 'Test Story Starting Here' is ignoring my initializing of variables at the start. I have a passage at the very top of my story chart. This passage is tagged as annotation and I am using it to initialize variables which I use later on.
(set: $name to "")
(display: "Begin")
This is in an attempt to ensure I can check if a variable has a value or not at various moments. The second line is simply to display the
actual starting point of the story since some endings link back to the start.
(if: $name is not "")[As a matter of fact...a name just popped into my head...how about $name?]
The above code is what I used to check if the $name variable already had a value (from a previous try). It works quite well when I use the normal 'Test' or 'Play' options, but if I wish to play from that specific location it seems to give the $name variable a garbage value of
'o' and thus messes up my code above. It also seems to ignore the initializing passage. It's not a very big deal since all that matters is the end-result but it can potentially cause confusion. Is there a way to deal with this?
Thanks for reading, and I hope I posted this in the right place.
Comments
You should be using Harlowe's built in special startup tag feature to initialize your variables. That way your variables will always be initialize no matter which method you use to start your story. (Test, Play, Test story starting here, or Publish to File)
Because you already have an existing Passage where you are initializing your variables, you only need to do three things:
1. Remove the annotation tag and replace it with a startup tag.
2. Remove the (display: "Begin") from that passage's contents.
3. Set the Begin passage as your story's Starting Point.
After you have done the above the Test, Play, and Publish to File options should show the Begin passage and your variables should be initialized. Your variables will also be initialized if you use the Test story starting here option on another passage.
Now that you mention it, I had seen the use of the startup tag somewhere on the internet but I was unable to find it again. The wiki didn't have it listed either (it needs an update maybe).
Thanks again for the quick solution. This helps a ton!
The Twine wiki mostly covers using the application itself, not the story formats that come with it.