ID:138723
 
Description:

I have a var which is a list. When saving the list everything seems to run smoothly. When loading it won't load the var. It was saved under a proc.

For e.x:

// In a code file of its own.

mob
var
list
Example_List = list()

// Seperate code file.
mob
proc
Save_File()
var/savefile/save = new("Savefile/[src.key]/Savefile.sav")
save["x"] << src.x
save["y"] << src.y
save["z"] << src.z
save["Example List"] << src.Example_List
Load_File()
var/savefile/load = new("Savefile/[src.key]/Savefile.sav")
load["x"] >> src.x
load["y"] >> src.y
load["z"] >> src.z
load["Example List"] >> src.Example_List


Extra:

When loading a file with the example list the x/y/z vars don't work. Is there a specific way to save lists?


Sting15 wrote:
Description:

I have a var which is a list. When saving the list everything seems to run smoothly. When loading it won't load the var. It was saved under a proc.

For e.x:

> // In a code file of its own.
>
> mob
> var
> list
> Example_List = list()
>
> // Seperate code file.
> mob
> proc
> Save_File()
> var/savefile/save = new("Savefile/[src.key]/Savefile.sav")
> save["x"] << src.x
> save["y"] << src.y
> save["z"] << src.z
> save["Example List"] << src.Example_List
> Load_File()
> var/savefile/load = new("Savefile/[src.key]/Savefile.sav")
> load["x"] >> src.x
> load["y"] >> src.y
> load["z"] >> src.z
> load["Example List"] >> src.Example_List
>


Extra:

When loading a file with the example list the x/y/z vars don't work. Is there a specific way to save lists?



anything not under the /tmp directive will be saved if you did a push (ie: save << src)

so you don't have to manually go through everything the mob owns and specifically push it to save it

so if Example_List was of /tmp (ie: mob/var/list/tmp/Example_List) then yes, you'd have to specifically do save << src.Example_List

things like x, y, and z are always tmp variables, so they don't get saved automatically.

another thing that is happening automatically is by defining your variable with = list() at the end, means its being filled with null at run time. this may or may not be happening before or after you are using Load_File() procedure.

you also may not be calling src.Load_File() on the correct "/mob" at the right time...
In response to FIREking (#1)
The x,y,z work fine and loads the mob to its last location as it is supposed to. After adding the
load >> Example_List
the x,y,z vars come to a halt. The map stays the same as it is, blank. Vars such as
load >> src.Name
work as well.
In response to Sting15 (#2)
Have a read of this problem with solution - [link] , [link] , [link] , [link]

Hopefully they can help you.
Loading x,y,z directly doesn't work, because it sets them one at a time. Here's the problem: If the mob is already in a null location, its x,y,z vars are 0,0,0. you're changing x while y and z remain 0; the loc stays null, and therefore x doesn't actually change. The same goes for y and z. You need to load those into local vars, and then use locate() to set the location.

var/sx,sy,sz
load["x"] >> sx
load["y"] >> sy
load["z"] >> sz
loc = locate(sx,sy,sz)


As for the list, you should check after it loads to make sure it's a valid list. If it isn't, set it to a new list.