Howdy, Stranger!

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

Some of my (replace: ) commands aren't working and I don't understand why

Hello!
Sorry if this has already been answered, but neither Google nor the forum search feature showed me any relevant posts.

I'm currently experimenting with different conversation systems. My only experience so far has been with a multi-node approach, where there was a node for each meaningful action, but I'm trying to figure out how a single-node system could work since it would be much more compact and convenient.

I'd prefer to have each new set of text and choices replace the last, so I was experimenting with (replace: ). It works perfectly for the first set of choices, but not for the second, and I can't figure out why that is.
For example, choosing to dance with the NPC replaces the talk/ignore/dance options with the new text and choices - tango/slowdance/breakdance. However, choosing to tango does not replace the tango/slowdance/breakdance options, it only adds the tango-related text below it.

I've included the current state of my little experiment below. Does anyone see what I did wrong?
(I'm using Harlowe 2.0.11, if that makes any difference)

I'd really appreciate any help!
[The [single-node NPC]<sNPC| is looking at you expectantly.

(click: ?sNPC)[The NPC seems to be waiting for you to [talk]<sNtalk| to it. You could, however, decide to [ignore]<sNignore| it instead. You could also attempt to [teach it how to dance]<sNdance|.]]<passage1|

{ [(click: ?sNtalk)[(replace: ?passage1)[You start making small talk with the NPC.]]

(click: ?sNignore)[(replace: ?passage1)[You turn away and pretend not to notice the NPC, though you can still see its dejected expression out of the corner of your eye.]]

(click: ?sNdance)[(replace: ?passage1)[You offer to teach the NPC how to dance - it enthusiastically agrees. Do you want to [tango]<tango|, [slow dance]<slowdance| or [breakdance]<breakdance|?]]]<passage2| }

{ (click: ?tango)[(replace: ?passage2)[You dance a passionate tango with the NPC. (set: $mood to "romantic") The NPC is growing fatigued from all this energetic dancing. Will you allow it to [take a break]<break|, or force it to [continue]<continue|? ]]

(click: ?slowdance)[(replace: ?passage2)[You gingerly wrap your arms around the NPC and start swaying around in a soft rythm.]]

(click: ?breakdance)[(replace: ?passage2)[You bust out some moves with the NPC.]] }

Comments

  • NOTE: I am assuming that when to say 'multi-node' and 'single-node' you actually mean 'multi-passage' and 'single-passage'.

    Your issue is a result of a slight misunderstanding of where the resulting link created using a named hook with a (click:) macro is generated.

    The code representing the resulting link is generated where the named hook is, not where the (click:) macro is, this also means that the output of the related (replace:) is also generated where the named hook is and you can see this using your web-browser's Development tools to see what happens when you click on the links.

    This is why replacing the passage2 area does not effect the dance options text, because that text is actually part of the passage 1 area. The passage2 area being replaced actually contains the residual elements representing where the (click:) macros were.

    To make your code work the way you want you would need to move the passage2 named hook into the (replace:) macro's associated hook, the middle section of your example would look something like the following:
    { (click: ?sNtalk)[(replace: ?passage1)[You start making small talk with the NPC.]]
    
    (click: ?sNignore)[(replace: ?passage1)[You turn away and pretend not to notice the NPC, though you can still see its dejected expression out of the corner of your eye.]]
    
    (click: ?sNdance)[(replace: ?passage1)[[You offer to teach the NPC how to dance - it enthusiastically agrees. Do you want to [tango]<tango|, [slow dance]<slowdance| or [breakdance]<breakdance|?]<passage2|]] }
    

    WARNING:
    The current Twine 2 Story Formats are not designed to support the type of single page/passage methodology you are trying to create. Their History/State modules are designed to only persist the variable changes done within the current passage when the Reader navigates to another passage, up until that point the changes are only local to the current passage (and to child passages / code referenced from it).

    eg. Your (set: $mood to "romantic") is only persisted to History/State when the Reader moves to another passage.

    If there current passage is refresh in the wrong way (eg via web-browser page refresh) then all the Reader's progress through the current passage can be lost.

    There is only one Story Format that I know of that is designed to work correctly in singe page mode and that is Twine 1's Jonah.
Sign In or Register to comment.