How to Make a Save and Load System in GameMaker

Поділитися
Вставка
  • Опубліковано 30 жов 2023
  • In this GameMaker tutorial learn how to code a save and load system into GameMaker. It will work with any game.
    You'll learn how to implement:
    * Writing and reading variables as text files
    * Using structs & JSON
    * Saving and loading multiple objects / rooms
    * Using buffers
    Big thank you to Josia for the tutorial: / w7games
    👉 Download the GameMaker project: yoyo-www-cms.s3.amazonaws.com...
    What is GameMaker? 👀
    -----------------------------------------------------
    GameMaker is the industry’s premier 2D game engine, used by thousands of developers every day to create indie gaming classics like Undertale, Hyper Light Drifter, and Chicory: A Colorful Tale.
    It’s completely free to download and keep forever, with dozens of written guides and video tutorials to help you bring your games to life.
    When your project is complete, you can publish your creations to all major platforms, including PlayStation 5, Xbox Series X|S, and Nintendo Switch.
    👉 Get GameMaker: opr.as/DownloadGM-YT
  • Ігри

КОМЕНТАРІ • 57

  • @GameMakerEngine
    @GameMakerEngine  8 місяців тому +4

    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 7 місяців тому +11

    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!

  • @pzaan
    @pzaan 7 місяців тому +8

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

  • @Widestone001
    @Widestone001 8 місяців тому +9

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

  • @asamadoCH
    @asamadoCH 4 місяці тому +4

    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.

  • @evaisotalo3386
    @evaisotalo3386 17 днів тому

    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. 🤗

  • @marcussmithwick6326
    @marcussmithwick6326 5 місяців тому +1

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

  • @geostargames
    @geostargames 8 місяців тому +3

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

  • @svenjorgensen5
    @svenjorgensen5 6 місяців тому +7

    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 5 місяців тому

      Hey did you find out how to do it?

    • @svenjorgensen5
      @svenjorgensen5 5 місяців тому +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.

    • @user-uy8od4vj9c
      @user-uy8od4vj9c 4 місяці тому

      ​@@svenjorgensen5it used to be built in.

    • @svenjorgensen5
      @svenjorgensen5 4 місяці тому +1

      @@user-uy8od4vj9c 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.

  • @Palpus_X
    @Palpus_X 2 місяці тому +1

    My god the pacing is PERFECT. Thank you for this

  • @tokensgaming
    @tokensgaming 4 місяці тому +3

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

  • @pinatranaves
    @pinatranaves 8 місяців тому +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 7 місяців тому +7

      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 20 днів тому +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.

  • @dylanmuss2052
    @dylanmuss2052 6 місяців тому +2

    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.

  • @christopherorestis6906
    @christopherorestis6906 2 місяці тому +4

    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).

  • @_FurryOwO_
    @_FurryOwO_ Місяць тому

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

  • @LPmcGamer
    @LPmcGamer 7 місяців тому

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

  • @ajejebrazord4068
    @ajejebrazord4068 4 місяці тому +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  4 місяці тому +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

  • @kaspinator5265
    @kaspinator5265 Місяць тому

    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?

  • @kaspinator5265
    @kaspinator5265 Місяць тому

    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'

  • @Bretthejet
    @Bretthejet 4 місяці тому

    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  4 місяці тому

      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

  • @tctrax
    @tctrax Місяць тому

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

  • @IamNeptunus
    @IamNeptunus 5 місяців тому +1

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

    • @GameMakerEngine
      @GameMakerEngine  5 місяців тому +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 5 місяців тому +1

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

    • @IamNeptunus
      @IamNeptunus 5 місяців тому

      @@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 2 місяці тому

      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.

  • @dXXPacmanXXb
    @dXXPacmanXXb 8 місяців тому

    9:36 dont u have to use is_undefined?

    • @gnysek
      @gnysek 8 місяців тому

      No, both should work.

  • @genyaarikado1778
    @genyaarikado1778 5 місяців тому +1

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

    • @genyaarikado1778
      @genyaarikado1778 5 місяців тому +1

      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 5 місяців тому +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 5 місяців тому +1

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

    • @wizeller5040
      @wizeller5040 19 днів тому

      @@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

  • @user-rv2qf4pi3v
    @user-rv2qf4pi3v 8 місяців тому +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 7 місяців тому +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.

  • @Mellowpeekos
    @Mellowpeekos 4 місяці тому

    How would you delete a save file as a option

    • @Pienotpi
      @Pienotpi 3 місяці тому

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

  • @-Russian_Knight
    @-Russian_Knight 7 місяців тому +1

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

  • @DIRD-nz8qw
    @DIRD-nz8qw 8 місяців тому

    i use visual how will i do

    • @pzaan
      @pzaan 7 місяців тому +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 7 місяців тому

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

    • @kiber_pivowar
      @kiber_pivowar 7 місяців тому

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

    • @GameMakerEngine
      @GameMakerEngine  7 місяців тому +1

      @@kiber_pivowar GameMaker exports are now free! From today :)
      * ua-cam.com/users/shortstmejf5Zvupk?feature=shared
      * gamemaker.io/en/blog/gamemaker-free-platforms

  • @fierorecensione5828
    @fierorecensione5828 8 місяців тому

    top!

  • @xulld._.4983
    @xulld._.4983 21 день тому

    For some reason my saved data is in chineese

    • @wizeller5040
      @wizeller5040 19 днів тому

      haha I wish I had that problem.