How do I make my own UNDO/REDO system?

  • You can easily convert to new Functions, just right-click and choose "Replace with built-in function".

    1. Number of undo steps is set on UNDO sprite, maxSteps variable.

    3. Yes, if you use System Save somewhere else, it will be saved as undo step, so you need to add some kind of flag, say a boolean variable isUndoSave, set this flag in "SaveStep" function, and check for this flag in "On Save complete", also reset this flag there.

  • dop2000 I tried to follow your instructions but I made a total mess now whenever I Run the software (F5) it will open the "Save as.." box, so I know for sure that it's not working because I did it wrong.

    I tried to follow your instructions but probably didn't understand exactly:

    1 - I've added a boolean "isUndoSave" for the "UNDO" sprite, false by default.

    2 - Here is where I didn't understand how to apply what you explained to C3 exactly:

    Sorry, the functions and arrays are not something my brain can get easily yet.. I'm trying to follow but as you can see obviously I don't get it... yet.

  • The code on your screenshot is correct, that's exactly how it should be done. I don't know why are you getting "Save as" dialog, must be some other event.

  • The code on your screenshot is correct, that's exactly how it should be done. I don't know why are you getting "Save as" dialog, must be some other event.

    IT IS?? ok... I wasn't sure at all, that's a progress for me.

    So, just for testing if I disable the:

    Start of Layout > Functions | Call Undoinitialize

    The "Save As" issue won't appear... so I'm trying to look what I did wrong, and how to fix it.

    I don't know how to "start over" maybe I'll rename the "Save As" for fresh test because I don't know how to get rid of this issue so I can proceed.

    EDIT:

    I disabled the SAVE LOAD - SYSTEM group, and the UNDO system doesn't work at all on my project.

    I have no idea what I did wrong even with all the organized groups it is a mess to find the issue, I can only guess it's a mess related to the JSON or whatever data these two systems work with...

    Or maybe because I use Families? (which I must)

    Creating Objects:

  • Do you have other "On save complete" or "On load complete" events in your project? Or an action like "Browser invoke download SaveStateJSON"? You'll need to add "isUndoSave not set" condition to those events.

  • Do you have other "On save complete" or "On load complete" events in your project? Or an action like "Browser invoke download SaveStateJSON"? You'll need to add "isUndoSave not set" condition to those events.

    I guess yes, here is the screenshot of the SAVE / LOAD SYSTEM:

    But even if I disable this group, nothing related to Ctrl + Z works, what could it be?

  • Is it because you forgot to re-enable UNDO group? :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Is it because you forgot to re-enable UNDO group? :)

    LOL.. no no, both are enabled :D

    I just tested the UNDO group without the SAVE group to stop getting this annoying automatic "Save As" that starts as soon as I test with F5

  • I don't know your project and can't help you with this. Maybe when you preview with F5 the event sheet with Undo functions is not accessible (not included into layout's event sheet). Or there may be a dozen of other reasons.

    .

    By the way, you probably need to initialize Undo (clear undo history) after you load ".alon" files.

  • I don't know your project and can't help you with this. Maybe when you preview with F5 the event sheet with Undo functions is not accessible (not included into layout's event sheet).

    .

    By the way, you probably need to initialize Undo (clear undo history) after you load ".alon" files.

    OH! I'm not sure but... the UNDO and other "SYSTEMS" are all in one dedicated layout called: "E_MANAGER"

    which included in the actual Layout I'm using, so far everything worked there but maybe the Undo won't because of that?

    Also can you please guide me how I clear the undo history for the load and also...

    Just an idea... maybe as soon as the Software start (f5) it will clean which probably doesn't make sense but worth a try?

  • ...Or there may be a dozen of other reasons.

    When something is not working I usually add a bunch of "Browser log" debug messages into relevant events/functions and see which of them are showing in the console. This is called debugging :)

    .

    Also can you please guide me how I clear the undo history for the load

    Change the function like this and call it after .alon file is loaded.

    .

  • When I try to replicate the code for the clear, C3 asking me for a value to clear the entire array with,

    I think in C2 it's just Clear, and since I'm super confused with Arrays anyway I don't even know what to type there so I put 0 for now (default).

    Anyway, here is the current mess (sorry about it) I tried to cut it to the problematic part, maybe your sharp eyes will get the problem why the UNDO/REDO system doesn't even work with CTRL+Z

    There will be very ugly things you'll see because I tried to follow your instructions (beside the CLEAR part for now because I don't know what value to type in)

    Sorry for the HUGE image, I'm out of ideas already...

    Anything that related to the Creation of the objects is on that GROUP but with the same code you made, it maybe not seen because I fold it for sake if how huge this event sheet is already.

  • In event 100 the condition should be inverted - "Is NOT IsUndoSave".

  • Yeah... I guess I broke it real bad, even that won't save the project.

    Maybe I should just make my software without UNDO/REDO (users will be pissed off for such primitive decision) but this event sheet is already huge and I will never find what goes wrong.

    Debug won't help me because I don't know what to look for anyway.

    Don't get me wrong dop2000 I appreciate your help a lot! (I tried to look for you on discord so I could show you the project via screenshare) but you're offline also probably offline.

    I'll see what I can do, messing around with it before I'll give up on such MUST feature.

  • Hi dop2000 sorry to bother you again, but I had to see if it's just me or something is wrong with the "converting" from C2 functions to C3...

    So I delete EVERYTHING in my project but layers and some layouts to keep the same structure.

    And COPY/PAST your project from c2.

    When I did that CONVERT to built-in functions... I guess something went wrong because I get the exact same issue I had: NO UNDO when Ctrl+Z

    Can you please have a look? maybe it's a minor thing that can be fixed so I can actually use this on my project?

    Maybe there is still a hope for me:

    DOWNLOAD C2 converted to C3 Functions

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