N
Nitex
Guest
I'm a bit stuck. I'm currently trying to save and pull a ds_grid and a ds_map from an ini file. I save them like so (other code surrounds these):
And read them like so, function calls formed up straight from the docs:
This is the error:
I'm trying to do hexes, and I'm using the grids package but at this point there's not really a file I haven't mucked about with. I was thinking the problem might be the original data type isn't actually a grid or something, but typeof doesn't work I suppose in GMS 1. At any rate, the actual creation of global.grid occurs here:
So it does appear to be a grid. Global.map is similarly is a map:
This is what gets saved to my file:
But I honestly have no bloody idea if that's what it's supposed to look like. Google hasn't been a ton of help on this one. Printing what ini_read grabs to the console shows it is indeed getting those monstrous strings, but somehow ds_grid and ds_map aren't actually populating global.grid and global.map with the values they should be?
They're getting read in in a code block in a dialogue event. I'm not sure if that matters or not. They're placed in the file in a left_click event of that same object. Printing global.grid before and after the load just returns 0. Printing global.map before/after returns 1 both times, so that's not helping me. Running:
Before and after returns the same thing, 100041, so I'm guessing the load isn't working, but I already knew that lol
Is it because the ds_grid has objects in it?
I can't think of what else to add, but if you need more detail I'll toss it in.
GML:
ini_open(file_name_text)
ini_write_string("LevelData","RoomGrid",ds_grid_write(global.grid))
ini_write_string("LevelData","RoomMap",ds_map_write(global.map))
ini_close()
GML:
ds_grid_read(global.grid, ini_read_string("LevelData","RoomGrid", ""))
ds_map_read(global.map, ini_read_string("LevelData","RoomMap",""))
GML:
trying to index a variable which is not an array
at gml_Script_gl_vector_transform (line 18) - var a = m[0];
stack frame is
gml_Script_gl_vector_transform (line 18)
called from - gml_Script_gl_flathex_world2grid (line 12) - var v = gl_vector_transform(v_raw, map[? "inverse"]);
called from - gml_Script_gl_map_world2grid (line 13) - return gl_flathex_world2grid(map, world_point);
called from - gml_Object_oCursor_DrawEvent_1 (line 6) - grid_vector = gl_map_world2grid(global.map, gl_mouse_get_position()); //turn mouse pos into hex position
GML:
var grid = ds_map_create();
var grid_data = ds_grid_create(width, height);
grid[? "grid_data"] = grid_data;
grid[? "bottom_left"] = bottom_left;
grid[? "width"] = width;
grid[? "height"] = height;
grid[? "shape"] = shape;
grid[? "neighbors"] = global.gl_flathex_neighbor_directions;
var principle_directions = ds_list_create();
ds_list_add(principle_directions,
global.gl_flathex_ne,
global.gl_flathex_n,
global.gl_flathex_nw);
grid[? "principles"] = principle_directions;
return grid;
GML:
var map = ds_map_create();
map[? "cell_dimensions"] = cell_dimensions;
map[? "base_transform"] =
gl_matrix3_create(
3/4*cx, cy/2, 0,
0, cy, 0,
0, 0, 1);
map[? "transform"] = gl_matrix3_identity();
map[? "inverse"] = gl_matrix3_identity();
map[? "type"] = global.gl_gridtype_flathex;
return map;
GML:
[LevelData]
RoomMap="1:696E7665727365:0000000009B69710,1:74797065:4008,1:63656C6C5F64696D656E73696F6E73:0000000009B6A598,1:7472616E73666F726D:0000000009B698A0,1:626173655F7472616E73666F726D:0000000009B6A868"
RoomGrid="590200000A0000000F0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E06BF8400000000000000000806CF8400000000000000000206DF8400000000000000000C06DF8400000000000000000606EF8400000000000000000006FF8400000000000000000906FF84000000000000000000070F84000000000000000005070F84000000000000000008070F8400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000F06BF8400000000000000000906CF8400000000000000000306DF8400000000000000000D06DF8400000000000000000706EF8400000000000000000106FF8400000000000000000A06FF84000000000000000001070F84000000000000000006070F8400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000606BF8400000000000000000006CF8400000000000000000A06CF8400000000000000000406DF8400000000000000000E06DF8400000000000000000806EF8400000000000000000206FF8400000000000000000B06FF84000000000000000002070F84000000000000000007070F8400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000706BF8400000000000000000106CF8400000000000000000B06CF8400000000000000000506DF8400000000000000000F06DF8400000000000000000906EF8400000000000000000306FF8400000000000000000C06FF84000000000000000003070F8400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006BF8400000000000000000806BF8400000000000000000206CF8400000000000000000C06CF8400000000000000000606DF8400000000000000000006EF8400000000000000000A06EF8400000000000000000406FF8400000000000000000D06FF84000000000000000004070F8400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000106BF8400000000000000000906BF8400000000000000000306CF8400000000000000000D06CF8400000000000000000706DF8400000000000000000106EF8400000000000000000B06EF8400000000000000000506FF8400000000000000000E06FF8400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C06AF8400000000000000000206BF8400000000000000000A06BF8400000000000000000406CF8400000000000000000E06CF8400000000000000000806DF8400000000000000000206EF8400000000000000000C06EF8400000000000000000606FF8400000000000000000F06FF8400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D06AF8400000000000000000306BF8400000000000000000B06BF8400000000000000000506CF8400000000000000000F06CF8400000000000000000906DF8400000000000000000306EF8400000000000000000D06EF8400000000000000000706FF8400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A06AF8400000000000000000E06AF8400000000000000000406BF8400000000000000000C06BF8400000000000000000606CF8400000000000000000006DF8400000000000000000A06DF8400000000000000000406EF8400000000000000000E06EF8400000000000000000806FF8400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000B06AF8400000000000000000F06AF8400000000000000000506BF8400000000000000000D06BF8400000000000000000706CF8400000000000000000106DF8400000000000000000B06DF8400000000000000000506EF8400000000000000000F06EF840000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
They're getting read in in a code block in a dialogue event. I'm not sure if that matters or not. They're placed in the file in a left_click event of that same object. Printing global.grid before and after the load just returns 0. Printing global.map before/after returns 1 both times, so that's not helping me. Running:
GML:
print("1 ", gl_grid_get(global.grid, array(1,1)))
Is it because the ds_grid has objects in it?
I can't think of what else to add, but if you need more detail I'll toss it in.
Last edited by a moderator: