Loop inside embed loop+race structure never gets cancelled

Apparently, this is the fix (move the whole race inside a method, I didn’t know races where aware of their suspending method, I thought they would be aware of their suspending scope only)

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

test_device := class(creative_device):

    OnBegin<override>()<suspends> : void =
        loop: # Fake loop, will only iterate once
            Print("START RACE")

            race:
                Sleep(1.0)
                loop:
                    LoopPrint()

            Print("END RACE") # Prints after 1s
            Sleep(Inf)
        
    LoopPrint()<suspends>:void=
        race:
            Sleep(Inf)
            loop:
                Sleep(0.4)
                Print("LOOPING")
1 Like