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

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

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

  • @CoffeeAI201
    @CoffeeAI201 2 года назад +31

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

  • @remixtrick
    @remixtrick 8 месяцев назад +2

    3:37 End of Intro/Demonstration

  • @hundredfive
    @hundredfive 2 года назад +26

    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!

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

    the sigh in the beginning felt too relatable

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

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

  • @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 :))

  • @peegion4742
    @peegion4742 Год назад +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

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

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

  • @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 года назад +3

      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!

  • @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 8 месяцев назад

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

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

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

  • @itsnateyboy
    @itsnateyboy 2 года назад +3

    oh my god he's BACK BABY!

  • @nomeos01
    @nomeos01 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.

  • @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 11 месяцев назад

      Have you returned with your findings yet?

  • @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 11 месяцев назад

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

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

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

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

  • @BritBox777
    @BritBox777 2 года назад

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

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

  • @lloyd011721
    @lloyd011721 9 месяцев назад +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 9 месяцев назад +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 8 месяцев назад

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

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

      @@gassashadow1930 what old method?

  • @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 11 месяцев назад

      I have to do something in the create event?

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

      what is your _roomData?

  • @giu0014
    @giu0014 2 года назад

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

  • @KokomiFish0
    @KokomiFish0 5 месяцев назад +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?

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

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

  • @gassashadow1930
    @gassashadow1930 8 месяцев назад +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)

  • @NoLongerTwee
    @NoLongerTwee 2 года назад +3

    Ah!!! Perfect Timing!

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

  • @patriciaduffy2479
    @patriciaduffy2479 2 года назад +2

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

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

  • @AudioBombStudios
    @AudioBombStudios 2 года назад

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

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

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

    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.

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

    Whats in the step event of obj_item?

  • @Pika782
    @Pika782 2 года назад +1

    timestamp for me:
    12:46

  • @questionm521
    @questionm521 2 года назад

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

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

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

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

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

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

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

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

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

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

  • @sooperjay
    @sooperjay 2 года назад +3

    LETS GOOO PEYTONN!!!

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

    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 9 месяцев назад

      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 9 месяцев назад

      @@lloyd011721 thanks

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

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

    • @remixtrick
      @remixtrick 8 месяцев назад +1

      You should start with his How to Make an RPG series

  • @sheeplavender3261
    @sheeplavender3261 2 года назад

    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 2 года назад

      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

  • @weltonn
    @weltonn 2 года назад +2

    THANK YOUU!!

  • @adenpun
    @adenpun 2 года назад

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

  • @micyoz5283
    @micyoz5283 2 года назад +3

    Oh my god

  • @Corilo91
    @Corilo91 2 года назад +1

    Thanks!

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

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

  • @orangeyeez
    @orangeyeez 2 года назад +2

    epic yes

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

    thank you !

  • @GabrielRodrigues-do9rg
    @GabrielRodrigues-do9rg 4 месяца назад

    14:12

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

    at least can you provide the source code?

    • @remixtrick
      @remixtrick 8 месяцев назад +1

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

  • @BossAleks123
    @BossAleks123 2 года назад +1

    ou hello!

  • @saxenart
    @saxenart 2 года назад

    What does “var” mean?

    • @hyphen_tv
      @hyphen_tv 2 года назад +1

      variable.
      In GameMaker you use it to set local variables

    • @remixtrick
      @remixtrick 8 месяцев назад +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(); }

  • @yolodragoon5219
    @yolodragoon5219 2 года назад

    Bump the Algorithm !

  • @bardano_intimo
    @bardano_intimo 2 года назад +1

    innit

  • @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 2 года назад

    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.