Bug – For Loop containing While True (1.2.5b)

FlowCanvas Forums Support Bug – For Loop containing While True (1.2.5b)

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #719
    pawels
    Participant

    A For Loop that contains a While True won’t work properly. I made a simple example script that shows it. It should output the following sequence of numbers in the console:

    0, 1, 0, 2, 1, 0, 3, 2, 1, 0, 4, 3, 2, 1, 0

    While it outputs the following:

    0, 4, 3, 2, 1, 0

    Attachments:
    You must be logged in to view attached files.
    #725
    Gavalakis
    Keymaster

    Hey,

    The While node is not exactly a While loop but rather a coroutine while. This is done to avoid accidental user error with a result of hanging the editor in an infinite loop.
    If you replace the While.cs code with the following code bellow it will come up with the results you want, but I am not really sure I this would be a good change to add for the reasons above. Maybe I can add an option in the node inspector for that.

    Let me know what you think.
    Cheers.

    Join us on Discord: https://discord.gg/97q2Rjh

    #730
    pawels
    Participant

    Sorry for another false bug report from me, it turns out that finding a real bug in FlowCanvas is not as easy task 🙂 Can you explain how the coroutine while works? If I understand it, perhaps I can find a way to use it without making the above change to the code.

    #734
    Gavalakis
    Keymaster

    Hey,

    No worries 🙂
    Well, right now the While node works like a coroutine. Once the first flow signal is called on the While node, it starts a coroutine which calls “DO” only once every frame until the “Condition” input becomes false.
    If the While node is called more times while the coroutine is still running, it is simply ignored. So only after the While node is done (and thus “Done” output is called), will another While loop be possible to take place for this While node.

    So, probably due to how it works now, using While node as part of a For Loop will not really work as expected. I will probably need to add this option to do a real While loop (no coroutine) for such cases.

    Let me know what you think and thanks! 🙂

    Join us on Discord: https://discord.gg/97q2Rjh

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.