GameMaker I Don't wanna use secure save Please show me another way?

I have this ds global.entityData I wanna save and read back untouched from a file.

GML:
///@param TheItem

var TheItem

TheItem = argument0;

if instance_exists(TheItem){
    var TheGrid = ds_grid_create(ENTITY_PROPERTIES.COLUMN_COUNT,0)

    with(TheItem) {
        var _row = Ds_Grid_Add_row(TheGrid);
       
        TheGrid [# ENTITY_PROPERTIES.X, _row]            = x;
        TheGrid [# ENTITY_PROPERTIES.Y, _row]            = y;
        TheGrid [# ENTITY_PROPERTIES.IMAGE_SPEED, _row] = image_speed;
        TheGrid [# ENTITY_PROPERTIES.DIRECTION, _row]    = direction;
        TheGrid [# ENTITY_PROPERTIES.IMAGE_INDEX, _row] = image_index;
    }
    var _data = room_get_name(room) + string(TheItem);

      ds_map_replace(global.entityData, _data, ds_grid_write(TheGrid));

    ds_grid_destroy(TheGrid);
}
I have a script that reads global.entityData
GML:
///@param TheItem

var TheItem,TheGrid

TheItem = argument0;

var _data = room_get_name(room) +string(TheItem);

var _str = global.entityData[? _data]; //check to find data

if (_str == undefined) {
    exit;
    }
    else{
    var TheGrid = ds_grid_create(0,0);
    ds_grid_read(TheGrid,_str);
    for (var _row=0; _row < ds_grid_height(TheGrid); _row++)
    {
        with(instance_create_layer(0,0,"Instances",TheItem))
        {
            x            = TheGrid[# ENTITY_PROPERTIES.X, _row];
            y            = TheGrid[# ENTITY_PROPERTIES.Y, _row];
            image_speed = TheGrid[# ENTITY_PROPERTIES.IMAGE_SPEED, _row];
            direction    = TheGrid[# ENTITY_PROPERTIES.DIRECTION, _row];
            image_index = TheGrid[# ENTITY_PROPERTIES.IMAGE_INDEX, _row];
        
        }
    }
}

ds_grid_destroy(TheGrid);

Save

GML:
var _SavEntity;

file_delete("saveEntity.ini");
   ini_open("saveEntity.ini");

_SavEntity    = ds_map_write(global.entityData);
ini_write_string("Lists", "0", _SavEntity);

ini_close();
and for load

GML:
if file_exists("SavEntity.ini"){

    ini_open("SavEntity.ini");

    var str = ini_read_string("Lists", "0", "");
    if str != ""
        {
        ds_map_read(global.entityData, str);
        }
    ini_close();
}
This save and load code doesn't work. .

But how do I save the whole thing to a file and reload it. without using secure save.

Because secure save and load doesn't work with console saving.

Like a save game situation..

Need Help!!
 
Last edited:
The thing is that the save and load thing of all my entities work...
It work perfectly If i use secure_save and secure_load

I don't want to rewrite all the code for this because as I said It works.

I just want to know and understand how I can save the ds map containing a ds grid and reload it to be the same...

Maybe I wasn't to clear about that.
 
I want to Save my ds_map(global.entityData) containing a ds grid to a file.

And load the file and rebuild the ds map containing the grid. without using secure save and load
 
What are your requirements?
HI..

I took a look at this vid

and did a quick implementation to my game..

That system saves the txt file but when im trying to load it it gives med this error

___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Step Event0
for object oSaveLoad:

ds_list_size argument 1 incorrect type (undefined) expecting a Number (YYGI32)
at gml_Script_LoadInstances (line 13) - for (var i = 0; i < ds_list_size(list); i++){
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_LoadInstances (line 13)
called from - gml_Script_LoadAllTheInstances (line 12) - LoadInstances(json);
called from - gml_Script_LoadGame (line 13) - LoadAllTheInstances();
called from - gml_Object_oSaveLoad_Step_0 (line 6) - LoadGame();

Using 2.2.5

maybee found an error brb..
 
Last edited:

TsukaYuriko

☄️
Forum Staff
Moderator
This error message says:
ds_list_size expects an integer as its first argument.
You passed undefined as its first argument.
This means that list is undefined.
Wherever you are last setting list before this line of code runs, you are setting it to undefined.
There's no real way for us to tell why that is the case without seeing the code.

If you copied the tutorial line by line, you didn't accurately copy the tutorial line by line.
 

GMWolf

aka fel666
The thing is that the save and load thing of all my entities work...
It work perfectly If i use secure_save and secure_load

I don't want to rewrite all the code for this because as I said It works.

I just want to know and understand how I can save the ds map containing a ds grid and reload it to be the same...

Maybe I wasn't to clear about that.
you could just replace secure save and load with ds_map_write(id) and ds_map_read.

Alternatively, Json encode it.


I'm assuming that if you were using secure save it was to stop it from being human readable.
secure save just base64 encodes a json string and tacks on some machine identifier at the start (not at all secure I know. YYG disappoint me).
So you can get the exact same level of security by just base64 encoding the json string and saving that.
If you want to make it more secure than secure save, but still make it complient with consoles, you could add a hash of the json string at the end of your base64 encoded buffer.
Still not very secure but harder to modify than secure save.
 
The secure thing is not an issue.. don't need to be secure.. just to save all my data and get it back looking the same..
 

GMWolf

aka fel666
The secure thing is not an issue.. don't need to be secure.. just to save all my data and get it back looking the same..
then json encoding your data and saving the string should work fine.
that or using ds_map_write(id) and ds_map_read.
it pretty much a drop in replacement for secure save/
 
I tried this out but it doesn't work??

save:
GML:
var _string = ds_map_write(global.entityData)
var file = file_text_open_write("save.json")
file_text_write_string(file,_string);
file_text_close(file);
load
GML:
var file =  file_text_open_read("save.json");
ds_map_read(global.entityData,file);
file_text_close(file);
 
Last edited:
then json encoding your data and saving the string should work fine.
that or using ds_map_write(id) and ds_map_read.
it pretty much a drop in replacement for secure save/
I can't just replace it doesn't work ...
I use the ds_map not id. because everything i want to save is in that ds map and inside that map is a grid(string)
 

GMWolf

aka fel666
I tried this out but it doesn't work??

save:
GML:
var _string = ds_map_write(global.entityData)
var file = file_text_open_write("save.json")
file_text_write_string(file,_string);
file_text_close(file);
load
GML:
var file =  file_text_open_read("save.json");
ds_map_read(global.entityData,file);
file_text_close(file);
file_text_open_read gives you a file, not the contents of the file.
you still need to use file_text_read_string to read the string.
 
Top