Why does REPEAT expression need a trigger once?

0 favourites
  • 6 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • Please help me with this one. I feel very dumb right now. Cosmically so.

    But doesn't the expression REPEAT 20 TIMES indicate that it repeats 20 times and then ends?

    Is the use case for REPEAT 20 times and then repeat again so frequent and logical that it justifies avoiding using the expression like it is intuitive?

    I can't even think of a use case for just repeat without Trigger once before it.

    But as I already established I may be profoundly stupid.

  • "Trigger once" has nothing to do with loops.

    In your screenshot it basically means that this event will be executed once only on the first tick. So it has the same effect as placing this Repeat loop inside the "On start of layout" event.

    With "Trigger once" the Repeat loop will still repeat 20 times.

    Without the "Trigger once", the Repeat loop will repeat 20 times, and will continue doing this each tick.

  • Yeah so right now with the trigger once its doing what I presumed. But at a meta level, do you agree that "repeat 20 times" indicates that it will end afterwards?

    That's just the intuitive takeaway from the wording.

  • Not sure what you mean. Like I said, Trigger once has nothing to do with loops. Loops are used to repeat some action within one tick. "Trigger once" is to not allow running events on the next ticks.

  • "Trigger once" really means "this condition did not run last tick". So if it's at the end of a block of conditions, and the block becomes true, it only runs once: the first time it goes from false to true. Therefore it only makes sense to use it at the end of an event block, as the manual entry for it says:

    It must be the last condition in an event.

    It doesn't make sense to use it at the start of an event block. People seem to often misunderstand its purpose and how to use it and end up putting 'Trigger once' in all sorts of funny places. I guess it's quite an abstract notion.

    'Repeat' is much simpler: it does what it says on the tin, and repeats the remaining conditions, actions and sub-events as many times as you tell it to.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Yeah so right now with the trigger once its doing what I presumed. But at a meta level, do you agree that "repeat 20 times" indicates that it will end afterwards?

    That's just the intuitive takeaway from the wording.

    I understand where you are coming from, but keep in mind that the logic you are thinking will only occur with "Trigger" events, such as "On Collide" or "On Key Press", and as you have found, "Trigger Once Whilst True".

    All loops (Repeat, While, For, For Each) are not "Triggers", and will always be processed each tick.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)