ID:146829
 
I've been trying to save vars to the turf but It won't let me. Is there any way to call these Read and Write procs on turfs?

turf/House1


Write(savefile/a)
a["owned"] << owned
a["housename"] << housename
..()

Read(savefile/a)
a["owned"] >> owned
a["housename"] >> housename
..()


I compile this with now error and doesn't effect the game, but it doesn't save the turfs var making me have to buy the house everytime i reboot. Please help if you know how.
Turfs don't follow most normal read/write rules, so you won't be able to save them the way you could save, say, an obj. To save a turf properly you basically have to do the whole thing manually.

Lummox JR
In response to Lummox JR
I've been trying to save the turfs var for awhile, and I've been pretty unsuccesful. I was wondering if you could help me with this. Besides the code I posted before I also tried to do something like this.
turf/verb
Save()
var/savefile/F = new("house1.sav")
F["housename"] << housename
F["owned"] << owned

I added the verb to me and tried manually saving it but it doesn't save the house1 vars.
In response to WickedlyAndy
This could and probabally is a problem in your house buying verb/option. Post that and Ill try to help you out. That would help out all the people trying to help you out. I would tell you the verb myself, but I am too lazy. But, If I can get to it before you post back, I will.
In response to CaptDarkDragon
First of all I'm useing someone's demo for temporary houses. I forgot who because I removed the commentary to nake the code look cleaner. Also I know the houses sell for 1 gold but says 5000.
mob/var
canenter
/*
turf/House1
verb

Write2(savefile/a)
a["owned"] << owned
a["housename"] << housename
..()

Read2(savefile/a)
a["owned"] >> owned
a["housename"] >> housename
..()
turf/verb
Save()
var/savefile/F = new("house1.sav")
F["housename"] << housename
F["owned"] << owned


*/


turf
House1
icon='Turfs.dmi'
icon_state="House"
Enter()
if(owned==1)
if(usr.owner=="House1")
usr<<"Welcome to"
usr<<"[housename]"
return 1
else
if(usr.canenter=="House1")
usr<<"[housename]"
return 1
else
usr<<"This is not your house!"
return 0
else
switch(alert("This house is for sale, do you want to buy it for 50000 gold?",,"Yes","No"))
if("Yes")
if(usr.gold>=1) //How ever much you want the tempary house to sell for.
usr.gold-=1 //How ever much you want the tempary house to sell for.
usr.owner="House1"
src.owned=1
statpanel("House")
usr.verbs+=/mob/proc/invite
usr.verbs+=/mob/proc/un_invite
usr.verbs+=/mob/proc/name_house
else
usr<<"You dont have enough gold!"
if("No")
return 0

House2
Enter()
if(owned==1)
if(usr.owner=="House2")
usr<<"Welcome to"
usr<<"[housename]"
return 1
else
if(usr.canenter=="House2")
usr<<"[housename]"
return 1
else
usr<<"This is not your house!"
return 0
else
switch(alert("This house is for sale, do you want to buy it for 50000 gold?",,"Yes","No"))
if("Yes")
if(usr.gold>=50000) //How ever much you want the tempary house to sell for.
usr.gold-=50000 //How ever much you want the tempary house to sell for.
usr.owner="House2"
owned=1
statpanel("House")
usr.verbs+=/mob/proc/invite
usr.verbs+=/mob/proc/un_invite
usr.verbs+=/mob/proc/name_house

else
usr<<"You dont have enough gold!"
if("No")
return 0

turf
House3
Enter()
if(owned==1)
if(usr.owner=="House3")
usr<<"Welcome to"
usr<<"[housename]"
return 1
else
if(usr.canenter=="House3")
usr<<"[housename]"
return 1
else
usr<<"This is not your house!"
return 0
else
switch(alert("This house is for sale, do you want to buy it for 50000 gold?",,"Yes","No"))
if("Yes")
if(usr.gold>=50000) //How ever much you want the tempary house to sell for.
usr.gold-=50000 //How ever much you want the tempary house to sell for.
usr.owner="House3"
owned=1
statpanel("House")
usr.verbs+=/mob/proc/invite
usr.verbs+=/mob/proc/un_invite
usr.verbs+=/mob/proc/name_house

else
usr<<"You dont have enough gold!"
if("No")
return 0

turf
var
owned=0
housename="your home."


mob
proc
invite(mob/M in world)
set category="House"
if(M.client==null)
src<<"You can't invite non-player characters into houses!"
else
M.canenter=src.owner
M<<"You have been invited into [src]'s home"
src<<"you have invited [M] into your home"
name_house()
set category="House"
if(src.owner=="House1")
for(var/turf/House1/H in world)
H.housename=input("What do you want to name your house?")
if(src.owner=="House2")
for(var/turf/House2/H in world)
H.housename=input("What do you want to name your house?")
if(src.owner=="House3")
for(var/turf/House3/H in world)
H.housename=input("What do you want to name your house?")
un_invite(mob/M in world)
set category="House"
if(M.client==null)
src<<"You can't un invite non-player characters into houses!"
else
M.canenter=0
M<<"You have been un invited to [src]'s home"
src<<"you have un invited [M] into your home"

Also the saving is in /* */ to show the saving everythign else has to do with the houses but i removed the /* and */ to test just so you know.