Howdy, Stranger!

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

Issue setting a variable (beginner question)

edited November 2015 in Help! with 2.0
Hi all, I'm using Harlowe
I have a quiz on one passage. If a user selects the correct choice, they are brought to another passage where the variable $mom is set to true. (It hasn't been initiated anywhere, this is the first appearance of the variable)

Then, on returning to the quiz page, an if statement at the top checks for the value of $mom.

As you can see, the variable is set to true, but then is still displayed as "0" upon return.
Where's my oversight?

Thank you

Comments

  • How are you returning to the quiz page?
    If you are using the Undo button then that is the reason, because it winds back history which undoes changes to variables.

    I suggest you use a startup tagged passage to initialize your variables, which would allow $mom to equal false at the start instead of zero.
  • edited November 2015
    Thanks greyelf. Is the default return arrow (shown in my attachments) the Undo button?
    If so, I should like to have a function to bring the user back to the previous passage without undoing the variable history. Any ideas?
  • Yes, that is the Undo button. If you place your mouse cursor over the 'button' a tooltip will appear.

    The (history:) macro returns a list containing the names of all the passages previously visited by the Reader, the last entry is the previous passage. You can combine it with a (link:) and (goto:) macro like so:
    (link: "return")[(goto: (history:)'s last)]
    
  • edited November 2015
    I see, so I can make a custom return link using that code. However, I probably will be sacrificing the nice UI of the return arrow for some boldened text. Is there a way to keep the intuitive visual of the return arrow without the undo aspect? Perhaps some other Twine style, like snowman or sugarcube, has this feature? Or I could try placing an image on every passage that triggers the history code you've provided..Thanks so much btw! I should probably mark the answer as solved. I'd like to continue receiving your help without closing the thread though. :P
  • Oh it seems to have left it open. Well I'll try that image placement button idea in the meantime. I am a tad curious about the other styles because having that undo button in there could really mess up my code.
  • ... the nice UI of the return arrow for some boldened text. Is there a way to keep the intuitive visual of the return arrow without the undo aspect?
    The clockwise and anti-clockwise symbols use for Harlowe's Undo and Re-do 'button' are just characters, you can use Inspect Element to view the 'button' source and cut-n-paste the character.
    (link: "↶")[(goto: (history:)'s last)]
    
  • Nice it's working, and prolly my last question: is there a way to deactivate the undo button in harlowe?
  • edited November 2015
    EDIT: Holy moly, I found another one of your posts and now the "header" tagged passage runs your <script></script> code for each page! Currently testing if the back fwd arrows can be removed.
    EDIT 2: Ok, I think this is magic. I've removed the undo/redo buttons entirely using your modified code in a header passage.
    <script>$('tw-sidebar tw-icon[title="Undo"]').text("").attr("title", "");</script>
    
    Thank you!

    ORIGINAL:
    I actually may have found the answer in one of your other posts. However it seems to be only changing the tooltips for undo/redo and not the actual button functions so I could try using a variant of this to maybe remove the charaters used to display the undo/redo buttons.
    I couldn't find out what exactly header tagged passage is, so I've placed the following code in my "Story javascript" :
    <script>$('tw-sidebar tw-icon[title="Undo"]').text("Back").attr("title", "Back");</script>
    
    And added the tag "Header" to a passage to see if the button tooltip is changed, it still reads undo and actually I get a story error so I'm overlooking something huge I'm sure.
    The undo and redo 'buttons' don't use icons, they are actually just text characters. You can use Javascript to change both the character and title (tooltip) displayed, the following changes the undo button to be Back.
    $('tw-sidebar tw-icon[title="Undo"]').text("Back").attr("title", "Back");
    Because the undo and redo buttons are (re)created every time a new passage is shown you will also need to issue the above Javascript each time as well. You can do that by first adding a header tagged passage to your story (if you don't already have one) and then using code like the following:
    <script>$('tw-sidebar tw-icon[title="Undo"]').text("Back").attr("title", "Back");</script>
    
    ... the text function is changing the character display while the attr function is being used to change the title (tooltip)
  • is there a way to deactivate the undo button in harlowe?
    If by deactivate you mean hide then you can use CSS to do that, place the following in your Story Stylesheet area:
    tw-sidebar {
    	display: none;
    }
    
  • Awesome greyelf. I found a way to do that which was 10x as cumbersome but it was a learning experience! Cheers.
  • For anyone wanting clarification on this issue, there's another posting here http://twinery.org/forum/discussion/5096/change-undo-to-go-back-in-harlowe#latest
Sign In or Register to comment.