Howdy, Stranger!

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

Fake conversation using time and live ?

edited February 2017 in Help! with 2.0
Hey there, it's me again.
I'm trying to "simulate" a conversation.
I've been trying multiple things, and discovered "Time" and "Live".

So far, here I am :
//Sent by// $name: "''Fuck off, why would you go and tell mom AND dad I didn't do shit ?!''"

(live:1s)[
(if: time >=2s and time <4s)[$nameC is writing...]\
(if: time >=4s)[
//Sent by// $nameC: $c["''Seriously ? Are you talking to me?!''"]
]\
(if: time >=5s and time <8s)[$nameC is writing...]\
(if: time >= 8s)[
//Sent by// $nameC: $c["''I told them BECAUSE you didn't do shit ffs!''"]
]\
(if: time >=9s and time <12s)[$nameC is writing...]\
(if: time >= 12s)[
//Sent by// $nameC: $c["''You didn't do ANYTHING !''"]
]\
(if: time >15s)[(stop:)]]\

(live:) checks time every second in order to show new lines of text.
It works fairly well, although I'm sure you'll have better ways of doing this, which I'd gladly receive !

There is one issue though, because of the loop nature of this method, it re-prints what $nameC says, and her text is colored.
(set: $c to (color: "#D87093"))\

Every time it prints her text anew, the color doesn't charge fast enough, and her text blinks.

Any way to go around that ? I'd really like to keep her color...

And as always, thanks for your help !




Comments

  • When asking a question you need to state the name and version of the Story Format you are using, as answers can be different for each one. Based on the syntax of your examples and your comment history I am going to assume you are using Harlowe v2.0.0

    1. Instead of re-displaying the conversation each time the (live:) macro's timer fires, you could use a combination of a named hook and the (append:) macro to update a section of the page.

    2. Because your (if:) macro conditions are mutually exclusive you should use an (else-if:) macro for each of the conditions after the first.

    3. I personally don't like relying on the value returned by the time keyword because the (live:) macro's timer does not always fire on exact intervals due to the additional delay introduced by the processing of the content of it's associated hook.

    eg. If you have a (live: 1s) timer and the content of the associated hook takes 0.8 seconds to process then the timing of the events may look something like: 1s, 2.8s, 4.6s, 6.4s, etc...

    Because of this I suggest using a variable to track how many times the timer has fired and base your conditional statements on that variable instead.

    The following is a modified version of your example, I have added the assignment of $name and $nameC for testing purposes.
    {
    (set: $name to "Person1")
    (set: $nameC to "Person2")
    (set: $counter to 0)
    (set: $c to (color: "#D87093"))
    }\
    |chat>[//Sent by// $name: "''Fuck off, why would you go and tell mom AND dad I didn't do shit ?!''"]
    
    (live: 1s)[
    	(set: $counter to it + 1)
    	(if: $counter is 2)[
    		(append: ?chat)[<br>$nameC is writing...]]
    
    	(else-if: $counter is 4)[
    		(append: ?chat)[<br>//Sent by// $nameC: $c["''Seriously ? Are you talking to me?!''"]]]
    
    	(else-if: $counter is 5)[
    		(append: ?chat)[<br>$nameC is writing...]]
    
    	(else-if: $counter is 8)[
    		(append: ?chat)[<br>//Sent by// $nameC: $c["''I told them BECAUSE you didn't do shit ffs!''"]]]
    
    	(else-if: $counter is 9)[
    		(append: ?chat)[<br>$nameC is writing...]]
    
    	(else-if: $counter is 12)[
    		(append: ?chat)[<br>//Sent by// $nameC: $c["''You didn't do ANYTHING !''"]]]
    	
    	(else-if: $counter > 12)[(stop:)]
    ]
    
Sign In or Register to comment.