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

Legacy GM Is it possible to save a path mid-way through? (Data Structure method)

Dr_Nomz

Member
If I use a data structure (ds_map/list/grid) to save data, and an NPC is in the middle of a path, is it possible to save the position of the path the NPC is on, and then load it in WITH the NPC resuming it's path?

I'm using path_position and path_start btw.
 
T

Timothy

Guest
Sure it is.

If your path is a resource, just save the index nd path position.

If your path is created dynamically, you can save all the points of the path then re build it later.
 

Dr_Nomz

Member
Okay but how would I write that in code?

Here's how I normally save data:
Code:
ds_grid[# enum.x, _row]=x;
The way I normally save variables is I take a ds_grid, use an enum to pull a value, and have it equal to whatever the current value is for that object. So like whatever the X position of the NPC is, it'll save that value.

But how about the path_position? Will it be able to distinguish different points of the path down to the decimal without error? Because path_position only goes from 0.0 to 0.5 to 1.0, and everything in between, which seems like it would cause issues.

This is how I normally load in data btw:
Code:
x=ds_grid[# enum.x, _row];
So the X value for the object would be equal to whatever the value is in the grid, for example.
 
T

Timothy

Guest
Okay but how would I write that in code?

Here's how I normally save data:
Code:
ds_grid[# enum.x, _row]=x;
The way I normally save variables is I take a ds_grid, use an enum to pull a value, and have it equal to whatever the current value is for that object. So like whatever the X position of the NPC is, it'll save that value.

But how about the path_position? Will it be able to distinguish different points of the path down to the decimal without error? Because path_position only goes from 0.0 to 0.5 to 1.0, and everything in between, which seems like it would cause issues.

This is how I normally load in data btw:
Code:
x=ds_grid[# enum.x, _row];
So the X value for the object would be equal to whatever the value is in the grid, for example.
Put all the path points into a ds_list. You can then turn that list into a string and put it in your grid or write it to a file. There are functions for all of this and should be relatively simple. so at least attempt it before I just write the code for you.
 
Top