calminthenight's Forum Posts

  • Not possible.

  • Would it not be better to just modify the string that already determines the array index?

    For example your current string is 4231 and if you want to invert positions 2 and 3 you would change the string to 4321?

  • Thanks ROJO that's much neater.

  • In the screenshot the function was called normally so it can’t take multiple frames to complete. It would run till it’s done.

    Of course, that makes sense and means it should work. Thanks, my tired brain never even considered that it is actually restricted to running within that tick.

    The array could be considered sorted if the sub event isn’t run once in an entire loop. You could use a variable for that: set it to 0 before the loop, set it to 1 in that sub event, then check if the var is still 0 after the loop. But then all the previous recursions would need to finish all their loops of doing nothing before it was truly done.

    I tried this method and it consistently failed. Likely due to how recursive functions stack.

    Another idea is to pass a depth parameter to the function When you first call the function use 0. Then each recursed call would be depth+1. Finally add another event to the function to check if depth=0, and if it is the whole function is done.

    I had also tried this exact method but it failed with inconsistent results, often stopping the function before the sorting was complete. Couldn't work out why.

    Personally I’d write the sort in a non recursive way. Like sorting one column at a time. If for no other reason but to be more efficient. Your function will sort but it will be looping over the array a lot.

    I agree, it's not the most efficient but I can't think of a way to sort all the non zero values in a single column to the bottom without recursion.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It should be enough to just call a second function in the “on space” event. Then when the first function finishes the second will be run.

    While this works, if the function took more than one tick to complete would it break as the next function would be called prior to the completion of the first, which it is dependent on?

    An Asynchronous function with a "wait for previous events to finish action" would likely also be unreliable as the function is recursive, so technically it finishes many times before actually being finished.

  • I'm using a recursive function to sort an array in a specific way but I can't work out a good way to flag when the function is complete.

    The recursive function itself works fine, I just can't action something when it ends.

    What I want is for the the function to be initially called by another event. Then when the function has fully completed sorting the array I want it to call a different function.

    I've tried a few different methods but can't nail it. Help would be greatly appreciated.

    1drv.ms/u/s!AkmrWgxeuxlKhJwBQwo7XM7mMAoluQ

  • I don't think you can change the duration of an already running/paused timer. If you stopped it instead, you could restart it with a new duration.

  • Thanks. Hopefully Ashley responds to the request for clarification and the issue can be started on.

    Time to roll back Chrome in the meantime.

  • Anyone else seeing this issue?

    Since Chrome 104.0.5112.79/80/81 (Windows) Construct 3 Debugger is lagging heavily at load and sometimes locking up entirely.

  • I'm not familiar with the example but if you are only using 2D arrays you could use 3D arrays instead and use a different depth for each chest.

  • Alextro is correct. Add a pick all event to reset the pick list.

  • If the instance of the tool is always the most recent instance of that object then you can use this to destroy it after the timeline finishes.

    Just replace the Characters object with your object.

  • Thanks ROJO. Yes, easy to work around but I just found it odd that it is not exposed. Will have a poke around with the logger and see if I can find it in JS.