GameMaker - Better Saving & Loading (JSON)

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

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

  • @SaraSpalding
    @SaraSpalding  4 года назад +6

    IMPORTANT: I have made a new, updated version of this video for version 2.3.1+ using structs and arrays! ruclips.net/video/R84mR52QaMg/видео.html

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

    I dont know anything about to save data in JSON files but Im here learning a lot, although there is another and updated tutorial. I´ll watch after this one of here.

  • @illdie314
    @illdie314 6 лет назад +38

    The vertical line symbol above the backslash is called a pipe.

  • @DarkKnightDad
    @DarkKnightDad 6 лет назад +7

    thank you soo much for your video, you cannot imagine how elegant is the loading/saving thanks to this code. I even extended the code so that I save game variables (in a map) and inventory list (in a list) and enemies locations and types (in a map within a list, like what you did) and finally the whole thing in one big wrapper map ^____^

  • @JohnDoeagtfdyutasgdjak
    @JohnDoeagtfdyutasgdjak 6 лет назад +51

    You should make an online multiplayer tutorial! There aren't many Game Maker tutorials out there that cover the subject (not to mention effectively, or completely), and I feel like you could make an effective tutorial. Not only that but the Game Maker community for both GMS1 and 2 would benefit as a whole. I've been watching your tutorials for a few years now, and I would definitely want to see this!

    • @AurrenTV
      @AurrenTV 6 лет назад +6

      The problem with online multiplayer is that it exceeds game maker itself. Sure you could set up clients ready for playing multiplayer but the networking solutions would need to be done outside Game Maker and would involve the use of networking knowledge as well as money to set up the infrastructure (servers) even if you plan on peer to peer you still need hole punching servers.
      LAN however is easily possible and it is easily found on the internet for GMS2/GMS1.4 but it isn't online multiplayer

    • @AurrenTV
      @AurrenTV 6 лет назад +3

      Getting everyone to port forward their router is a terrible idea for a commercial game, there would need to be some kind of server connect clients together using udp hole punching so people don't have to do that. (and that's just for peer to peer, not even touching on dedicated servers)

    • @AurrenTV
      @AurrenTV 6 лет назад +5

      Say you release a game on Steam (also for the purpose of your argument you're not using Steam's mediation server for peer to peer, and are just using GM's network functions.) It's a 4 player rogue-like (the most common kind of game for indie devs.) They want to play multiplayer together but before buying the game have no idea what port forwarding is let alone that this game needs it to function. They press host and get a nice prompt saying ("Please port forward ports xyz on your router.") the friends who aren't hosting are fine but 1 out of 4 people will still need to go through port forwarding, which is highly unprofessional. You'd see refunds from people saying the game is broken because you're expecting players to have networking knowledge.

    • @AurrenTV
      @AurrenTV 6 лет назад +3

      If you're talking about everybody (possibly thousands of players) connecting to a dedicated server made in game maker then yes, only one machine needs to have their connected router port forwarded but game maker wasn't designed to make dedicated server programs with: GM made games only run on a single core meaning there is no multi threading (something servers generally require, especially logic/ packet heavy game servers). I'm pretty sure I've read somewhere game maker networking fizzles out at sub-50 connected clients.
      Lol, I don't mean to be a contrarian, if that's how it comes off.

    • @sn4pi
      @sn4pi 4 года назад +2

      ​@@AurrenTV Well I made an Online Multiplay Shoot 'em Up for my class mates and me to play. Had an in-game lobby, fluid ping and worked really good as a whole. And I only needed Hamachi for it to work! In my opinion all is right what you say except the part "The problem with online multiplayer is that it exceeds game maker itself."
      I managed to do alot with GameMaker only, and simply buying a server or needing to pay for the sake of programming a game should be obvious beforehand and has nothing to do with GameMaker itself. You could say the same things for Unity or UnrealEngine in terms of Online Multiplayer therefore it makes no sense to say that GameMaker can't come up with good-enough networking solutions. I mean I even amde a voice-chat through GM Networking ^^

  • @checkbox.entertainment
    @checkbox.entertainment 6 лет назад +3

    It's about time a good tutorial is released about saving that isn't using ini files! Ini files can get corrupted quite easily.

  • @alexmagnus3339
    @alexmagnus3339 6 лет назад +1

    You posted this video just as I wanted to make saving enemy locations and your location in "Your First Platformer" possible!

    • @andre_4046
      @andre_4046 6 лет назад

      did it work for you? cuz i have alot of rooms and it won't load the enemies correctly for me(they are always at full hp and at the same position)

  • @animaitor99
    @animaitor99 4 года назад

    I have been doing this list in a map with list thing in my game and didnt even know i could save it all into a JSON . Thx
    Also i came here after your brief explanation you did when building your game for Ludum Dare 47.

  • @jealouscrow4593
    @jealouscrow4593 6 лет назад +6

    Perfect. Was wondering when a full tutorial on this would be made.

  • @owenbevt3
    @owenbevt3 6 лет назад +3

    Thanks for a tutorial on this I can follow. I do think Game Maker could make this all so much simpler they seem to have compleatly droped to ball on there usual ethos of making everthing very accessable when it comes to saving.

  • @jorgemuffareg7146
    @jorgemuffareg7146 5 лет назад +3

    Thank you! I know it's a simple solution and me as a developer should know this but... you saved me!

  • @craigrobishaw9796
    @craigrobishaw9796 3 года назад

    Really useful video. exactly what I needed mate. many thanks for sharing

  • @soubakouh
    @soubakouh 4 года назад +5

    INCREDIBLE!! you save me :'D

  • @ion2618
    @ion2618 4 года назад +6

    I was wondering if you could make a tutorial for how to use this with the Action RPG?

  • @giankeberlein8648
    @giankeberlein8648 5 лет назад +2

    Hey man I really like your tutorials and find them very useful! I could not be more thankful. Unfortunately, I would like to ask you a question about this one because I didn't get it very clear.
    So the question is: if i want to add another map/list inside the root list just to have, for example, a map for keys data and a map for enemies data. When "adding" it to the root list, in the "ds_list_mark_as_map" function, should I still reference the position to be listed as "ds_list_size -1"? I mean, would it still be listed correctly?

  • @biddumtv3663
    @biddumtv3663 6 лет назад +4

    Great tutorial! Say I have a persistent object, obj_controller that creates global variables for my game. Would I save that instance and its attributes (like how you did with x,y,sprite,etc..) and then load them into the game or should I create a new key-value pair in the ds_map and save/load that way?

  • @mahmoud.zayedd
    @mahmoud.zayedd 6 лет назад

    Owsome 👌

  • @jack5590
    @jack5590 6 лет назад +1

    Love your videos. The key you referred to is called the pipe or bar key.

  • @benanderson89
    @benanderson89 5 лет назад +1

    I'm brand new to GML (though already a professional software dev) and saving content from my little demo GML projects has been the worst part of any of them. This seems a nice method, and JSON is a dirt simple format to work with. I'll be sure to give this a whirl when I can. :)
    Though, rather than character/string data and expensive JSON processing, could a method similar to this save raw byte data to disk? It'd effectively be a memory dump stored as a map or tree.
    Just two points in the video that I think need a bit of clarification:
    15:00 Compatibility isn't the reason to use a buffer. Buffers are sequential data held in a temporary portion of memory. A storage device (like an SSD) is slower than RAMs, o you create a buffer for the disk to read at it's own pace, rather than sending chunks of data to the disk and waiting for said chunk to complete it's read or write operation before sending another. Buffers are more complicated to write in a high level language, but more performant since it's actually simpler to implement under the skin; there's less obfuscation with how a computer actually works.
    21:08 It's just called the Vertical Bar, but in computing it's more commonly refereed to as the "Pipe" character because of it's association with the UNIX Pipeline. It's not to be confused with the broken bar ( ¦ ) which is AltGr + Grave Accent ( ` ) key on British keyboards.
    My nitpicking aside, great video! I'll try to use these techniques somewhere down the line. :)

    • @benanderson89
      @benanderson89 5 лет назад

      Also, hello from a fellow Northeasterner! :))

    • @landdweller9684
      @landdweller9684 5 лет назад

      @@benanderson89 Hello from Cumbria; I was hoping someone could answer a quick question I have on this subject, but can't find an answer. I would consider myself a beginner but have been using GameMaker studio and learning about computers for 2 decades.
      By using JSON to save game progress / variables and what not; Would this be the best method for my intended target which is HTML5, rendered in JavaScript? which should make this method work more natively?
      One thing I have noticed with HTML5 is some events appear to be getting read from right to left making the usual windows platform logic go out the window and I have to use alternative measures to achieve similar results.

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

    I did everything the same in the video, but now when I save and load the game, the player duplicates. In other words, one player remains as I saved, and the other reverts back to the beginning of the game. What should I do?

  • @owenbevt3
    @owenbevt3 6 лет назад +3

    how dose this work with different object types (with different variables)? sould each type get its own wrapper?

  • @BlueMiaou
    @BlueMiaou 5 лет назад +1

    Great tutorial! Definetly a life saver.

  • @jk-gn2fu
    @jk-gn2fu 6 лет назад

    A great example. I made very similar one before, but this example has a much cleaner codes than the one I made.

  • @andre_4046
    @andre_4046 6 лет назад +4

    so i have alot of rooms(i was following your tutorial shaun), in the save file i also put the room in which i am currently, but when i load it the enemies i killed are still there and alive(i did save their hp)
    can anyone help me please
    edit: instead of using a object i put the code in 2 scripts (loading and saving) don't know if that makes a big difference
    i need it to be in a script so that i can call it in my menu

  • @cervicesejvl6412
    @cervicesejvl6412 4 года назад

    This video is ONLY ONE THING I NEEEEEEEEED!!!!! :)

  • @Jt9393synyster
    @Jt9393synyster 4 года назад

    Thank you so much, Shaun.

  • @gotcowdota
    @gotcowdota 4 года назад +1

    If anybody else cannot find where GMS2 is saving your files, drop this code in just after your save. It will pop up the directory where files are being saved in a dialogue box when you run your game. You can then remove the code from your game once you've found the file.
    file_text_close(file_text_open_write("temp"))
    // opens and closes a temporary text file
    var r=filename_path("temp");
    // creates a temporary variable with the filepath for that file
    file_delete("temp"); // deletes that file
    show_message (string(r));
    // display a message with that file directory
    file_text_close(_file); // closes the file to prevent memory leak
    Don't leave this in your final game, obviously.

  • @dkrobinson1187
    @dkrobinson1187 6 лет назад +3

    This works very good! just one issue, when i create the .exe file and run it this feature stops working. any idea why?

  • @kupo150
    @kupo150 6 лет назад

    Perfect! Was hoping for this! Thank you!!!!!!!!!!!!!!!!!!!!!

  • @JordanM56
    @JordanM56 5 лет назад +3

    How can this be expanded to include multiple different types of objects all with different variables?

    • @jorgemuffareg7146
      @jorgemuffareg7146 5 лет назад +1

      @@karstenpedersen2132 nice! I think it would be interesting to use switch(_obj){ case: }

  • @tuliohenry5484
    @tuliohenry5484 5 лет назад +7

    I'm getting an error when i try to load my game from the beginning saying then the data structure doesn't exists, how can i fix this

    • @FoxyOfJungle
      @FoxyOfJungle 4 года назад

      Me too! Can someone help??

    • @dinar8749
      @dinar8749 4 года назад +2

      I don't know if this will help, but it works for me after much pain and suffering trying to get it working in the first place.
      For the loading, I had to make his load file script in the video that loads the buffer (for buffers, when it's numbers you're using use one of the buffer number ranges constants in the game maker manual, BUT if you're using text (string) then use buffer_string...this stumped me for ages since gamemaker kept saying "buffer out of range, going back to 0" and I couldn't find any guides).
      Then you wanna do some stuff like...
      //checks if file exists first (don't worry about name or "dat" that's just related to my game)
      "if (file_exists("XGA.SAVEFILE.dat"))
      {
      var _map_decoded = LoadJSONFromFile("XGA.SAVEFILE.dat")
      var list = ds_map_find_value(_map_decoded,"ROOT")

      var size = ds_list_size(list)
      //loops through whole ds list containing all the ds maps
      on each list part (I think?)
      for (var i = 0; i < size; i++)
      {
      var listvalue = ds_list_find_value(list,i)

      global.variable you want to change or whatever = ds_map_find_value(listvalue, key)
      Where "key" is whatever you set it to be when you saved your game using ds_maps beforehand.
      .....
      }
      Then you destroy the list and ds map to prevent a memory leak
      Hope this helps...even though it's over 6 bloody months ago 😂

    • @Will-ei2jz
      @Will-ei2jz 4 года назад

      Dinar 87 I’m having the same problem when I load my game: Illegal buffer index -1, obviously you wrote this a while back but I’m a little confused about how you fixed this issue?

  • @drtt1gg3r1
    @drtt1gg3r1 4 года назад +1

    I've seen this type of tutorial a couple of times from different YTbers. And the one thing that none of them show is saving objects that have lists/maps tied to their instances. They all say it can be done but none of them show it. Could you please give or show an example of saving/loading objects that have lists of other objects tied to them.
    EXAMPLE:
    In obj_player there is a variable that stores the id of another object; obj_inventory. obj_inventory is an object that stores a ds_list. In that ds_list is a bunch of instance id's of items the player is holding. How would you set this up for save/load?

    • @Karak-_-
      @Karak-_- 4 года назад

      Well, I would definetly *not* create inventory system based on instances in first place, that's for sure.
      I would asign a number to each type of item as an enum and then I would save in a ds_list or ds_map ids of items. Because in all honesy, instance id are "tempoary".

  • @trexie15
    @trexie15 3 года назад +1

    Can you make an tutorial here on RUclips where you show us how to save our game by clicking on an object?

  • @Leonardo-jk4wu
    @Leonardo-jk4wu 6 лет назад +4

    hey, could you make a tutorial for Google Play cloud integration and using?

    • @nathan08085
      @nathan08085 6 лет назад +2

      Leonardo007, you know that all topics are chosen by Shaun’s patrion by a vote. It isn’t too much; $5 ish dollars a month to vote.
      Try there. Not here

  • @ethanhopkinsmusic
    @ethanhopkinsmusic 4 года назад

    I have objects with different variables. Would I add a second "with statement" to include those other objects?

  • @adriancifersky791
    @adriancifersky791 5 лет назад +1

    Nice tutorial, you really help me with this but still a have one problem, I made platform game and when I tried load game nothing happend
    well first i screw up few details in code but i fix it immidiatly..

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

    What do I do if I want to add more things to a struct, but there is already a save file that doesn't have the new variables in the json file? How do I avoid the game crashing? This would be very important for if I were to publish to steam and need to update the game.

  • @cchhiipp
    @cchhiipp 6 лет назад +1

    How does one deal with saving objects with different attributes. For example a car object has speed, fuel, color. A robot has weapon strength, durability, etc. Do I need different parent SaveMe objects for each type of object, then a new with() statement for each object type? And how do I load the different types of objects in the load event?

    • @raspberry_picker395
      @raspberry_picker395 6 лет назад

      Same problem here. I have a game in which you pick your side, the player has levels xp and upgrades, there's 9 worlds and each has 5 levels, it's teritorry based, I wont get into the details of it. Basically there's a lot of very important stuff going on
      Juju Adams and Shaun both say this code is very flexible and I'm sure it is, but having to write lines for saving and loading for pretty much EVERYTHING just seems like a bad practice. Yes, you could say that I don't need everything saved, but yes, yes I do (atleast it seems like I do). Not sure how to do this properly, I've watched Jujus talk and they don't explain how to properly use it. I understand the code, they both explain it very well but I am not sure how to use it properly.

    • @Robotik_X
      @Robotik_X 6 лет назад

      You Would Put It In Front Of The Line Of Code, Let's Say We Are Using Jumps, if No Other Object Had It You would Put:
      with (Obj_Player) ds_map_add(_map,"jumps",jumps);

  • @eshels2288
    @eshels2288 3 года назад

    THX but what did you define in global.mystery
    ?

  • @JohnDoeagtfdyutasgdjak
    @JohnDoeagtfdyutasgdjak 6 лет назад +6

    how would I save multiple rooms?

    • @sylvyonosu9326
      @sylvyonosu9326 6 лет назад +1

      i wonder too

    • @sylvyonosu9326
      @sylvyonosu9326 6 лет назад

      Okay i figured out how, but it’d be hard to explain over youtube comments
      If you haven’t figured it out already, do you have discord? I can explain it there

    • @playmaker1633
      @playmaker1633 6 лет назад

      Hi, One of you can explain to me how you did ? it will really help me so much !!

    • @sylvyonosu9326
      @sylvyonosu9326 6 лет назад

      Romuald Henry do you have discord? I can explain it there easily

    • @playmaker1633
      @playmaker1633 6 лет назад

      @@sylvyonosu9326 Yes I have discord, but my oral comprehension in english is very bad :/

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

    I popped this video open because i was annoyed at how Game Maker’s native function ds_map_secure_save encrypts per device. I want to still be able to save data that can only be read by Game Maker when it loads, but not readable by a human. Essentially i want to have non-tamperable save data that i can move from machine to machine. Pardon this question but because the video is 30min long, i wanted to ask before i watched if it solves the problem i posed above. Thank you in advance.

  • @DitheryStudios
    @DitheryStudios 4 года назад

    How do I save and load a ds map? I have a minimap that relies on it, but cant figure it out...

  • @GnomeMadeGames
    @GnomeMadeGames 6 лет назад

    This was great help thanks.

  • @Limekys
    @Limekys 6 лет назад

    It hard for me, but very good tutorial of saving game! Thanks, i'll try to learn and will do it!

  • @DanBraithwaite
    @DanBraithwaite 6 лет назад +1

    This is a great video, Shaun, well put together and easy to follow. However it has a major flaw, in that you simply cannot guess for all of the variables which may or may not be present in all objects at any point in the game. You see I was able to save all of the variables to the .sav file using the VARIABLE_INSTANCE_GET_NAMES function within the code. This allowed me to store any data, regardless of the object and it's variables.
    Storing and saving works fine this way, I can see the data is present in the file. However your method doesn't seem to be able to pull the data out. You claim that this is more advanced than a simple text file however I still find myself having to list every possible variable at any given time, which is just not viable if you want to save the state of the game mid-battle, for example.

    • @zeldwaugh5703
      @zeldwaugh5703 5 лет назад

      I'm not too sure about this... but I think in your case maybe just creating global variables to check where in they game you are? Then just save those variables as strings like in this vid. Load them upon file selection. Adjust code accordingly to them? My two cents

  • @ikkiekcuriel4519
    @ikkiekcuriel4519 6 лет назад

    @Shaun Spalding Is there any way to store a ds_grid inside of a ds_list or ds_map? i've been struggling with this for a while

  • @lukehowe4188
    @lukehowe4188 5 лет назад

    Boys, For me the line of code SaveStringToFile just doesn't exist it comes up as a varibale any ideas?

  • @m1s3ry97
    @m1s3ry97 4 года назад

    Great tutorial! Is there any way to save a buffer inside an specific directory?

  • @Gngwro
    @Gngwro 6 лет назад +1

    When I try to recreate all of the objects in the With statement, I get an error on the object argument within instance_create_layer. Any advice?

    • @ichocksyololo445
      @ichocksyololo445 6 лет назад +1

      First make sure you are in GMS 2(GMS 1.x doesn't support that function, use instance_create instead).
      Could you please show how are you setting up the arguments?

    • @K31774
      @K31774 6 лет назад

      Hi, Im using GMS 1.4 , so what exactly i need to write there?
      cuz
      /with (instance_create(0,0,asset_get_index(_obj)))/ or / (with (instance_create(x,y,asset_get_index(_obj))) I get an error
      Can You help me please!
      Upd
      I already helped myself!
      But thanx anyway!!

    • @GlyphicEnigma
      @GlyphicEnigma 5 лет назад

      @@K31774 I'm using ENIGMA and it doesn't have asset_get_index(). do you know whether this system would still work?

  • @ToastGhost26
    @ToastGhost26 4 года назад

    Where does the save file get stored?

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

    How can edit a game for example; coin gemms etc. thanks

  • @FoxyOfJungle
    @FoxyOfJungle 4 года назад +3

    I save the file and I can load it, but if I close the game and open it again and try to load it, the error appears:
    Data structure with index does not exist.
    What can I do?

    • @yassinesey9295
      @yassinesey9295 4 года назад

      you probably destroyed the wrapper while still in loop

  • @Hubert99999
    @Hubert99999 5 лет назад

    So for an online game, would you use one of these files for each account and then store them on your own server? Or please do explain to me how an online saving/accounts roughly work !

  • @raptyrn1290
    @raptyrn1290 6 лет назад +1

    supposing I created a group of different objects with their own ids, would I need to put this code in each object? Beginner here just trying to get a better understanding of how that works.

    • @nathan08085
      @nathan08085 6 лет назад

      Raptyrn you can put this in one parent object and use event inheritance so all child objects save

    • @nathan08085
      @nathan08085 6 лет назад

      I would recommend learning .ini files first if you are a beginner

    • @raptyrn1290
      @raptyrn1290 6 лет назад

      I will try both of those things, thanks!

  • @larryteslaspacexboringlawr739
    @larryteslaspacexboringlawr739 6 лет назад

    thank you for gamemaker video

  • @maxdax55
    @maxdax55 4 года назад

    Eazy upgrade: Instead of "_string = json..."+"SaveString..."+"ds_map_destroy...". You can simply change "SaveString..." argument1 by the ds_map and in "SaveString..." add the line "_string = json_encode(ds_map)" and at the end of the script "ds_map_destroy(ds_map)". That will save you a bit of time (2 seconds every time haha) But also you will never forget to destroy the map as you need the argument or else syntax error. :)
    Edit: You should also; not start by a list but by a map. (map - map) instead of doing "map - list - map".

  • @owenbevt3
    @owenbevt3 6 лет назад

    One problem I've found with this method is it changes the id of your instances (and as far as I know you are not alowed to change it back again). Guess I'll have to find everwhere I refer fo instance ID and find something elce to use?

  • @cckong7803
    @cckong7803 4 года назад

    I save the file and I can load it
    but if I close the game and open it and try to load the game, the error appears:
    Data structure with index does not exist at this line "for(var i = 0; i < ds_list_size(_list); i++)"
    can someone help me with that:(( trying to fix it for whole day and checking the code for many times

  • @MichelleMoonknight
    @MichelleMoonknight 5 лет назад

    Hello, it's a great tutorial , but I have a little problem, when I save and then load , the player is not where it was while saving , I meant the x and y of player and all the objects that were doing some path are restored. How could I save the way they were before save ?

    • @MarkDuval
      @MarkDuval 5 лет назад

      Did you make your player object a child of the parent saving object?

  • @laszloeszik5033
    @laszloeszik5033 6 лет назад +1

    Thanks for this video, I was looking for a method to save stuff into files, so I can handle language versions more efficiently. Tho for some reason I thought this json_encode _decode is about to make the data unreadable and hard to modify (so it's encrypted). Is there an easy method to make this possible? And if there is a way, do you plan to make a video about it? :) I will try to put this idea in via patreon.
    Thanks again! I follow your tutorials for a while and I already made a minigame along the platformer tutorial series. :) Keep up the good work Shaun! :)

    • @laszloeszik5033
      @laszloeszik5033 6 лет назад +2

      Ok, I actually found an easy way to encrypt stuff. :) ( base64_encode _decode(); )

  • @REALSOLIDSNAKE
    @REALSOLIDSNAKE 4 года назад

    Hello Shaun. This is an awesome tutorial, thanks for it.
    I do have one question, it works wonders when the room is the same, though when moving between rooms, the objects loaded are passed to other rooms.
    Any one knows how to solve this? I've been trying to think a way to work around this, like a save for each room. The only problem I can think about this is for save deletion as I am trying to make a game with 3 save game slots, and making a script for code deletion seems a bit difficult for my current level of knowledge.
    Looking forward to hear from you guys!

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

      ds_map_add(_map, “room”, room)
      Then just do an if statement where you specify a room

  • @noahfreedley7694
    @noahfreedley7694 4 года назад

    How do you make the script with the new 2.3 update? ;-;

  • @srujankale7274
    @srujankale7274 5 лет назад

    is there an alternate code for ds_list_mark_as_map() ?

  • @glitched_studios
    @glitched_studios 5 лет назад

    Does anyone know how I could make it when you load the game, it writes all the saved variables to the objects, instead of deleting them and recreating them with the stored variables? It causes way too many dramas when I delete my control object and recreate it

  • @crainingaming3082
    @crainingaming3082 6 лет назад +1

    hey shaun, Ive been wondering something, in my game, Ive been trying to make an hp system but it just doesn't work. here is my code. my player just dies right away.
    /// @desc Die
    if (place_meeting(x,y,oEnemy)) or (place_meeting(x,y,oEnemyBig))hp--;
    if (hp==0)
    {
    with (oGun) instance_destroy();
    instance_change(oPDead,true);
    direction = point_direction(other.x,other.y,x,y);
    hsp = lengthdir_x(6,direction);
    vsp = lengthdir_y(4,direction)-2;
    if (sign(hsp) !=0) image_xscale = sign(hsp);
    }

    • @ringtoss8975
      @ringtoss8975 5 лет назад +2

      It's because you most likely have that code in the step event which means when the player and enemy are in contact, the player loses 1 hp per frame. So it appears are if the player just dies right away. You should add knockback or inviniciblity frames when hit so that this doesn't happen. PS: I know this comment is from a year ago but maybe someone else might have the same issue in the future and this may help them.

  • @tas_cie
    @tas_cie 4 года назад

    When I load game, the blocks disappear. Can you help me please ?

    • @Karak-_-
      @Karak-_- 4 года назад

      Ok my advice is look on what exactly is happening. Also the "When I load game, the blocks disappear." is really vague, I have no idea what that could mean,
      like about which blocks are we talking about.
      My advice is to run in in debug mode, there you can set breakpoints and checks what is happening. Also you might look at Game Maker Discord server, there are chennels for solving these kind of issues.

  • @JordanM56
    @JordanM56 5 лет назад

    Anybody have any idea how to LOAD different objects with different variables? I have no trouble saving different instances with different variable into a JSON but can't load more than one type of object...

  • @Mellz900
    @Mellz900 4 года назад

    This will bypass the sandboxing?

  • @iainbell8366
    @iainbell8366 6 лет назад

    You mentioned being able to add many sub levels in the JSON. I have objects with DS Lists inside their create event. I try add them to the DS Map but it only saves the reference ID. I tried using the ds_list_mark_as_map but its still only saving the reference. Anyone got a few pointers on how to expand his example to save DS Lists inside an object instead of just simple variables such as x,y, image_scale... etc? Should I simply use ds_list_write() to save the DS List? Not really readable and does not create sub levels in the JSON file. Appreciate some pointers.

    • @repsej2003
      @repsej2003 6 лет назад

      If I understand your comment correctly, you're using the wrong "mark as" function! If you want to save DS Lists inside a DS Map, you need to use ds_map_mark_as_list.
      OR, you can use the special function ds_map_add_list, which will both add the list to the map, and mark it for you.

  • @SuperGamersgames
    @SuperGamersgames 6 лет назад

    Hey, @Shaun Spalding! So I am working on a Space game called Vector Space (An Open-World ship game using similar controls to Asteroids, as well as graphics), and I want to make enemy ships that you can encounter. The problem is, I can't figure out how to actually make the AI without the Ship looking weird and acting weird (ex. The ship is always facing you and is moving not where the ship is looking). Do you possibly have a script or a video that would be able to help me in this sort of case?
    Thanks! :)
    -@SuperGamersGames

    • @checkbox.entertainment
      @checkbox.entertainment 6 лет назад

      image_angle = direction

    • @SuperGamersgames
      @SuperGamersgames 6 лет назад

      Alex Aulds The problem isn't the enemy's direction. The problem is being able to make an ai that move towards the player and shoots, while stay at a good distance the player and moving the enemy smoothly.

  • @crespo313
    @crespo313 6 лет назад

    Hi I lately made a health bar and i have a problem because i don't know how do I make it so the health bar stays in the corner of the screen? Because I added a view that follows the player.

    • @nathan08085
      @nathan08085 6 лет назад

      Crespo if you healthbar is not an object. Draw it in the draw GUI event. If it is an object get it’s position to equal the view width and height plus.. ... say 15. You could do this as x = camera_get_blahblahblah(camera)+15

  • @nathan08085
    @nathan08085 6 лет назад

    Thanks, this is neat.

  • @x_ranl_x
    @x_ranl_x 6 лет назад +1

    if you make a "HTML5 multiplayer" tutorial (it seems possible, but very untouched by tutorial makers) I'll donate $100. Not sure if networking is your forte, but worth a shot. Keep the GM world alive!

    • @NeZversSounds
      @NeZversSounds 6 лет назад

      check Gloomy Toad Studios - Multiplayer Fighting Game Programming

    • @nathan08085
      @nathan08085 6 лет назад

      Shawn Spaulding does the thing after you pay. It’s like buying a pc off NZXT, you pay and say what you want and then they give it to you

    • @x_ranl_x
      @x_ranl_x 6 лет назад

      NateStar 0 I understand, thanks. If he expressed interest I'm certain it would have panned out that way.

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

    SaveStringToFile doesn't work for me.

  • @FarronAnimations
    @FarronAnimations 4 года назад

    I want to make a game that has multiple rooms specifically, how would i make it so it also saves what room is being used?

    • @Etricks11
      @Etricks11 4 года назад

      you can use room_get_name and then when loading it pass it through asset_get_index and load that room

  • @evensteven4367
    @evensteven4367 5 лет назад

    Can you be more clear with the parent and child object, like the code in them because I think that's why this system isn't working for me. I'm just using a game object with no parent, and I'm accessing the global variables within, so I don't understand why this isn't working.
    Nvm I fixed it

  • @KornYellow
    @KornYellow 4 года назад

    What happened if I have 2 or more room to save how can I do that....

    • @Etricks11
      @Etricks11 4 года назад

      use room_get_name to save the room name string then when your loading pass the string though asset_get_index then load the room

  • @peal9256
    @peal9256 6 лет назад

    if we make objects that we want to save child objects of the saveme objects what do we do if the things I want to save already have a parent ?

    • @nathan08085
      @nathan08085 6 лет назад

      Pea & L I think you have to copy the events into all the objects and change psaveme to the object

    • @repsej2003
      @repsej2003 6 лет назад

      Well, you could make the parent object a child of saveme, if all the children of said parent need to be saved. Otherwise you might have to create a "subparent" to distinguish between the ones you want to save, and the ones you don't. Sadly this is a limitation of GameMaker itself, with objects only being able to have a single parent, but you can definitely make it work!

  • @glitched_studios
    @glitched_studios 5 лет назад

    Got it working well on desktop. But does this work for Android on IOS?

  • @JaisonJFranklin
    @JaisonJFranklin 6 лет назад +1

    Wow! Very complicated for me. If I need save the current values of all the variables created by me in my game is this the best way?

  • @yuuri_
    @yuuri_ 4 года назад

    wtf is the SaveStringToFile function and why can't i access it

    • @scrongus1959
      @scrongus1959 4 года назад

      go a few seconds further in the video and you'll see the script

  • @hericki5483
    @hericki5483 3 года назад +1

    "SaveStringToFile()" not exist '-'

  • @seandougherty2925
    @seandougherty2925 5 лет назад

    I dont understand where he went to when he highlights a bit of text and then hes in SaveStringTo File

    • @frankiewennerIV
      @frankiewennerIV 5 лет назад +1

      I believe he middle clicked his mouse and it took him to a script that he had already created just be sure to create a blank script called SaveStringToFile then you can middle click that same spot you saw him click, yours will be blank however so just type what he has in that script.

  • @mtr3754
    @mtr3754 4 года назад +1

    One thing I'm wondering about is where it's saving to. I set the name as savegame.sav like in the tutorial, but I can't find that save file anywhere in the directory. Mind you, it still works perfectly for me.

  • @GmodPlusWoW
    @GmodPlusWoW 6 лет назад

    Will this work with scripts, like if you're trying to make an RPG in GameMaker?

  • @GameDevYal
    @GameDevYal 6 лет назад

    Seeing "better" and "JSON" in the same sentence irks me greatly, but I suppose "better than the default GM save system" isn't the highest of bars to set :P

  • @LeftClickShift
    @LeftClickShift 6 лет назад

    Sorry to bother anyone here, but using this method- is their easy way to save the contents of a rather large 2D array into a JSON file and retrieve it when loading??

    • @DarkKnightDad
      @DarkKnightDad 6 лет назад +1

      you can save it as a list. Use the same code in the video, but instead of storing a map in each list, store a list in each list (so that the outer list is the rows, and the inner lists are the columns) [just remember to use ds_list_mark_as_list]

  • @athenasowl1857
    @athenasowl1857 5 лет назад

    Hi Shaun, I'm making a game with an achievement room with lots of global variables that I need to save and I do not have experience when it comes to saving and loading.
    I've followd along your tutorial and watched the video on Juju Adams, and I was wondering how you would save and load global variables within a persistent object. Currently I have an achievement room and I have a persistent game object called obj_achievements that holds all the achievements / global variables.
    The way I've set up my code is that instead of an (if key pressed) to save and load, I have used the step event in my object SaveLoad to trigger to save when at the end of the game when in rm_end, and load once it has saved. Would I still destroy my object obj_achievements before loading? How should I then write to create a new object? Do I still use instance_create_layer? Should I be using something else instead of JSON?
    Thank you for all that you do. I really appreciate your videos.

  • @ringtoss8975
    @ringtoss8975 5 лет назад

    Hey Shaun, just a quick question. I noticed in previous tutorials you used ++i inside for loops but in here you've used i++ instead. Does it make any difference besides including the first entry when using i++ as apposed to ++i? Great tutorial, once again!

    • @GlyphicEnigma
      @GlyphicEnigma 5 лет назад +1

      It shouldnt make any difference. i++ is basically the same as saying i+1 anyway

  • @richard_orc
    @richard_orc 4 года назад

    thank you =D

  • @aforgottenmemory4160
    @aforgottenmemory4160 6 лет назад +1

    phuck, my brain organ.

  • @gdomjan83
    @gdomjan83 6 лет назад

    There is a thing I'm not entirely sure about. At the beginning of the save script, first you create the ds_list, then you create the ds_map, and finally you add that map to the list. But at that point the map is empty, isn't it? Because you only populate the map with variables after that. I thought the order you do this would be : create the list, create the map, add variables to map and just after that you add the now populated map into the list. Or is there something I'm missing?

    • @Azenris
      @Azenris 6 лет назад +1

      only a reference is added to the list. so even as populate it after, they reference the same map

  • @mateusleme5846
    @mateusleme5846 6 лет назад

    Does this works for android projects aswell?

  • @aaronwise1089
    @aaronwise1089 4 года назад

    I thought game maker studio 2.3 was meant to be easy to use and have no coding, well that does it I am moving to construct 2 which is making things easier than both game maker studio 2.3 and Clickteam Fusion 2.5

  • @jakeadam0000
    @jakeadam0000 6 лет назад

    An IAP tutorial would be great

    • @nathan08085
      @nathan08085 6 лет назад

      XenoFusion - MTG all topics are voted on patrion. Please suggest there; it is only $5 ish dollars a month

  • @NotMySocial
    @NotMySocial 6 лет назад

    Oh wow i havnf seen 5 comments from this channel xD

  • @CSanykdotCom
    @CSanykdotCom 6 лет назад

    "|" is called the pipe, at least in the USA.

  • @ВячеславУкраинцев-т2з

    Ох, спасибо тебе большое! Как же я долго думал) it's russian

  • @jakeadam0000
    @jakeadam0000 6 лет назад

    Can you add In app purchases to a game made for steam?
    (my game is an MMO btw)

  • @purplegamer6223
    @purplegamer6223 6 лет назад +1

    Spoiler Alert "I going to Press L"