ID:262125
 
area/house
House1
House2
House3
var
owned
housename
Enter(atom/movable/A)
if(ismob(A))
var/mob/M=A
if(owned==1)
if(M.owner=="House1")
M<<"Welcome"
M<<"[housename]"
return 1
else
if(M.canenter=="House1")
M<<"[housename]"
return 1
else
M<<"This is not your house,[housename]"
return 0
else
switch(alert("This house is for sale, do you want to buy it for 5000 Zenni gold?",,"Yes","No"))
if("Yes")
if(M.Zenni>=50000)
M.Zenni-=50000
M.owner="House1"
owned=1
statpanel("House")
M.verbs+=/mob/proc/invite
M.verbs+=/mob/proc/un_invite
M.verbs+=/mob/proc/name_house
else
M<<"You dont have enough gold!"
if("No")
return 0

///////////////////////////////////


name_house()
set category="House"
if(src.owner=="House1")
for(var/area/House1/H in world)
H.housename=input("What do you want to name your house?")
if(src.owner=="House2")
for(var/area/House2/H in world)
H.housename=input("What do you want to name your house?")
if(src.owner=="House3")
for(var/area/House3/H in world)
H.housename=input("What do you want to name your house?")


Sigh

TemparyHouses.dm:53:error:H:undefined type: H
TemparyHouses.dm:54:error:H.housename:undefined type: H.housename
TemparyHouses.dm:56:error:H:undefined type: H
TemparyHouses.dm:57:error:H.housename:undefined type: H.housename
TemparyHouses.dm:59:error:H:undefined type: H
TemparyHouses.dm:60:error:H.housename:undefined type: H.housename
TemparyHouses.dm:53:H :warning: variable defined but not used
TemparyHouses.dm:56:H :warning: variable defined but not used
TemparyHouses.dm:59:H :warning: variable defined but not used
Dont save it on World/Del() That wont work,it has no time to do what you wish for it to do because the world is already gone.

--Goz
In response to Goz
Also, to extend what Goz said. If you are doing an actual reboot like cntrl + R, what i'm about to say won't work. If you are doing a Admin Reboot, like world.Reboot() you can actually make another proc that has all your save stuff in it, and call that proc in the Reboot proc
1. Don't use usr in procs; See Dream Tutor: Usr Unfriendly

2. rather than using things like the following:
if(owned==1)

or

if(M.client==null)


You should be using if(owned) or if(!M.client).

3. It isn't saving/loading the houses because you are not actually saving the houses, your saving a savezone (Just as a note a tile can only have 1 area, so you can't put down a house area and then a savezone).
In response to Goz
Goz wrote:
Dont save it on World/Del() That wont work,it has no time to do what you wish for it to do because the world is already gone.

--Goz

You CAN save in world/Del().
In response to Nick231
Nick231 wrote:
You CAN save in world/Del().


I'm almost positive you cannot save things in world/Del() because the worlds already gone before it can do what was programmed. See [link]

--Goz
In response to N1ghtW1ng
no no no no no When yo ubuy a house i want it to Save in a list that Usr owns House 1 so whe nit reboots Usr still owns house 1
In response to Dranzer_Solo
[link]

Read the Dream Tutor thing. Just from that sentence you are implying that the user is usr or something...Just read the article by Lummox, and read Nick's post also
In response to N1ghtW1ng
yeh um i click thta and it takes me back to my post -_-
In response to Goz
You can save just fine in world/Del. All other functions are aborted and all objects are silently destroyed (that is, the Del for all other objects in the world is not called when the world is shutdown) once this function returns, so you can do other things before it is returned.
world/Del()
var/savefile/S=new("houses")
//stuff the houses into S
..()

That should work just fine.

I have saving in world/Del of many of my programs, and it works perfectly. However, when you do so you need to be wary if you also load things at world/New. If you load from a savefile at world/New when there is no savefile (such as when the world is started for the first time) things will get screwed up since there is no data to load. In that case, you need to check to see if the variables input to are null, and change them if they are not supposed to be.

