Howdy, Stranger!

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

(live:) event not stopping?

So I'm trying to do a simple animation of sorts, and I have a feeling I'm missing something really obvious, but I just can't figure it out for the life of me. I'm working in Twine 2, using Harlowe.

I want to have a page that says "Initializing..." and adds a dot to the end of the sentence every 0.2s or so, until the total length is about 30 characters long, or so. Then it will stop automatically. I wrote an (if:)/(else:) statement based on the length of the word, but that doesn't seem to be working... do I need to do something like set a variable to increment? What am I missing??

Here's what I've written so far - it works fine, it just never stops :)
(set: $init to "Initializing...")

$init

{(live: 0.2s)[
(if: (text: $init)'s length is 30)[(stop:)]
(else:)[(append: $init)[.]]
]}

Thanks so much in advance!!!

Comments

  • There are a number of misunderstanding in your example:

    1. You are using a (text: ) macro to convert the current value in the $init variable (which is a String) into a String value, so it is not needed. So (if:) macro could be changed to:
    (if: $init's length is 30)
    
    2. The third line in your example is adding a copy of the current value of $init to the page's output, you then use an (append: ) macro to update all occurrences of the current value of $init in the page's output. That append is not changing the value of the $init variable, just what is being displayed on the page which means the value in $init is not getting any longer. The following test shows this:
    (set: $init to "abcd")
    init length: (print: $init's length)
    
    $init
    
    (append: $init)[e]
    current init: $init
    current length: (print: $init's length)
    

    Try something like the following, it uses a Named hook to mark the area of the page to replace:
    (set: $init to "Initializing...")
    
    |msg>[$init]
    
    {(live: 0.2s)[
    	(set: $init to it + ".")
    	(replace: ?msg)[$init]
    	(if: $init's length is 30)[(stop:)]
    ]}
    
Sign In or Register to comment.