Howdy, Stranger!

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

Keeping past links active without rewinding in Jonah

edited March 2015 in Help! with 1.x
Hello! I am currently starting work on a story using Jonah in 1.4.2, and I'm trying to figure out if there's a simple way to have a link in a previous passage open a new passage below the current one, instead of rewinding and replacing the current passage. For example, if there are two links to click on and I want the user to be able to (or have to?) click on both before moving on to the following passage:
:: Start
Today is the day... time for the big [[trial]].


:: trial
Your [[client]] is accused of killing the [[victim]]. Of course, you are going to defend her from the charge.


:: victim
Strangled in his office - quite a gruesome affair.

<<if visited("client")>><<display continue to crowd>><<endif>>


:: client
Quiet, but fidgeting. She keeps her gaze down, glancing up and around quickly, often looking to you for reassurance.

<<if visited("victim")>><<display continue to crowd>><<endif>>


:: continue to crowd
You hear the [[crowd]] shuffling in.


:: crowd
You place a hand on your client's shoulder to reassure her everything's going to be fine.
In this case, I would like the player to be able to click on "client" first and then "victim" in the previous passage, or vice-versa, and get the continue passage in whichever is displayed second. As it currently works, if you click "client" then "victim", the client passage is erased and the victim passage is displayed without a link, because visited("client") is false.

Obviously I could just use the <<if visited>> to display a link back to the unread passage first, or the <<actions>> macro, but I'm hoping there's a more elegant way to give players this kind of multiple-choice exploration using the links already created in Jonah.

Relatedly, is there a way to advance to the next passage automatically besides <<display>>ing it? For example, in this case, to just advance to the final passage when both of the choices have been visited. By advancing to a new passage, I can take advantage of the nice css transitions Jonah provides, rather than having it appear all at once with <<display>> (or without transitions, if I were to use <<timedinsert>> or <<timedcontinue>>).

Comments

  • So, after much javascript wrangling and source-diving I figured out how to accomplish both tasks using the state.display() function. You can see below, "persistentlink" and "displayPersistentLink" are used to create a link that stays active until it's clicked (preferably while "undo" is off in the story settings), and "autolink" allows a delayed passage-follow in milliseconds.

    Ideally, I would prefer if the story view showed passages linked this way, but I suspect if that is possible, it would require me to reverse-engineering the python source, which is more than the convenience is worth.
    :: Start
    Today is the day... time for the big [[trial]].


    :: trial
    Your <<persistentlink "client" "client">> is accused of killing the <<persistentlink "victim" "victim">>. Of course, you are going to defend her from the charge.


    :: persistentlink
    <<print '<a onclick="displayPersistentLink(this,' + "'" + parameter(1) + "'" + ')">' + parameter(0) + '</a>'>>


    :: autolink
    <<set setTimeout(function(t){state.display(t)}, parameter(1),parameter(0))>>


    :: alert
    <<set alert()>>


    :: victim
    Strangled in his office - quite a gruesome affair.<<if visited("client")>>

    <<display "continuetocrowd">><<endif>>


    :: client
    Quiet, but fidgeting. She keeps her gaze down, glancing up and around quickly, often looking to you for reassurance.<<if visited("victim")>>

    <<display continuetocrowd>><<endif>>


    :: continuetocrowd
    You hear the crowd shuffling in.

    <<autolink 'crowd' 1000>>


    :: crowd
    You place a hand on your client's shoulder to reassure her everything's going to be fine.


    :: displayPersistentLink [script]
    displayPersistentLink = function(el,title) {
    state.display(title);

    var i, p, D;
    D = insertElement(null, "span", null, "disabled");
    D.innerHTML = el.innerHTML;
    p = el.parentNode;
    p.insertBefore(D, el.nextSibling);
    p.removeChild(el);
    }
Sign In or Register to comment.