Full Saving and Loading Tutorial in GMS2! (Part 1 of 2 - Room Saving)

Поділитися
Вставка
  • Опубліковано 21 жов 2024

КОМЕНТАРІ • 106

  • @CoffeeAI201
    @CoffeeAI201 2 роки тому +27

    The fact that you showed a 2nd, more complex item to save took this tutorial from being just another basic UA-cam tutorial to being a really strong foundation for a lot us beginner devs to build off of. Thanks so much.

  • @kittycitykat
    @kittycitykat Рік тому +2

    the sigh in the beginning felt too relatable

  • @hundredfive
    @hundredfive 2 роки тому +25

    you sir are a godsend, you restored all my previous knowledge on GML from years ago, in a much better way too. great work, and thank you!

  • @sabri8937
    @sabri8937 2 роки тому +19

    Amazing as usual, so useful !! Can't wait for the next and hopefully someday a battle system tutorial, it would be amazing :)

    • @peytonburnham4316
      @peytonburnham4316  2 роки тому +7

      Will do for sure! It'll be a long video to make so I have to have a bit of free time!

  • @Nullfighter
    @Nullfighter 2 роки тому +7

    I have moved to Unity since subscribing to you but I don't want to unsub because you seem like a dope person and your tutorials are both fun and informative. Keep up the good work homie.

    • @peytonburnham4316
      @peytonburnham4316  2 роки тому +6

      Thanks haha! That’s super nice of you! Good luck with everything you’re working on!

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

    3:37 End of Intro/Demonstration

  • @gaelanwort1202
    @gaelanwort1202 2 роки тому +6

    Odin, Izanagi and every other badass deity bless this channel - I have never encountered more helpful tutorials than yours, Peyton! Not just game coding, but in general! Somehow answering all my questions specifically, concisely, and making the videos ENJOYABLE to boot! Looking forward to more tutorials :))

  • @itsnateyboy
    @itsnateyboy 2 роки тому +3

    oh my god he's BACK BABY!

  • @NUGGet-3562
    @NUGGet-3562 2 роки тому +2

    Very informative! This was super helpful and even had a little bit of humor which I appreciated. Can't wait to watch more tutorials! I noticed in my recommended that you also have a tutorial for menuing which is something I've been wanting to do!

  • @BritBox777
    @BritBox777 2 роки тому

    Damn, just one week after I build my own multi save system, this drops. Would have saved me some brain ache!

  • @laskillersmos36
    @laskillersmos36 2 роки тому +3

    First time on your channel, just an amazing videos, I literally never comment a video nor like, but u deserve it. Thank you.

  • @KokomiFish0
    @KokomiFish0 3 місяці тому +2

    I know this may be a little late, but i've followed your video on how to create an inventory system. The thing is, i can't get this method to work with the "overworld item" that we created in that video. there is no error at all, the items just reappear when i go back when their not supposed to. Can you perchance help me or give me a hint on how i can possibly solve this issue?

  • @starryart2429
    @starryart2429 2 роки тому +3

    For anyone wondering the code can be simplified further by having instance_find be a parent object to all saveable objects, and having a variable within the room structure data array set to _inst.object_index, then calling it as the object when reloading the room! As seen in the video, this can also be used to save the state of the objects in the room as well, like if you want corpses or parts or whatever still left over! Also HP, effects, anything as long as its within the parent object!

  • @studentesso
    @studentesso Рік тому +1

    i followed this tutorial step by step but somehow the save function doens't save a struct, when the load fuction is performed it immediately exit it (because the _roomStruct isn't a struct),, what am I doing wrong?

  • @kingenderraptor
    @kingenderraptor 2 роки тому +10

    I feel there's a way to automate it even further when it comes to the rooms, perhaps a means of setting it so that if the instance is greater than 0 within a certain room it automatically adds that room to the _roomStruct, I shall experiment and return in the future with my findings.

    • @artorias-24
      @artorias-24 9 місяців тому

      Have you returned with your findings yet?

  • @Etsa
    @Etsa 2 роки тому +2

    How would I save the array that is my item inventory from the other video?

  • @elementz301
    @elementz301 Рік тому +3

    Thank you for the video, very helpful. Although I think I will need to automate the roomStruct stuff instead of manually writing in each room name for dozens of rooms
    Edit: did so using struct set and struct get:
    //save
    struct_set(global.levelData, room_get_name(room) + "Data", _roomData);
    //load
    _roomData = struct_get(global.levelData, room_get_name(room) + "Data");
    also nice because struct set creates the new variable if it doesn't already exist. So you don't need to list all room names in the
    levelData struct

    • @w3irllomusic
      @w3irllomusic 9 місяців тому

      I have to do something in the create event?

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

      what is your _roomData?

  • @NoLongerTwee
    @NoLongerTwee 2 роки тому +3

    Ah!!! Perfect Timing!

  • @Seabr0ok
    @Seabr0ok Рік тому

    Great tutorial, this worked so well!! thanks so much for running through it :)

  • @StompaJay
    @StompaJay 2 роки тому +3

    LETS GOOO PEYTONN!!!

  • @gassashadow1930
    @gassashadow1930 6 місяців тому +1

    How can I fix the following error?
    I32 argument is array
    at gml_Object_obj_item_overworld_Create_0 (line 3) - item = global.item_list.vegMegaBurger;//;
    ############################################################################################
    gml_Object_obj_item_overworld_Create_0 (line 3)

  • @giu0014
    @giu0014 2 роки тому

    Great video! I’ll take on the next one sometime soon

  • @patriciaduffy2479
    @patriciaduffy2479 2 роки тому +2

    Thanks so much for this tutorial! You really made this easy and understandable! I really appreciate this. Thanks again!

  • @olavman88
    @olavman88 Рік тому +1

    You have such great videos 🙂 why is it that you use curly brackets after if statements?

  • @SusieUndertale
    @SusieUndertale Рік тому +3

    You don't have to type out the name of every single room to include it in the struct. Here's what I did in my SaveLoad object Create event:
    global.LEVEL_DATA =
    {

    }
    for (var i = room_first; i

    • @SusieUndertale
      @SusieUndertale Рік тому

      The applause at 22:35 killed me btw lmao, great tutorial, thanks for this

    • @w3irllomusic
      @w3irllomusic 9 місяців тому

      and in the functions script what I do? (im dumb

  • @peegion4742
    @peegion4742 11 місяців тому +1

    Why on earth are you not using a with() statement at 13:52?
    You can use with to target all instances and just count a local var up each time to use as the array accessor

  • @AudioBombStudios
    @AudioBombStudios 2 роки тому

    This video helped me a lot! Thank you very much!

  • @peeposki
    @peeposki 2 роки тому +5

    eppiiic, tho when are ya guna make a battle system tutoriaall

    • @peytonburnham4316
      @peytonburnham4316  2 роки тому +6

      Battle systems are a pretty tall order so it'll be a little while, but I'll definitely do one!

    • @peeposki
      @peeposki 2 роки тому

      @@peytonburnham4316 ayyyyyyy epicc it'd be cool if u could show how todo battle systems that aren jus "attack, u lose health, u win" instead like makin stuff like Mario & Luigi or Undertale for example

    • @starryart2429
      @starryart2429 2 роки тому

      You could make use of state machines and irandom_range(1,(whatever different types of attacks you want)) like
      If enemyturn{
      Var Emoveused = irandom_range(1,3)
      switch emoveused {
      case 1:
      do whatever
      break;
      case 2:
      do something else
      break;
      case 3:
      big scary attack
      break;
      }
      }
      And have those random moves be something the player can interact with like undertale by having a “player_move_in_enemy_state” where it could be a smaller timing based mini game or something. Hope this helps!

  • @Livonade
    @Livonade 2 роки тому +9

    Hey Peyton, Nice video! However I am having a problem with using this system with the inventory system you made a few months ago. I have the load and save set to check for the item= but the game crashes with an error saying the argument is an array. I would appreciate help because my brain is fizzled.

    • @jamesbb4448
      @jamesbb4448 2 роки тому +7

      Hey, pretty sure I was having the same issue.
      Try switching "global.item_item_list = array_create(0);"
      to "oItemManager.item_item_list = array_create(0);" in the create event for oSaveLoad.
      Your names are probably different than mine, but you get the idea

    • @Livonade
      @Livonade 2 роки тому +3

      @@jamesbb4448 Thanks! I tried it and it worked like a charm. I'm really glad people like you are always here to help!

  • @jamesbb4448
    @jamesbb4448 2 роки тому +5

    Great tutorial, and it works for my coin system, but I cannot for the life of me get it to work with the inventory system from your previous tutorial. Does anyone know how to implement it?

    • @gassashadow1930
      @gassashadow1930 6 місяців тому

      Were you able to save the items with the old method?

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

      this is exactly mu issue! been trying to fix it for days now, and i'm empty handed :o

  • @dub1400
    @dub1400 2 роки тому

    Is there any way to bypass persistent instances when loading rooms? I've tried to solve this for a while but haven't come up with anything that works well

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

    so, ive gotten this all to work so far... except for the item image saving. i used your previous tutorial videos, and the way you made the item and had it set the sprite doesnt work with this video's method of saving the sprite. and the way you have the item calling its sprite is different enough that idk what else you did ( complete beginner). so could you either explain the newer item method or a different way to save the item image?

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

      upon changing rooms, the instance creation code for setting what the overworld object is, seems to be being ignored, and only the creation code's
      item = global.item_list.small_potion;
      seems to be accepted by the step event's
      sprite_index = item.menu_sprite;
      i would like to have some of my ground items be able to animate, so i dont want to throw them all in 1 sprite

    • @gassashadow1930
      @gassashadow1930 6 місяців тому

      ​@@lloyd011721Were you able to save the items with the old method?

    • @lloyd011721
      @lloyd011721 6 місяців тому

      @@gassashadow1930 what old method?

  • @josefshutrick8224
    @josefshutrick8224 10 місяців тому

    Question: How would one setup an automatic room save system where you don't have to assign every single room consecutively? Rather using an array of some kind. While I really appreciate the help the video has given, I do feel the room system isn't very practical

  • @Moxadonis
    @Moxadonis Рік тому

    What about if you have gates with certain instance ID's. I'm working with the Heroes Trail tutorial to learn. Everything works besides the gates opening when I load.

  • @giu0014
    @giu0014 2 роки тому +1

    23:48 I don't understand why we set the image speed to 0 in the alarm instead of doing it in the create event, when i put image_speed = 0 in the alarm, by the time the speed gets set to zero , the sprite image_index becomes 1.5 and the code in the alarm which checks for the image_index to be == to 1 doesn't work. Setting the image speed to 0 in the create event fixes this problem but I would like to understand why this works in your case.

    • @peytonburnham4316
      @peytonburnham4316  2 роки тому +2

      Oh good point and good question! Pretty sure I also have the image speed set to 0 in the actual sprite as well, so it wasn't animating in the first place and I just overlooked that fact. adding the "image_speed = 0" was just kind of a logical clean up to me but actually i dont think it makes much sense lmao!!
      Generally I would just set image speed to 0 in the sprite editor, but you could also set it in the create. OR you could do it the same way as in the video but instead of checking like "if image_index == 1" you could check "if floor(image_index) == 1" and it would work fine.
      Good catch!

  • @sniffsy
    @sniffsy 2 роки тому

    so, im starting a game and i would like to know, should i make the save and loading feature at the start of development or near the end or development?

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

    I followed this to the T but with enemies instead of coins, and for some reason it’s not working at all?

  • @weltonn
    @weltonn 2 роки тому +2

    THANK YOUU!!

  • @evanmg3338
    @evanmg3338 6 місяців тому

    Would anyone happen to know on how to reset these structs and arrays. Like a room reset.

  • @Corilo91
    @Corilo91 2 роки тому +1

    Thanks!

  • @NUGGet-3562
    @NUGGet-3562 2 роки тому

    19:25 what if you just put it on the layer it's supposed to be? Like if you know coins just go on the Coin layer, couldn't you just say to put it on "Coins" instead of layer?

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

    how can I access the left coin number in a room?

  • @jakehopper5204
    @jakehopper5204 2 роки тому

    Hey how are we about going on altering this code for our own projects that we release. Like how do you want to be credited.

  • @PhantomTaxi6947
    @PhantomTaxi6947 2 місяці тому

    Whats in the step event of obj_item?

  • @obamacat3
    @obamacat3 Рік тому

    I tried making my own system from scratch with buffers but it had some erros and i couldnt find a way to save room data but i did make it fully automatic and as many save slots as i want

  • @sheeplavender3261
    @sheeplavender3261 Рік тому

    Very important question. If I were to port this to html5, I would need to use ini. files instead right. How would I be able to do that?

    • @sheeplavender3261
      @sheeplavender3261 Рік тому

      I wanted to give it a try but I ended up getting so many issues and it's virtually impossible to troubleshoot since you don't get any error messages when it crashes. If you know of any solutions please let me know. i really like this format of save/load room/game, id appreciate the help

  • @questionm521
    @questionm521 2 роки тому

    could u make a tutorial on manipulating variables in order to get different endings in a game?

  • @micyoz5283
    @micyoz5283 2 роки тому +3

    Oh my god

  • @vrtexxradiation
    @vrtexxradiation 11 місяців тому

    Hey there, Peyton! I've seen your RPG videos, and they are real helpful! However, I want my character to go to a SAVEPOINT and save the game from that. How can I do it?

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

      create an obj_savepoint and then stick some save code into it that brings up a menu when you interact with it. or an if statement that allows you to open your menu and access the save function when touching obj savepoint.

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

      @@lloyd011721 thanks

  • @orangeyeez
    @orangeyeez 2 роки тому +2

    epic yes

  • @fierorecensione5828
    @fierorecensione5828 Рік тому

    thank you !

  • @chimichanga673
    @chimichanga673 Рік тому

    Could anyone help me on what tutorial to do first? Because this seems.... weird.

    • @remixtrick
      @remixtrick 6 місяців тому +1

      You should start with his How to Make an RPG series

  • @Pika782
    @Pika782 2 роки тому +1

    timestamp for me:
    12:46

  • @adenpun
    @adenpun 2 роки тому

    How to make a character following you?
    And i love your video❤

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

    same error here
    ############################################################################################
    ERROR in
    action number 1
    of Step Event0
    for object _ob_saveload:
    I32 argument is array
    at gml_Script_load_room (line 54) -

  • @yolodragoon5219
    @yolodragoon5219 2 роки тому

    Bump the Algorithm !

  • @BossAleks123
    @BossAleks123 2 роки тому +1

    ou hello!

  • @bardano_intimo
    @bardano_intimo 2 роки тому +1

    innit

  • @elartistadelligue786
    @elartistadelligue786 Рік тому

    at least can you provide the source code?

    • @remixtrick
      @remixtrick 6 місяців тому +1

      you can get the source code for any tutorial from Peyton's partreon. It's in the video's description

  • @saxenart
    @saxenart Рік тому

    What does “var” mean?

    • @hyphen_tv
      @hyphen_tv Рік тому +1

      variable.
      In GameMaker you use it to set local variables

    • @remixtrick
      @remixtrick 6 місяців тому +1

      A Local variable is a variable that can only be called in the object/script that you created it in.
      It looks like this:
      var _thisIsALocalVariable = 9+10;
      A GLOBAL variable is a variable that can be called anywhere, reguardless of where it was created. However, these kinds of variables are harder to run for your machine and can cause conflicts if they overlap, so use them sparingly.
      They look like this:
      global.ThisIsAGlobalVariable = 21;
      You can also call variables that you've created in other objects (like your player's hp) like this:
      if oPlayer.hp == 0 { instance_destroy(); }

  • @GabrielRodrigues-do9rg
    @GabrielRodrigues-do9rg 2 місяці тому

    14:12

  • @carlwood6142
    @carlwood6142 2 роки тому

    promosm

  • @bobmaulei8101
    @bobmaulei8101 2 роки тому

    EXPLAIN IT BETTER

  • @bobmaulei8101
    @bobmaulei8101 2 роки тому

    DONT WORKS

  • @KohniHart
    @KohniHart Рік тому

    a 2 minute long intro, i already know the rest of the video is not worth watching!!!

  • @hyphen_tv
    @hyphen_tv Рік тому

    so I've been getting this error and I've tried fixing it but nothing works. Any ideas?
    " Variable saves.obj_coin(100056, -2147483648) not set before reading it.
    at gml_Script_save_room (line 264) - var _coinNum = instance_number(obj_coin); "
    I've gone through the video 4 times and as far as I'm concerned, I've written everything exactly as shown in the video.
    What am I doing wrong?

    • @_bubblezzzzzz_
      @_bubblezzzzzz_ Рік тому +2

      20:43 in Room Start event there was an error it was typed load_game(); then at 20:53 it shows load_room();
      it should be load_room, not sure if this has anything to do with your issue just noticed it.