Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Counting turns() in Jonah?

I tried to bring over some turns() code from Sugarcane to Jonah, but I can't get it to work properly.

The home passage has a number of options the reader can click; after they've clicked enough of them (say, three of the five), it unlocks an additional set of options. After three of those five, an additional set and so on... I want to track the number of clicks, not necessarily an if visited() from a certain passage, because it doesn't matter in what order they read them.

So in Sugarcane, I had this -- all the sets are displayed passages.
<<setone>>

<<if turns() gt 6>><<settwo>><<endif>>

<<if turns() gt 15>><<setthree>><<endif>>

But Jonah doesn't seem to recognize the clicks as turns... Suggestions? Alternate macros to use?

Comments

  • edited July 2015
    You could use <<set>> to add +1 to a $variable each time a link is visited, and when it gets to 3, open up the new options.
  • edited July 2015
    @Claretta

    Hmm... As clever as the concept is, it doesn't seem to be working either. The home passage isn't updating/recognizing the change in variable. It seems like the home passage would need to be refreshed somehow in order to recognize that +1 has been added. I imagine that's also the cause of the turns() not working.
  • @litrouke
    When you say "home passage" I am assuming you mean the Start passage that is displayed at the start of the page.

    Basically what happens each time you click on a link that appends the contents of a new passage to the bottom of the page (now the Present), is that the passage that was previously at the bottom (now the Past) is added to the story's History system.

    When a passage is added to the History system a snap-shot of all the known $variables values is made and this snap-shot is also store with the passage, this is done so that if History is wound backward then the $variables can also be returned to the same values they were at the time.

    When you click on a link within one of the previous (the Past) passages, history is wound back so that passage becomes the Present again, so the related $variables are also returned to their previous values.
    The following five passage example show this happening, if you first travel to Passage 4 via the Passage 1, Passage 2, Passage 3 (within Passage 2) links you will see var: 3, if you then click on the Passage 3 within the Start passage you will see var: 1
    :: StoryInit
    <<set $var to 1>>
    
    :: Start
    [[Passage 1]]
    [[Passage 3]]
    
    :: Passage 1
    Passage 1 text
    <<set $var to $var + 1>>
    [[Passage 2]]
    
    :: Passage 2
    Passage 2 text
    <<set $var to $var + 1>>
    [[Passage 3]]
    
    :: Passage 3
    Passage 3 text
    var: <<print $var>>
    

    This is why @Claretta suggestion is not working for you and maybe also why turns() does not work because it may also be getting wound back.
  • @greyelf

    I don't quite mean the Start passage -- I'm using a hub system that another Twiner developed; it allows you to create additional home/hub passages that clear out all the old passages and start a fresh chain. But yes, it's pretty much the same idea.

    So, the long and short of it seems to be that this idea won't work well in Jonah... On to another format! I've been working on a back-up strategy in case this was indeed the conclusion. Still, thanks for the clarification!
Sign In or Register to comment.