As an example, the following is what you would want to do if you have a list of banned players to save.
var/global/list/banned
world
New()
var/savefile/S=new("banned")
S>>banned
if(!banned)banned=list()
/*Without the above line, the first time you run
the program banned will be null instead of an empty
list. That could also leed to other errors as you
try to add to it while it is null, resulting in
even more errors and saving null when the world
is shutdown so the problem never goes away even
for later tests.*/

Del()
var/savefile/S=new("banned")
S<<banned
In response to Dranzer_Solo
Yeah my bad...I copied the parent ID by accident >.>
In response to Loduwijk
world/Del()
var/savefile/S=new("houses")
//stuff the houses into S
..()


var/global/list/houses
world
New()
var/savefile/S=new("houses")
S>>houses
if(!houses)houses=list()
Del()
var/savefile/S=new("houses")
S<<houses


so they are liek the same ok anyways wut did u mean //stuff the houses into S
It would be much more managable if you just gave the variables and function to a base /area/house type. Also, it is best to avoid usr in Enter.
area/house
House1
House2
House3
var
owned
housename
Enter(atom/movable/A)
if(ismob(A))
var/mob/M=A
if(owned==1)
if(M.owner=="House1")
M<<"Welcome"
M<<"[housename]"
return 1
else
if(M.canenter=="House1")
M<<"[housename]"
return 1
else
M<<"This is not your house,[housename]"
return 0
else
switch(alert("This house is for sale, do you want to buy it for 5000 Zenni gold?",,"Yes","No"))
if("Yes")
if(M.Zenni>=50000)
M.Zenni-=50000
M.owner="House1"
owned=1
statpanel("House")
M.verbs+=/mob/proc/invite
M.verbs+=/mob/proc/un_invite
M.verbs+=/mob/proc/name_house

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

Also, Enter is used to check and see whether something is supposed to be allowed entry into another object. Entered is what happens when something actually does do the entering. Annoying bugs can crop up if you rely on only Enter for both.
In response to Dranzer_Solo
// are comments. Anything coming after them on a line is ignored by the compiler and not included into the game.

So if I did the following:
//Hey there, this line does absolutely nothing.

That code would not do anything since it is commented. Comments are for leaving notes to yourself in the code.

I did that to show that the house saving would be done there, but I did not type up house saving stuff since that was not what my reply was for, rather being just to make a point.
In response to Loduwijk
k i got yeh now i just dont how to save the houses
In response to Dranzer_Solo
Since an object's contents are saved along with it when you stash it in a savefile, it is better not to save the actual area unless you put in sufficient code to avoid bugs that brings up.

If all your areas are of a different type, you can just loop through the areas and save their name along with their owner.
proc/houseSave()
var/savefile/S=new("houses")
for(var/area/house/A in world)
S["/[A.name]/owner"]<<A.owner
S["/[A.name]/housename"]<<A.housename
proc/houseLoad()
var/savefile/S=new("houses")
for(var/area/house/A in world)
S["/[A.name]/owner"]>>A.owner
S["/[A.name]/housename"]>>A.housename

Also refer to my other post in this thread about avoid the pitfalls of loading from nonexistant savefile directories that result in null data. In this application, whenever you would save houses you could have an if(fexists("houses")) check and only load if it is true, aborting if it is false to be left with default values.
In response to Loduwijk
thanks
In response to N1ghtW1ng
TemparyHouses.dm:53:error:H:undefined type: H
TemparyHouses.dm:54:error:H.housename:undefined type: H.housename
TemparyHouses.dm:56:error:H:undefined type: H
TemparyHouses.dm:57:error:H.housename:undefined type: H.housename
TemparyHouses.dm:59:error:H:undefined type: H
TemparyHouses.dm:60:error:H.housename:undefined type: H.housename
TemparyHouses.dm:53:H :warning: variable defined but not used
TemparyHouses.dm:56:H :warning: variable defined but not used
TemparyHouses.dm:59:H :warning: variable defined but not used
Maybe someone already said this but I dunno..When it asks if you want to buy a house it says the house is 5,000 but it checks for 50,000 and takes away 50,000.
In response to Dession
if(M.Zenni>=50000)
M.Zenni-=50000


That's what you have in the last piece of code that was posted. You can also do a advanced/find replace for 50000 and either manually replace it (in '50000' is used elsewhere) or automatically have it be replaced by 5000.
Page: 1 2