Anders__oo__
Member
I have this ds global.entityData I wanna save and read back untouched from a file.
I have a script that reads global.entityData
Save
and for load
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!!
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);
}
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();
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();
}
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: