[SOLVED] Save with multiple instances (copies) of an object?

I am making a “tab/sheet music engine” for Ocarina music, which means I have 4 lines, each with 14 copies of boxformed sprites (/platforms called Note) and when I have the cursor on one of them and press different keys, the animation changes accordingly (24 different animations showing note + which holes to cover on the ocarina). Now my question is: can I make a save-mechanism without having to name every sprite differently? Probably I would do saving possible by making the number of the animation a variable, unless anybody has a better suggestion? :wink: I suspect the system wouldn’t keep track on which Note is which when I save without naming them differently; am I right? It would be nice to be able to save the sheet music I have written for possible later editing, but I am not sure it is worth the effort if every Note needs to be named differently (to again place all boxes precisely where they should be, especially when I also have two additional boxes per Note for additional information, it would be tedious and a lot of boring work…) Bonus question: I also have black (note)lines and some are shown black, but others look grey. It seems to depend on where they are located, as it sometimes changes when I change their position. Any suggestions how to fix this and how to make everything look more crisp would be appreciated :slight_smile: Could there be a window size or other issue with scaling that could be easily fixed?

1 Like

I’m having trouble understanding everything, There’s a key on the keyboard called “Return”, it’s very nice, give it a try, some time. :grin:
Some screenshots would have helped too, but to reference your game data, you can use animation number, animation name, variables or anything you like.
If you have “additional boxes per Note for additional information”, you can position them relatively to each Note, to avoid manual work.

I don’t know about your grey/black issue, we need some details and screenshots.

Cheers

Here is a screenshot with some random notes put in in the beginning. The grey lines can be seen especially among the uppermost lines:

I suppose I could do the saving with Instance variables, but could I group them as a Structure for example? And how would I do that? I haven’t yet figured out how to make a Structure… I would also like to have it so that the “player” can save the song they have written and name it, and then later load it (means multiple saved files). Any ideas on how to do that?

I see what you mean. I think this is an issue of the image being scaled up/down. When the drawing is too thin, it gets noticeable because 2 px is 200% of 1px.
Yes, there are structure variables. You’ll find all the details on the wiki page.

Thanks for your thoughts Gruk! I have been busy working with the saving, so the testing with scaling is still wating to happen.

After some research on the forum, and thanks to ddabrahim (you are a lifesaver!) and especially this very useful tread: Save/load I did manage to save in a simple and beautiful way, so I thought I would share it. Is there by the way some way to mark the most helpful solutions to a given problem or add examples in a place where they can easily be found? Here is how I did it:

  • So I gave all instances of my object Not an own variable, ID, with the help of another variable, id_counter, with 1 added to it for each instance of Not

  • I think it is crucial to have the group you save to in the form it is here (unless it is something else than the animation you want to load.) So the group name really matters in this case! :wink: It is here we tell what it is we want the system to write/read and take the instance ID into account.

  • Repeat for each instance is crucial too for the ID counter, write and for read. (It is added from the round + button → For each object)

  • I first tried with number of animation, but it didn’t work (maybe it was something else I did wrong?), so I gave them names (from where you add animation, you can also give them alternative names) and coded accordingly, and it works! :smiley:

  • If I have animations of different Objects, I noticed it doesn’t work with calling all the groups
    “Animation” + ToString(Object1.Variable(ID))
    (with “Animation” for all and just changing Object1.Variable, Object2.Variable…) The system seems to do overwriting with this, as just the animation of the Object written last (lowest on the coding) will change. So I called the groups
    “Object1” + ToString(Object1.Variable(ID))
    and it works! It seems it doesn’t matter what the first part, the “xx” is, it is this:

  • ToString(Object1.Variable(ID)) - part that matters.

Now on to figure out how to save into PC files with names… Ideas are highly appreciated!

1 Like

For saving to PC files, you use the “Filesystem” instructions. There’s a wiki page about it.

And you can add [Solved] to your topic title if you want to help future users find this answer.

Thanks! As the saving with multiple save files is another topic, I have made a new question about that here: Make several save files player can find

If you don’t save your game before you copy the copy will be out of order. I just saw this in my game.