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

Saving maps question

Jihl

Member
Hey fellas!

I am using GM ds_map_secure_save function and I'm struggling to have maps inside other maps.

I need to store some maps inside other maps so I can hold all the data needed for every client and character of my game, it's an Online RPG.
Everything goes well while the game is on and I can manipulate the maps freely, but when I shut down the game and open it again, some of the values are shown as undefined, even when they werent before the shut down.

Some code I am using:
Code:
// Get arguments
var username = argument0
var password = argument1

// Add to registered accounts number
global.save_load_map[? "Registered Accounts"]+= 1
// Create map
var map = ds_map_create()
ds_map_add_map(global.save_load_map, username, map)
// Set values
map[? ds_client.username] = username
map[? ds_client.password] = password
// Create characters map
var map2 = ds_map_create()
ds_map_add_map(map, ds_client.characters, map2)
For example in this code I am registering an account, but after I shut down the game and open it up again, if I show up the username and password on the console it tells me it is undefined.

Do you have a better way to handle this? Or do you know what am I missing here?
Could it be that it goes undefined because I am using a local variable to create the maps? Does destroying the map that I have just created destroy the data that's inside the global.save_load_map?

Thanks alot!
Jihl :p
 

Jihl

Member
Solved the problem! It was that I was using .ini files and they don't work too well. Will do it with buffers! (buffer_save and buffer_load functions)
 

Tsa05

Member
Just to toss in there, check out json_encode and json_decode also--turns your maps, embedded maps, embedded list, etc into a data string for easy save/transfer. Most restful apis use json!
 
Top