Howdy, Stranger!

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

Is it possible to set text to Continue?

edited March 2015 in Help! with 2.0
Ok, tried going topic by topic to find this (and search) and really not finding it so.. question.
Hey there good neighbor, I can't quite tell in this light, what color shirt are you wearing anyway?
|body>[[Gold and white shirt]<Op1|
[Blue and black]<Op2|
[Sparkly shirt]<Op3|]
(click: ?Op1)[(set: $choice to 1)(replace: ?body)[It is gold and white, of course!]]
(click: ?Op2)[(set: $choice to 2)(replace: ?body)[Blue and black shirt, can't you tell?]]
(click: ?Op3)[(set: $choice to 3)(replace: ?body)[I just got back from the Twilight premier so.. sparkles for the win]]

Well, now that you mention it, of course it is [Gold and white | Blue and black | Sparkly], how could I have missed that? Although I still can't quite see your hat, what kind of...
And of course the 'well, now that you mention it...' text and all that happens below it, presumably a few more choices, would not appear until after you've picked one of the choices

There is the click-append option but it seems you have to append to something specific (not 'end of document') and that I would have to retype it all for each click options (not bad for a quick sentence, bad for a lot of ongoing text w/ options and so on happening afterward).

And I could insert it from a different passage to the bottom of this one, but that would leave a lot of dangling passages with no lines to them to manage, which seems doable.. but messy, especially if these situations happen in various points in the game.

The use-case I am considering is where there is some info-gathering dialog, where you don't want to have passages that are only 1-2 sentences long.  I am pretty sure I've seen this done in various places..?

Comments

  • In an ideal world you could wrap the text you wanted hidden in something like either <span id="conv1" style="display: none;"> or <span id="conv1" class="hidden">** and then use some in-line Javascript like either $("#conv1").show() or $("#conv1").removeClass("hidden") to make it visible again but currently Harlowe makes it difficult to call in-line Javascript.
    **: The class based version requires some CSS like .hidden {display:none;} to work.

    One possible solution to your issue is to use a (live:) macro to show the hidden text when a condition is met, as the following example based on your own shows.

    (note: I replaced some of your hook's with (link:) macros, to reduce the number of hooks, and I store your possible choices within a array so you only have to edit the choices text in one place.)

    {(set: $choice to 0)
    (set: $choices to (array: "Gold and white shirt", "Blue and black", "Sparkly shirt"))
    (set: $clothes to "")

    }Hey there good neighbor, I can't quite tell in this light, what color shirt are you wearing anyway?

    |body>[(link: $choices's 1st)[(set: $choice to 1)(set: $clothes to $choices's 1st)(replace: ?body)[It is gold and white, of course!]]
    (link: $choices's 2st)[(set: $choice to 2)(set: $clothes to $choices's 2st)(replace: ?body)[Blue and black shirt, can't you tell?]]
    (link: $choices's 3st)[(set: $choice to 3)(set: $clothes to $choices's 3st)(replace: ?body)[I just got back from the Twilight premier so.. sparkles for the win]]]

    (live: 20ms)[(if: $choice > 0)[Well, now that you mention it, of course it is $clothes, how could I have missed that? Although I still can't quite see your hat, what kind of...(stop:)]]
    The Harlowe source code implies that you should be able to access an array element based on an expression [eg. $choices's ($choice) ] but I have not been able to get that to work. If it did work then you would not need the $clothes variable in the above example.

    Here is a copy of the above example reformatted so it is a little more readable:

    {(set: $choice to 0)
    (set: $choices to (array: "Gold and white shirt", "Blue and black", "Sparkly shirt"))
    (set: $clothes to "")

    }Hey there good neighbor, I can't quite tell in this light, what color shirt are you wearing anyway?

    |body>[
    (link: $choices's 1st)[
    (set: $choice to 1)
    (set: $clothes to $choices's 1st)
    (replace: ?body)[It is gold and white, of course!]
    ]
    (link: $choices's 2st)[
    (set: $choice to 2)
    (set: $clothes to $choices's 2st)
    (replace: ?body)[Blue and black shirt, can't you tell?]
    ]
    (link: $choices's 3st)[
    (set: $choice to 3)
    (set: $clothes to $choices's 3st)
    (replace: ?body)[I just got back from the Twilight premier so.. sparkles for the win]
    ]
    ]

    (live: 20ms)[
    (if: $choice > 0)[
    Well, now that you mention it, of course it is $clothes, how could I have missed that? Although I still can't quite see your hat, what kind of...
    (stop:)
    ]
    ]
    I hope this helps.
  • Fantastic and brilliant, thanks greyelf!  I hadn't thought of using timer loops to keep checking for variables being changes, very nice and clean.  (Well, not perfect-universe clean, but for a human-readable scripting language, and without worrying about a lot of overhead from a lot of other processes... perfect)

    Much thanks!
  • greyelf wrote: »
    In an ideal world you could wrap the text you wanted hidden in something like either or ** and then use some in-line Javascript like either $("#conv1").show() or $("#conv1").removeClass("hidden") to make it visible again but currently Harlowe makes it difficult to call in-line Javascript.<br />
    **: The class based version requires some CSS like .hidden {display:none;} to work.

    For what it's worth, it seems to work for me if I enclose the inline script in <script> tags, i.e.
    (link: "Your link here")[<script>$("#choice1").addClass("hidden"); $("#choice2").removeClass("hidden"); </script>]
    
  • For what it's worth, it seems to work for me if I enclose the inline script in <script> tags,
    Harlowe has been updated since my original comment was posted in March and now supports <script> elements, which is why your solution to the dynamically assigning a class to an element issue now works.
  • greyelf wrote: »
    For what it's worth, it seems to work for me if I enclose the inline script in <script> tags,
    Harlowe has been updated since my original comment was posted in March and now supports <script> elements, which is why your solution to the dynamically assigning a class to an element issue now works.

    And here I was thinking I was really smart for figuring that out. Oh well, I just thought it was worth updating this (admittedly slightly old) thread in case someone else found it like I did and could use the answer.
  • And here I was thinking I was really smart for figuring that out. Oh well, I just thought it was worth updating this (admittedly slightly old) thread in case someone else found it like I did and could use the answer.
    You are and it was! lol

    I was just making it clear about why it now works, when it did not before.
Sign In or Register to comment.