Howdy, Stranger!

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

How can I repeat the same piece of code multiple times?

The method I used worked by having a passage named, for example, "repeat".

(set: $timer to $timer -1)
(if: $timer > 0)[(display: "repeat")]

The problem with this system is that after large enough amount cycles the system recognizes what its doing and registers an error before it can finish the system.

Comments

  • Based on the syntax of your example I am going to assume you are using the Harlowe story format.

    Harlowe does not currently have a (for:) / (while:) / (repeat:) macro, you can however use the (live:) macro to emulate it but the downside is that it can interfere with the Reader's ability to interact with your story.
    (live: 50ms)[Whatever you want to happen over and over until the user navigates to another passage]
    
    You can also use the (stop:) macro to stop a (live:) timer.
    (set: $counter to 0)
    (live: 50ms)[
    	Whatever you want to happen over and over.
    	(set: $counter to it + 1)
    	(if: $counter >= 10)[
    		(stop:)
    	]
    ]
    
    ... I added indents and line-breaks to the above to make it more readable, they can be removed.
Sign In or Register to comment.