• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Can a string be saved as a global variable?

A

Aaron Walton

Guest
I'm working on my save system, currently trying to implement a three slot system like a lot of retro games use, so when you start a new game, you select slot one, two, or three, and then you can load whichever slot you want. What I have right now is a newGame script, which sends the player to the starting location and has an argument which is a string ("savedgame1.sav"), which a global variable is set to, so that when the saveGame script is called, it saves to that text file. But my game is behaving strangely when I try to do this (it deletes my oPlayer when I try to start a new game in the menu, for some reason, which causes the game to crash). The save/load system worked perfectly before I started trying to implement multiple slots, when I wasn't trying to save a string to a global variable, so I'm wondering if somehow this is what's causing it. Is this even possible to do? If not, what would be a better solution? Here is my oNewGame object and my newGame script:

GML:
//This is oNewGame

with oMenu
{
    if menu[2] = true
    {
        other.image_index = 1
        if keyboard_check_pressed(vk_enter)
        {
            newGame("savedgame1.sav");
        }
    }
    else other.image_index = 0;
    
}
GML:
//This is the newGame script
///@arg saveSlot

SlideTransition(TRANS_MODE.GOTO, global.startRoom,global.startX,global.startY);
global.saveSlot = argument[0];
I suspect I could fix the issue by just having three different loadGame scripts, one for each save slot, which each just loads a particular file, but I'd like to see if I can do it this way before just brute forcing it.
 

Nidoking

Member
You don't seem to have specified how you're using global.saveSlot. It probably has the right value, but you're probably using it incorrectly.
 
Top