Howdy, Stranger!

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

Simple way to 'show' actions?

edited November 2015 in Workshop
I'll keep this example simple, as the principle is the same anyway, but I'm wondering if there's a more efficient way to show an action, than the method I currently use.

Let's say you have a passage in which a player may drink some water, and you want to 'animate' (not literally) that action. Here's how I'd do it.

Starting with a passage called, for instance, 'Forest Clearing'
You are by a stream in a forest clearing.

A cabin lies to the west while the tips of mountains can be seen to the east

[[Go west]]
[[Go east]]
[[Drink from the stream->Drink]]

Choosing the drink option would send the player to a separate passage called 'Drink' which would have the following.
You stoop down and fill your cupped hand with water. The water is cold and delicious.

[[Go West]]
[[Go east]]

Now okay, this works fine, but my thinking is that the more passages you have that don't actually lead anywhere, the more cluttered your grid is going to get.

Is there not a way to have the action display in the original passage. For instance have the 'Drink from the stream' link simply replaced by the 'You stoop...' action on click?

Comments

  • You may use a <<click>> macro combined with a few of the DOM (Content) macros to achieve your goal. For example:
    You are by a stream in a forest clearing.
    
    A cabin lies to the west while the tips of mountains can be seen to the east.\
    <span id="drink-target"></span>
    
    [[Go west]]
    [[Go east]]
    <span id="drink-action"><<click "Drink from the stream">>
    <<replace "#drink-target">>
    
    You stoop down and fill your cupped hand with water. The water is cold and delicious.\
    <</replace>>
    <<remove "#drink-action">>
    <</click>></span>
    
  • Wonderful! I'd never have got there in a hundred years. Thanks.

    I was doing my own digging and suspected I'd need to use the 'print' or 'input' macros. Just shows how little I know.
  • I can't utilise this successfully, as I'd forgotten I have whole heap of other conditions in the passage.

    I tried by best and ended up with this, which when tested returns the following errors:

    Error: HTML tag "span" is not closedError: cannot find a closing tag for macro <<click>>Error: cannot find a closing tag for macro <<replace>>
    <<if not $Drink>>\
    <<set $Drink to true>>\
    Steady pace along the long empty road now. Making good time, but the darkness is fading rapidly as the sun makes for the horizon.
    
    Thirst developing. Dry lips.
    <span id="drink-target"></span>
    [[Stay on the road]]
    [[Head for the forest and make camp for the night->Camp]]
    <<if $hasClearLiquid>><span id="drink-action"><<click "Drink clear liquid.">><<replace "#drink-target">><</if>>
    <<else>><<set $hasClearLiquid to false>><<set $hasDrink to true>>Tasting tentatively. A drop to the lips. <em>It's water!</em>
    
    Drinking furiously now, a quarter of the contents gone in a few gulps.\
    <</replace>><<remove "#drink-action">><</click>></span><</if>>
    
  • You've enclosed the opening <span>, <<click>>, and <<replace>> tags within the <<if $hasClearLiquid>>…<</if>>, but put their closing tags outside it. Beyond that, you put the very same tags inside the first clause of the <<if not $Drink>>, but their closing tags are within its <<else>> clause. Basically, you've cut the relevant tags in half, twice.

    I'm not entirely sure which parts you want pre-/post-replace, so for the moment, I can't offer an example. If you could clarify what you want it to look like before/after drinking the "clear liquid", that would help.
  • edited November 2015
    Okay. Please bear with me.

    Please bear in mind I have this working exactly how I want it, but my method sends the player to another passage for the drink action.

    Passage on 1st visit (assuming 'bottle of clear liquid' was taken at previous passage)
    Steady pace along the long empty road now. Making good time, but the darkness is fading rapidly as the sun makes for the horizon.
    
    Thirst developing. Dry lips.
    
    [[Stay on the road]]
    [[Head for the forest and make camp for the night->Camp]]
    [[Drink clear liquid->Drink]]
    

    Passage after player chooses 'Drink Clear Liquid' option
    Tasting tentatively. A drop to the lips. <em>It's water!</em>
    
    Drinking furiously now, a quarter of the contents gone in a few gulps.
    
    [[Stay on the road]]
    [[Head for the forest and make camp for the night->Camp]]
    
  • edited December 2015
    Does this format not support variable updates in response to destination choices?
    [[Drink from the stream|clearing][set $drinking to true]]
    

  • mykael wrote: »
    Does this format not support variable updates in response to destination choices?
    [[Drink from the stream|clearing][set $drinking to true]]
    
    If your asking does SugarCube support Setter Markup Links, then the answer is yes but they look like:
    [[Link Text same as Target Passage Name][$variable to "value"]]
    or
    [[Link Text|Target Passage Name][$variable to "value"]]
    
  • mykael wrote: »
    Does this format not support variable updates in response to destination choices?
    [[Drink from the stream|clearing][set $drinking to true]]
    
    It does (though your syntax is incorrect; you don't put "set" in a setter link). The problem is that Twine 2, currently, has rather poor handling of links which aren't absolutely basic. Setter links (e.g. link][setter) and links which cannot be resolved until runtime (e.g. text->aFunctionCall()) are handled poorly—the former, at least, has been addressed in the repo, while the latter shall require more extensive work (from both Twine 2 and story formats) to even partially address.

    Jud_Casper wrote: »
    Okay. Please bear with me.
    Since you're using SugarCube v1.x, I'll probably recommend something like the following: (for this example assume the passage is named "Long empty road")
    <<if not $hasDrink>>\
    Steady pace along the long empty road now. Making good time, but the darkness is fading rapidly as the sun makes for the horizon.
    
    Thirst developing. Dry lips.
    <<else>>\
    Tasting tentatively. A drop to the lips. <em>It's water!</em>
    
    Drinking furiously now, a quarter of the contents gone in a few gulps.
    <</if>>
    [[Stay on the road]]
    [[Head for the forest and make camp for the night->Camp]]
    <<if $hasClearLiquid>><<click [[Drink clear liquid->Long empty road]]>>
    	<<set $hasClearLiquid to false>>
    	<<set $hasDrink to true>>
    <</click>><</if>>\
    
    A few notes:
    1. I dropped $Drink, since you already have $hasDrink. I'm unsure if you were using it elsewhere, but it didn't really seem necessary here.
    2. The <<click>> loops back to the same passage, so replace "Long empty road" with the passage's actual name.
  • Thanks a lot, TMA. That works like a charm!
  • Yeah, sorry about the syntax. Comes from posting without a copy of Twine to hand.

    Setter links make this stuff much easier as they alliw you to rerun the passage with a specific variable set. Logic is a bit prologish, but you can't have everything...
    <<if $drinking is true>>You taste a sip...
    
    Water!
    
    You gulp it down. <<set $drinking to false>><<endif>>
    
    You stand on a long, dusty road.
    
    <<if $hasDrink is true>>[[Drink the clear liquid|road][$hasDrink to false; $drinking to true]]
    

    I tend to use an entry macro that simply prints whatever, if anything is in the $entry variable. That lets me do this:
    <<if $hasDrink is true>>[[Drink the clear liquid|road][$entry to "You take a cautious sip. Water! You gulp the rest of it down."; $hasDrink to false]]
    
    ]

    Typed on my phone, so appologies for any typo's.
  • May I ask the same question, but for vanilla and not Sugarcube?
Sign In or Register to comment.