How to Make a Save and Load System in GameMaker

Поделиться
HTML-код
  • Опубликовано: 25 ноя 2024

Комментарии • 73

  • @GameMakerEngine
    @GameMakerEngine  Год назад +6

    Big thank you to Josia for the tutorial. Find him on X: twitter.com/w7games
    In this tutorial learn how to code a save and load system into GameMaker. Implement:
    * Writing and reading variables as text files
    * Using structs & JSON
    * Saving and loading multiple objects / rooms
    * Using buffers

  • @teinimon2395
    @teinimon2395 Год назад +16

    Nice timing. I had just finished FriendlyCosmonaut menu tutorials and needed a to learn how to save and load settings. Started looking for a save and load tutorial on this channel and on the website, and came across this video from 6 days ago that I completely missed. Nice one!

    • @scootie_scoot
      @scootie_scoot Месяц назад

      friendlycosmonaut has amazing tutorials!

  • @pzaan
    @pzaan Год назад +9

    What an excellent video. The progression from simple to complex situations was tremendously helpful, and you covered everything in under 12 minutes.

  • @Widestone001
    @Widestone001 Год назад +9

    Thank you.
    You just turned the game I'm making and all my future games into proper games. 😀

  • @asamadoCH
    @asamadoCH 9 месяцев назад +6

    It was a simple and easy-to-understand tutorial on how to handle JSON and how to save and load files.
    However, this method has the problem that when instances are added to or deleted from a room, the save data becomes incompatible.
    I understand that to solve this problem, instead of deleting all instances and recreating them when loading, I need to use a method that reflects the saved contents without deleting the instances in the room.
    I'm looking forward to a tutorial that clearly explains this.

    • @poxpox1334
      @poxpox1334 4 месяца назад

      maybe post the problem on the gamemaker forum?

  • @geostargames
    @geostargames Год назад +4

    I always sucked at making saving and loading system 😅 Thanks! ❤

  • @evaisotalo3386
    @evaisotalo3386 5 месяцев назад

    Best tutorial for understanding saving, loading, arrays, structs and using buffer. It finally all fell in place for me. Thank you ever so much for taking the time making it. 🤗

  • @Paul8711gamezz
    @Paul8711gamezz Месяц назад +1

    tysm! this was exactly what i was looking for!

  • @marcussmithwick6326
    @marcussmithwick6326 10 месяцев назад +1

    Really appreciate these videos. Recently started using game maker and its an amazing toolset.

  • @arti5769
    @arti5769 3 месяца назад

    Wow, I just learned so much from this specific video. Very well done.

  • @KanjiCoder_RTFM
    @KanjiCoder_RTFM 2 месяца назад

    I really liked this tutorial . Thanks !

  • @christopherorestis6906
    @christopherorestis6906 7 месяцев назад +13

    This tutorial is missing a few steps,. I wish this tutorial started from the very beginning with the development of the objects as well as the variables included in each object. The tutorial could also have been slowed down, its not a race. I spent so much time adding in a bunch of code, only for that code to be removed and then replaced with a different line of code. I did learn a few new things though, so I can't complain about that. I just really hope that there will be an updated/extended version of this tutorial that skips straight to the proper method as recommended in the video (using buffers).

  • @tokensgaming
    @tokensgaming 9 месяцев назад +3

    Quick question, How do I find the save.txt in MAC :/

  • @svenjorgensen5
    @svenjorgensen5 11 месяцев назад +10

    If you have a very large game with tons of objects each with tons of variables, this video sort of reads like "how to create a beach with one grain of sand at a time." There's gotta be a faster more efficient way of saving the state of the game.

    • @rooftoprumble7845
      @rooftoprumble7845 10 месяцев назад

      Hey did you find out how to do it?

    • @svenjorgensen5
      @svenjorgensen5 10 месяцев назад +2

      ​@@rooftoprumble7845 I eventually took a similar approach to the one in this video. However, I severely restricted when the player is allowed to save, so that it is done when very few interactions are occurring and very few instances are present. It's not how I originally wanted to do it (I originally wanted the player to be able to save at any time during gameplay), however for larger projects if a developer needs to track nearly every object, variable, array, alarm, data structure, etc. with perfect precision, then it can easily open the game up for serious bugs and crashes when saving is done at certain times. Even then, it's still an enormous amount of work.
      It seems to me that this should be functionality that is built into the engine itself. A save state, like a ROM emulator would do. Especially if you want to bill your engine as beginner-friendly, being able to easily save should be a no-brainer.

    • @EtsaTwo
      @EtsaTwo 9 месяцев назад +1

      ​@@svenjorgensen5it used to be built in.

    • @svenjorgensen5
      @svenjorgensen5 9 месяцев назад +1

      @@EtsaTwo Technically it's still there, however it's marked as deprecated and not recommended for use in the manual. The problem is that even then it was extremely limited and didn't save everything; your game needed to be very simplistic for it to be useful.

  • @dylanmuss2052
    @dylanmuss2052 11 месяцев назад +4

    I've followed and triple checked everything in the video but I keep getting this error when hitting the save or load key. Variable .save_game(100030, -2147483648) not set before reading it. Any idea what the issue is here? I tried making the save_game and load_game functions isolated to their own scripts without declaring as a function and that seemed to work but then there appeared to be issues because they weren't in the same script. Seems like it is something related to functions.

    • @GlouGlou63
      @GlouGlou63 16 дней назад +1

      So, I've been running into the exact same problem and couldn't for the life of me find what the problem was. Went to sleep, and it turns out I was an idiot : in the save_game() function within the script, I had typed :
      var _file = file_text_open_write(save.txt); instead of var _file = file_text_open_write("save.txt");
      So basically your save.txt needs to be a string. If someone happens to have the same error, check that you haven't done the same mistake as me.

  • @Beologe
    @Beologe 27 дней назад

    This is a bit hard to understand, as it's so fast, but I feel kind of challenged to understand it :D I just gonna watch it a few times more. But it's nicely done anyway ^^

  • @ajejebrazord4068
    @ajejebrazord4068 9 месяцев назад +2

    Basically, if we need to save and load for console?
    We need to use the async version and what are the differences from console to console?
    Thank you!

    • @GameMakerEngine
      @GameMakerEngine  9 месяцев назад +1

      The best place to go for help is the GM community forum or Discord
      Forum: forum.gamemaker.io/index.php
      Discord: discord.com/invite/gamemaker

  • @pinatranaves
    @pinatranaves Год назад +2

    Very good!
    One question, when exporting the game to Steam or another platform, if someone else takes the game with this .txt saving system and opens the file, will they be able to change the saved data? (examples: character level, upgrades, items, etc.)

    • @gnysek
      @gnysek Год назад +9

      Of course. But even if you encode it, if someone wish, he would probably find a way to hack save. What I learned - ignore it. If people wants to break they game after they paid for game - who cares.

  • @mrnobody7600
    @mrnobody7600 5 месяцев назад +1

    It doesn't load the states of objects even though I followed this step by step. X and Y coordinations, image index and many other things don't work. It only loads the object's itself.

  • @Palpus_X
    @Palpus_X 7 месяцев назад +1

    My god the pacing is PERFECT. Thank you for this

  • @-Russian_Knight
    @-Russian_Knight Год назад +1

    Очень крутые уроки, я перешел по ссылке от одного канала, на который я подписан, но там уже не выходят ролики. И я рад что перешел по ссылке, ведь попал на очень полезный канал, который мне сильно поможет в изучении программы.

  • @kaspinator5265
    @kaspinator5265 6 месяцев назад

    Since this method works by deleting and recreating objects when loading a save, does that mean that the Instance Creation Code is no longer useable when using this method?

  • @jot2b
    @jot2b 4 месяца назад

    Hi all, will this solution work for adding save/load game function in GM 1.4999 ?

  • @IamNeptunus
    @IamNeptunus 10 месяцев назад +2

    How should i save values in the array that are not variables? such as room seeds and globals?

    • @GameMakerEngine
      @GameMakerEngine  10 месяцев назад +1

      Great question. The best thing to do is to go onto the GameMaker Discord or Online Community Form and ask there. People are really helpful and usually someone is on hand to support

    • @MachineMan64
      @MachineMan64 10 месяцев назад +1

      I'm having this exact issue, please let me know if you've figured it out.

    • @IamNeptunus
      @IamNeptunus 10 месяцев назад

      @@MachineMan64 I just made another seperate save and load script and used the first method in this video (so, without the for loop and manually loading each value)

    • @dimagloom
      @dimagloom 7 месяцев назад

      I saved everything into an array: first global variables, then objects.
      Next, I access element 0 of the array, get the structure and set the values of the global variables.
      Then we can delete objects and create a loop, as in the lesson, but we start from the 1st element of the array, and not from the 0th.

  • @SiegfriedTheCatfish
    @SiegfriedTheCatfish Год назад

    @GameMakerEngine Please make a Tutorial about Resolution and how to debug in not fullscreen but have to viewport set to 1920x1080 and so on

  • @kaspinator5265
    @kaspinator5265 6 месяцев назад

    After saving the game to save.txt the JSON viewer complains that there is an unknown character at the end of the file. I manually removed it (it was not visible, as pressing backspace once made no visible changes to the file), and it now works. But after saving again I get the same error. Does anyone know why?
    Here is the error:
    Expecting 'EOF', '}', ',', ']', got 'undefined'

  • @_FurryOwO_
    @_FurryOwO_ 6 месяцев назад

    Добавьте это как отдельную функцию
    Типа save() и load()
    И что бы это работало как например в Rpg Maker, там сохранения просто сохраняют ВООБЩЕ ВСЕ об игре, каждую переменную, положения персонажей, итд
    Это было бы очень круто >w

  • @genyaarikado1778
    @genyaarikado1778 10 месяцев назад +2

    I'm getting the error or when trying to create the instance during loading

    • @genyaarikado1778
      @genyaarikado1778 10 месяцев назад +2

      nvm i figured it out, the problem was cause i didn't save the x and y values for all objects, so when recreating them it gave an error. you need to save at least the x, y, and layer values for all objects if you plant to use them when creating the instance

    • @genyaarikado1778
      @genyaarikado1778 10 месяцев назад +1

      Now I'm having a new problem, because the struct variables are set before the instances creation code is ran, after the loading is finished, the creation code for my objects runs and sets the variables back to 0

    • @genyaarikado1778
      @genyaarikado1778 10 месяцев назад +1

      Fixed this by setting the variables in the variable definitions instead of the create event

    • @wizeller5040
      @wizeller5040 5 месяцев назад

      @@genyaarikado1778 I am having the same problem. What do you mean by setting the variables in the variable defenitions? In my create event I set all of my global variables. global.strength = 0;, global.speed = 0 etc. But then the struct wants these variables before the create event???!!! Jesus Christ

    • @Neovoid303
      @Neovoid303 4 месяца назад

      @@wizeller5040 All my variables are created when I start my game and the object is deleted and I save once you get in the game so the variables have been set

  • @Bretthejet
    @Bretthejet 9 месяцев назад

    I started the tutorial and 2 minutes in it isn't doing ANYTHING when i press S, I thought that i would go ahead and download the project to see what I was doing wrong and when i opened it up and pressed S, it also didn't work there??? really confused at the moment, and I would appreciate some feedback

    • @GameMakerEngine
      @GameMakerEngine  9 месяцев назад

      Hey Brett :). The best place to go for help is the GM community forum or Discord
      Forum: forum.gamemaker.io/index.php
      Discord: discord.com/invite/gamemaker

  • @phaseluv
    @phaseluv 4 месяца назад

    for some reason i can't load the save file from a title menu, how do i implement that

    • @phaseluv
      @phaseluv 4 месяца назад

      i want to be able to save the game somewhere and load at that point where i saved when i resume the game in the menu

  • @Exoudar
    @Exoudar Месяц назад +1

    I appreciate the tutorial. However, at 6:20 this is not correct. The variables in Create event will still override the ones in the struct. The solution would be to use something like with(instance_create........) and then inside that with you would add every single variables hp = _struct.hp....
    I made sure the variables in my save file is exactly the same as the one in object create event. But the information giving here is simply wrong.

    • @lebobshark
      @lebobshark Месяц назад

      Thank you. I'm lucky you posted this only 2 days ago.

    • @boomgoesthedynamite69
      @boomgoesthedynamite69 Месяц назад

      much better solution is to set these variables using the Variables Definition tab, since passing in a struct runs after these are set

    • @Exoudar
      @Exoudar Месяц назад

      @@boomgoesthedynamite69 That is one solution true. There is another I prefer more which is self[$ "hp"] ??= 100; When creating a new instance it would take the 100 value. However, when creating it using the struct, it would take the struct value. In other word, as long as hp is undefined during the create event, it will take 100. Otherwise, take the assigned value from any other source.
      Variables Definition for me is "not part" of the code. Hence, I prefer not to use it. But thank you anyway.

  • @Mellowpeekos
    @Mellowpeekos 9 месяцев назад

    How would you delete a save file as a option

    • @Pienotpi
      @Pienotpi 8 месяцев назад

      I think you would have to use some code that just deletes the file from your computer. Google it probably tho

  • @dXXPacmanXXb
    @dXXPacmanXXb Год назад

    9:36 dont u have to use is_undefined?

    • @gnysek
      @gnysek Год назад

      No, both should work.

  • @ErnestoChe-z1q
    @ErnestoChe-z1q Год назад +1

    Good tutorial. Just a question: How to encrypt the data? As far as I know, the player can simply access the saved data and modify it. Is there any solution for it?

    • @ToadstedCroaks
      @ToadstedCroaks Год назад +2

      Maybe just let the player have access to it?
      Unless you are trying to protect an online multiplayer experience, it's actually monumentally frustrating when developers try to obfuscate / encrypt data from the end user. It means they don't have agency for their product that they paid for, and they can't fix issues on their end that the developer hasn't gotten around to fixing on their end .. or maybe never will.
      Imagine not being able to reset a bugged quest flag because the developer doesn't trust you with your purchase; or some sort of purity decision. Forget trying to mod the game for your own enjoyment.

  • @DIRD-nz8qw
    @DIRD-nz8qw Год назад

    i use visual how will i do

    • @pzaan
      @pzaan Год назад +2

      Consider adding a function block and adding the code from the tutorial there. The rest of your project stays in Visual and you get to dip your toe into GML.

  • @kiber_pivowar
    @kiber_pivowar Год назад

    How can i make mobile game without purchasing 70$ bundle?

    • @kiber_pivowar
      @kiber_pivowar Год назад

      Its not for the commercial use, i cant give so much money just for 1 game

    • @GameMakerEngine
      @GameMakerEngine  Год назад +1

      @@kiber_pivowar GameMaker exports are now free! From today :)
      * ruclips.net/user/shortstmejf5Zvupk?feature=shared
      * gamemaker.io/en/blog/gamemaker-free-platforms

  • @xulld._.4983
    @xulld._.4983 5 месяцев назад

    For some reason my saved data is in chineese

    • @wizeller5040
      @wizeller5040 5 месяцев назад

      haha I wish I had that problem.

  • @fierorecensione5828
    @fierorecensione5828 Год назад

    top!

  • @tctrax
    @tctrax 6 месяцев назад

    for some reason, when following this, I was not able to correctly load variables (they are saving correctly but do not reflect or update).