ID:172539
 
Im using Super11's OBJ Saver thing, and I thought it would be a nice idea to make it work for areas as well, so heres the code:
var/list/objs = list ()
obj
var/lastx
var/lasty
var/lastz

area
var/lastx
var/lasty
var/lastz

world/New() // Obj one, DOES WORK
..()
if(fexists("Map.sav"))
var/savefile/F = new ("Map.sav")
F >> objs
for(var/obj/o in objs)
o.loc = locate(o.lastx, o.lasty, o.lastz)
objs.Cut()
return ..()

world/Del()
var/savefile/F = new("Map.sav")
for(var/obj/o in world.contents)
o.lastx = o.x
o.lasty = o.y
o.lastz = o.z
objs.Add(o)
F << objs
return ..()

var/list/areas = list () // Area One, DOES NOT WORK

world/New()
..()
if(fexists("Housing.sav"))
var/savefile/E = new ("Housing.sav")
E >> areas
for(var/area/y in areas)
y.loc = locate(y.lastx, y.lasty, y.lastz)
areas.Cut()
return ..()

world/Del()
var/savefile/E = new("Housing.sav")
for(var/area/y in world.contents)
y.lastx = y.x
y.lasty = y.y
y.lastz = y.z
areas.Add(y)
E << areas
return ..()

Very simple, its the same thing as before, just using areas. Now heres the problem, the obj one works, and the area one doesnt. Dunno why, it just doesnt, and I dont see any difference except for the fact that one works for objs, and the other works for areas. (except for a couple var changes) if possible please, anyone help, and if this wont work, please tell me how to get it to work, thanks.

Oh yea, heres the error I get when I compile:
house.dm:237:error:y.loc:cannot change constant value
Metroid wrote:

world/New()
..()
if(fexists("Housing.sav"))
var/savefile/E = new ("Housing.sav")
E >> areas
for(var/area/y in areas)
y.loc = locate(y.lastx, y.lasty, y.lastz)
areas.Cut()
return ..()
Oh yea, heres the error I get when I compile:
house.dm:237:error:y.loc:cannot change constant value

As far as i know, a mobs loc is a turf, and a turfs loc is an area. And i dont even want to know what an area's loc is. But have you tried setting the areas x,y,z variables individually, instead of using locate?
In response to Lazyboy
Actually, my friend told me you cant change an area's loc, its perminant, so nows the qustion, I did take that out, but it crashes the server to save, anyway just to save Areas?

[EDIT]
My friend told me to try this out
var/list/areas = new/list ()

proc/Save_Areas()
var/savefile/f = new("Housing.sav")
for(var/area/housing/a in world)
areas += "[a.x] [a.y]"
areas["[a.x] [a.y]"] = a
f["areas"] >> areas

proc/Load_Areas()
var/savefile/f = new("Housing.sav")
f["areas"] << areas
for(var/area/housing/h in world)
for(var/i in areas)
if(i["[h.x] [h.y]"])
h = i["[h.x] [h.y]"]

But it does not save. Any reason why?
In response to Metroid
Metroid wrote:
Actually, my friend told me you cant change an area's loc, its perminant, so nows the qustion, I did take that out, but it crashes the server to save, anyway just to save Areas?

[EDIT]
My friend told me to try this out
> var/list/areas = new/list ()
>
> proc/Save_Areas()
> var/savefile/f = new("Housing.sav")
> for(var/area/housing/a in world)
> areas += "[a.x] [a.y]"
> areas["[a.x] [a.y]"] = a
> f["areas"] >> areas
>
> proc/Load_Areas()
> var/savefile/f = new("Housing.sav")
> f["areas"] << areas
> for(var/area/housing/h in world)
> for(var/i in areas)
> if(i["[h.x] [h.y]"])
> h = i["[h.x] [h.y]"]
>

But it does not save. Any reason why?

Did you call the procs at client/New() and client/Del()?

If not, this is what you would do:

client/New()
..()
Load_Areas()
client/Del()
..()
Save_Areas()


--Dan
In response to SSJ4_Gohan_Majin
SSJ4_Gohan_Majin wrote:
Metroid wrote:
Actually, my friend told me you cant change an area's loc, its perminant, so nows the qustion, I did take that out, but it crashes the server to save, anyway just to save Areas?

[EDIT]
My friend told me to try this out
> > var/list/areas = new/list ()
> >
> > proc/Save_Areas()
> > var/savefile/f = new("Housing.sav")
> > for(var/area/housing/a in world)
> > areas += "[a.x] [a.y]"
> > areas["[a.x] [a.y]"] = a
> > f["areas"] >> areas
> >
> > proc/Load_Areas()
> > var/savefile/f = new("Housing.sav")
> > f["areas"] << areas
> > for(var/area/housing/h in world)
> > for(var/i in areas)
> > if(i["[h.x] [h.y]"])
> > h = i["[h.x] [h.y]"]
> >

But it does not save. Any reason why?

Did you call the procs at client/New() and client/Del()?

If not, this is what you would do:

> client/New()
> ..()
> Load_Areas()
> client/Del()
> ..()
> Save_Areas()
>

--Dan

Alas, I just added that to confirm my friend opinon, although we did not add it, it did not help, I still have the problem. It will not save my areas.
In response to Metroid
Well, for starters you have your operators backwards.

savefile << blah means save blah into your file and

savefile >> blah means take stuff from the savefile and stuff it into blah.
In response to tenkuu
OMG! It worked! Thanks a lot, man I really needed that help, my friend helped, and we looked over a million times, but never figured it out, THANKS!
In response to tenkuu
tenkuu wrote:
Well, for starters you have your operators backwards.

savefile << blah means save blah into your file and

savefile >> blah means take stuff from the savefile and stuff it into blah.

I still manage to mix these up about half the time I use them. I finally started thinking of them as funnels, so in your first example, you are pouring 'blah' into 'savefile'. :)