Tinderbox Forum

Storyspace Guard Fields

I’m starting to experiment with Storyspace. My objective is to establish whether it makes a good environment for creating learning materials. I want to experiment with two aspects of that: a “conventional” approach that is essentially based on a set of notes with links between them, organised in a non-linear fashion, and a more ambitious one that adopts a story telling approach to communicating the learning points. I anticipate Guard Fields being an important component of both approaches e.g. to prevent a topic being explored until some prerequisite information has been read and digested. I’m therefore playing with creating Guard Fields, and trying to follow the first exercise in “Getting started with Hypertext narrative”. That asks me to create a set of notes where at least one link is conditional on e.g. another note having been visited or having been visited a particular number of times. My understanding is that I can achieve this by using the $Visits attribute in the Guard Field of a text link to test whether e.g. a particular note has been visited a certain number of times (or at all). If the test fails the link is inactive. I’m clearly getting something wrong because I can’t get this to work. I’m writing $Visits(“Note 2”)>10 in the Guard Field of a text link in another note to prevent that link becoming active unless Note 2 has been visited more than 10 times. But that doesn’t work: the link simply doesn’t show in the text of the appropriate note. I have the $Visits attribute set as a KeyAttribute of the note in question so that I can see its value, which increments each time the note is visited, but I can’t get the Guard Field to work.

I can’t replicate this unless I type the wrong sort of quotes:

Wrong (fails):

$Visits(“Note 2”)>10

Right (works):

$Visits("Note 2")>10

Note the working version uses ‘straight’ quotes.

If still stuck, could you post a small test file so we are testing from the same base?

Also, in testing this I noticed that the v3.9.0b026 Help file has some encoding errors ( strings of ‘???’). I’ve reported this to support.

Meanwhile, definitely look up Howard Oakley’s articles on Storyspace, which are some of the little writing on use of Storyspace for other than non-linear storytelling: ‘non-literary’ use, so to speak. I think some of Howard’s projects align with what you are doing.

Here’s the file I’m trying to make work. I thought I was using straight quotes, and they appear that way on screen, but in any event I pasted in your statement from your very helpful response. “Third note” should have a link from the text “something else going on” that becomes live when $Visits to Third note exceed 3. That still doesn’t seem to happen. And thanks for the reference to Howard Oakley’s work. I had followed it at the time it was published but had forgottenHypertext Ex1.tbx (95.6 KB) about it since.

Sorry, the forum by default auto-changes straight to curly quotes unless you put a back-tick (`) before and after your code. Or, for the coloured examples you see put three back-ticks on a line of their own before and after the code sample.

I assume the “something else going on” is in note “third note”. However, opening that note’s Browse Links:

I think the issue is you created a basic link instead of a text link.

Still my install seems to have crashed and odd stuff is happening so can’t test further: I probably need to re-install. I hope the above helps.

I’ve double checked that I’m creating a text link from Third Note to Fourth Note, and, unless I am being more than usually obtuse, that is what I am doing. When I complete the creation of the link it appears in Map view, with a “no entry” sign attached to it, which seems reasonable. However when I start to coerce Third Note to be visited the requisite number of times the link disappears in Map view, and the Guard Field does not operate. Attached is a screen shot of what I see immediately after creating the link, showing the link with the “no entry” sign. However that disappears once I click on Third Note the first time.
I’m resetting $Visits in Third Note to 0 by having it as a Key Attribute, double clicking on it in the field at the top of the note and setting it to 0. Could that have something to do with it?

I’m not sure I fully understand, so will re-iterate:

  • We want to link from text in the note ‘Third note’ to note ‘Fourth note’.
  • We only want to be able to follow the link when ‘Fourth note’ has a $Visits count of greater than 3.

The guard field code to place in the ‘Guard’ box of the link is:

$Visits("Fourth note")>3

If you test $Visits("Third note")>3 in a note originating in ‘Third note’ that is the same as testing $Visits(this)>3. It may be what you mean to do (albeit a less seen type of test) but i just can’t tell from the the file or your description.

Also, I’m not sure if guard fields are intended for basic (i.e. note to note) links rather that text (text-to-note) links. the reason I say this is how Storyspace works in ‘read’ mode, which is slightly different to Tinderbox. Text fields have blue anchors. For links with guard fields, the link anchors are not coloured (i.e. not implemented) unless the guard condition is met. The symbols of the link indicate the condition status. Another form of guard field is based on a word or phrase in text being clicked; IIRC (without having time to test) these links are not coloured. Rather, the app testes to see if the clicked word is included in link guard field test.

If I understand the Storyspace paradigm correctly, a note would only have one (or zero) basic links. That link is invoked if the reader click return to go to the ‘next’ note as chosen by the author. Ergo, having >1 basic link makes no sense. If there are no basic links the user would click a text link or use the map to select another note.

Apologies for not making myself clear. I’m trying to link Note 3 to Note 4 via a Guard Field in the link I’m creating in Note 3. (There is another link from Note 3 back to Note 1: that is a Text link and ought to be the only link available in Note 3 until the Guard Field test (Note 3 has been visited a minimum number of times) is satisfied and therefore the (Text) link from Note 3 to Note 4 becomes active. As far as I can see all of the links I am making are Text links. I can’t understand why the link from Note 3 to Note 4 appears when I create it, with the “no entry” sign attached, but then disappears next time I click on Note 3. AFAIK I am not creating any basic links.
I appreciate the effort you are making to help solve this. Perhaps if you can make a small test file that works for you, implementing the scheme I have just described, I can see whether that works on my system.

In this scenario, go for a minimal test. To note, one link, so minimum chance of inference by other effect. You can diagnose the latter later, after the core function is correct. So:

Note that at this point, even in edit mode, the anchor is not shown as the guard condition (>3 visits to ‘Fourth note’) has not been satisfied. This condition is also indicated by the unfilled diamond shape on the map link line. Now let’s bump the visits for the target:

Note the link diamond is now filled (condition satisfied) and at source (in both edit and read modes) the link is colored. De-increment target $Visits (by editing its KA):

Here we’re using $Visits for convenience but this could be any relevant attribute and the point is that satisfying the guard condition is not a once-only assessment, but dynamic. So, link availablilty can phase in and out as the target value varies.

† After editing the KA you may need to de-select the current note to allow/force the app to re-draw the map and re-test guard conditions.

Here’s the test doc, reset for the start condition: Storyspace-guard-test.tbx (68.7 KB)

I now have this working in the simplest case, as you suggested, of only two notes. I’ve experimented with changing the Guard condition, both in terms of the number of visits being tested and the note involved (e.g. testing $Visits(“Third note”) and $Visits(“Fourth note”), always in Third note. It’s all working as expected. Many thanks for your help with this, and patience - I can see that you have also been busy responding to points on the Tinderbox forum.

Happy to help, and it’s nice to see Storyspace getting a look-in.