Howdy, Stranger!

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

Harlowe click-append macro and variables

Hi,

I'm using Twine as part of a project I'm working on for university but I'm fairly new to Twine 2.0 so I don't know if this is possible in Harlowe or not.

In one of my passages I've got a sentence with the 'click-append' macro linked to one of the words to provide some extra information. Is there a way for Twine to remember that the extra information has been displayed and I can use it as a variable later? i.e if click-append macro is activated $somevariable is set to 'true' and then in a later passage I can call $somevariable to do something.

Any help greatly appreciated. Thanks

Comments

  • You have basically answered your own question. *smile*

    1. Initialise the Boolean variable.

    Ideally this should be done in your story's startup tagged passage, but any time before the (click:) macro link is clicked is OK.
    (set: $somevariable to false)
    

    2. Create the (click:) macro link that appends the information text and updates the Boolean variable.

    note: I'm using the hook version of the (click:) macro because the String version searchers the content of the passage looking for every occurrence of the String.
    I have nothing to [fear]<word|.
    
    (click: ?word)[
    	(append: ?word)[ but my own hand]
    	(set: $somevariable to true)
    ]
    

    3. Do something based on the current value of the Boolean variable.

    Generally this needs to be done in proceeding passages because by default (if:) macros are only processed at the time the passage is displayed.
    ''Checking for true''
    (if: $somevariable)[Descriptive text was appended]
    (else:)[You did not click on the link!]
    
    
    ''Checking for false''
    (if: not $somevariable)[You did not click on the link!]
    (else:)[Descriptive text was appended]
    
  • Thank you!
  • Further question. Could I have multiple versions of the (click: ?word) etc = variable activate running in a single passage? Or can there only be one ?word running at a time?
  • There is nothing special about the name I gave the named hook, I could of named it some else like "I have nothing to [fear]<banana|"

    You can have multiple named hooks within a passage, and you can use the same name for multiple named hooks which will result in all of the same named hooks being effected by the related hook based macros.

    What you cant do is have more that one (click:) (type) macro target the same named hook, if you do then the later defined macro targeting the named hook will over ride the earlier one.
    (set: $somevariableA to false)
    (set: $somevariableB to false)
    
    [Link 1]<teddybear|
    [Link 2]<teddybear|
    [Link 3]<flower|
    
    (click: ?teddybear)[
    	(append: ?teddybear)[ used teddybear as the hook name]
    	(set: $somevariableA to true)
    ]
    
    (click: ?flower)[
    	(append: ?flower)[ used flower as the hook name]
    	(set: $somevariableB to true)
    ]
    
  • Awesome! Thank you!
Sign In or Register to comment.