My first post hopefully of many. I'm very new to this, but have made good progress over 3 months or so, and with luck I hope to finish an ancient world-based Rimworld-like game, one day, and hopefully contribute to the community, as I think GMS is awesome (most of the time).
However I've begun to encounter errors that I search high and low, and for which I cannot find an explanation.
I've been staring at this for my whole Saturday:
My house/building objects (oCustomHouse) are built at beginning of game (3 of them for development's sake), and can be built by the player, like in an RTS.
They each have their own inventory, as a ds_grid made in the house's create step, indexed to instance variable (houseInventory) as they can contain food and other resources.
All fine, my peasants are happily moving resources to the houses, until I realise that for some reason, with the newly built houses, the houseInventory ds_grids seemingly disappear instantly on creation of the object. Or I lose their index, whichever way you look at it. This leads to 'Data structure with index does not exist' errors. I narrow it down, and the ds_grid_create is returning 0. The three built by the game will return 24, 25, 26, or 56,57,58 for example, it's different each playthrough. Then the custom built ones come with 0, 0, 0 recurring.
The strange thing is, and this echoes a couple of other weird errors I've had, I can force it to work by doing this:
Now it's fine, and the returned indexes will come back as e.g. 32, 34, 36 and then, happily, 38, 40, etc.
But I definitely don't want to build this game on shaky foundations, so if anyone has encountered something like this, I'd love to know. Again, I've searched as hard as I can...
Thanks.
However I've begun to encounter errors that I search high and low, and for which I cannot find an explanation.
I've been staring at this for my whole Saturday:
My house/building objects (oCustomHouse) are built at beginning of game (3 of them for development's sake), and can be built by the player, like in an RTS.
They each have their own inventory, as a ds_grid made in the house's create step, indexed to instance variable (houseInventory) as they can contain food and other resources.
GML:
var rcsv = global.Resourcescsv;
houseInventory = ds_grid_create(ds_grid_width(rcsv),ds_grid_height(rcsv));
All fine, my peasants are happily moving resources to the houses, until I realise that for some reason, with the newly built houses, the houseInventory ds_grids seemingly disappear instantly on creation of the object. Or I lose their index, whichever way you look at it. This leads to 'Data structure with index does not exist' errors. I narrow it down, and the ds_grid_create is returning 0. The three built by the game will return 24, 25, 26, or 56,57,58 for example, it's different each playthrough. Then the custom built ones come with 0, 0, 0 recurring.
The strange thing is, and this echoes a couple of other weird errors I've had, I can force it to work by doing this:
GML:
var rcsv = global.Resourcescsv;
throwawaygrid1 = ds_grid_create(0,0);
houseInventory = ds_grid_create(ds_grid_width(rcsv),ds_grid_height(rcsv));
But I definitely don't want to build this game on shaky foundations, so if anyone has encountered something like this, I'd love to know. Again, I've searched as hard as I can...
Thanks.