ID:263476
 
Code:
obj

var
saveX = 0
saveY = 0
saveZ = 0
turf
var
saveX = 0
saveY = 0
saveZ = 0
list
owner = list()

doorway
Entered(mob/M)
if(src.owner.len == 0)
switch(alert(M,"Do you wish to buy this house for $500?","Buying House","Yes","No"))
if("Yes")
if(usr.money>=500)
usr.money-=500
M<<"Welcome to your new house"
src.owner.Add(M.key)
return 1
else
usr<<"Not Enough Money"
return 0
if("No")
return 0
else
if(M.key in src.owner)
return 1
else
M<<"This isn't your house!!!"
return 0


var/list/HouseStuff = list()

world
New()
if(fexists("World Save Files/House.sav"))
var/savefile/F = new("World Save Files/House.sav")
F >> HouseStuff
for(var/obj/O in HouseStuff)
if(istype(O,/obj))
O.loc = locate(O.saveX,O.saveY,O.saveZ)
for(var/turf/T in HouseStuff)
if(istype(T,/turf/doorway))
for(var/turf/S in world)
if(istype(S,/turf/doorway))
if(S.loc == locate(T.saveX,T.saveY,T.saveZ))
S.owner = T.owner
HouseStuff.Remove(T)
Del()
var/savefile/F
F = new("World Save Files/House.sav")
for(var/turf/T in world)
if(istype(T,/turf/doorway))
T.saveX = T.x
T.saveY = T.y
T.saveZ = T.z
HouseStuff.Add(T)
if(istype(T,/turf/floor))
for(var/obj/O in T)
O.saveX = O.x
O.saveY = O.y
O.saveZ = O.z
HouseStuff.Add(O)

F << HouseStuff



mob/verb/Invite_Person(var/mob/M in world)
var/check = 0
if(M.client)
for(var/turf/T in world)
if(istype(T,/turf/doorway))
if(src.key in T.owner)
check = 1
T.owner.Add(M.key)
M<<"[src] invited you to his house!"
src<<"You invited [M] to your house!"
if(check == 0)
src<<"You don't own a house!"




Problem description: when i compile it works no problem, i can even add stuff on the map. but when i run it, it freezes Dream Seeker and never runs. And if i run it from Dream Deamon and enter does same thing. whats going on?

update: i just say if i run it from Dream Daemon i get this

BYOND ERROR - maximum number of lists exceeded! (65535)


how do i fix?
In response to Chase_Hammer
Use less lists

EDIT: To be more helpful, turf lists are a BAD idea. The way you've got it set up, every turf in the entire game is going to have a list. There's a limit on the maximum number of lists you can have, and you should never hit it.

The simple way to fix it is to not initialise the 'owners' list until it is required - currently, you initialise it for all turfs.
In response to Jp
:P i only have like 3 at most
In response to Chase_Hammer
Every turf in your game has a list. That's a lot more then 3. That's quite a lot more then 65535, from the look of it.
In response to Jp
err this is rediculous...

what can i do?
In response to Chase_Hammer
In response to Jp
well i only really need a list for one turf only (the doorway) so what would i have to change to only have the list there but also make the verb (invite) work with the same var/list?
In response to Chase_Hammer
can someone help me fix this code please?
In response to Chase_Hammer
You have a list for every turf. Thats why you hit the list limit. You can use list2params for hiding them, but then you would probably hit the string limit. Try to make a subtype of turf to hold that list.
turf
doorway
var/list/owners[0]

Thats will probably fix your problem.
In response to Xx Dark Wizard xX
doesnt work.

i get 4 erros if i list the owner list as a var only for the doorway turf. where it talks about S.owner and T.owner

the errors are for:

if(src.key in T.owner)
check = 1
T.owner.Add(M.key)


and

if(src.key in T.owner)
check = 1
T.owner.Add(M.key)
M<<"[src] invited you to his house!"
src<<"You invited [M] to your house!"
In response to Chase_Hammer
Typecast t correctly, then.

You're doing it all wrong, anyway. The 'doorway' turf should hold a reference to its owner, and the owner should have a list of ckeys that are allowed to enter the doorway (A list of ckeys rather then references to avoid problems with saving/loading)
In response to Jp
Why? It makes more sense to put the list "on" the door, unless I'm missing somethng important.
Also, what people seem not to realize, you don't need lists for this kind of thing. A simple text string will do, and it saves you creating an object and slighly approaching the list limit (I guess there's a string limit too, but probably bigger than the list limit?_?) I like using a format like this:
obj/door/var/keyholders="|"
//add a person
keyholders += "[ckey]|"
//check for a person
if(findText(keyholders,"|[ckey]|"))

//remove a person (a tiny bit more complex:p)
keyholders = remove_text(keyholders,"[ckey]|")
//>_> yeah, fine:
proc
remove_text(maintext,txt,ignore_case=0)
var/pos = ignore_case? findtext(maintext,txt) : findText(maintext,txt)
if(!pos) return 0
return copytext(maintext,1,pos) + \
copytext(maintext,pos+lentext(txt))

It's easier to make procs/#defines to quickly do these 3 actions and save you the adding '|' at the right places and whatnot.
In response to Kaioken
Kaioken wrote:
Also, what people seem not to realize, you don't need lists for this kind of thing. A simple text string will do, and it saves you creating an object and slighly approaching the list limit (I guess there's a string limit too, but probably bigger than the list limit?_?)

The string limit is actually the same. While in theory it's easier to reach more quickly, in practice you're better off using strings for cases like this because you can use as many copies of the same string as you want. To be sure the strings are most likely to be the same, you might want to find a way to sort the keys that end up in your long string.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
The string limit is actually the same. While in theory it's easier to reach more quickly, in practice you're better off using strings for cases like this because you can use as many copies of the same string as you want. To be sure the strings are most likely to be the same, you might want to find a way to sort the keys that end up in your long string.

Lummox JR

Hey, at least Lummox is supporting an idea I said, but I don't actually get it. ^_^" This is a string in a global variable, why would you use multiple copies of it or need to sort it (an easy but possibly cheap way to do the latter would to temporairly convert it to a list and back, and use your favorite list-sorting-proc)?
In response to Kaioken
its hard to follow now...so what i gathered is a String is easier than List?

would someone be kind enough to input what they mean and impliment it into my code above so i see whats going on please?
In response to Chase_Hammer
In this case, it's better to use. Not always easier, and the code basically remains the same, just using the different ways to add,check, and remove keys from the string, described in my previous post.
The way this works, is that each key in the list is ending up being surrounded in "|" characters. That way, if there's a key "kaioken" and a key "gokukaioken" for instance, they get separated and findtext() won't confuse between keys.
turf/door
density=1 //you want the door to open and close, default closed
var/keyholders = "|" //initialize the string. keyholders means...people 'holding the key', as in allowed to pass threw the door :P
Enter(mob/M)
if(src.density && ismob(M)) //if the thing attempting to enter IS a mob, and the density isn't zero (ie its 1, ie the door is dense ie the door is closed :p)
if(findText(keyholders,"|[M.ckey]|")) //checks if the key surrounded by '|' is found in the string
viewers(src) << "[M.name] opens the door with his key."
src.density = 0 //open door stuff
flick(src,"opening") //animation, if wanted
spawn(20) //let this proc continue and run this code after 2 seconds
src.density = 1 //close the door.
return ..() //return the default value. if the door has been opened and there is no dense thing on it blocking movement, then movement will succeed.

Note you should combine the first 2 if checks with another && operator, but I separated them so they're easier to comment.
How to add people to the 'list text string' is described in my previous post. Since you initialized the string with a beginning '|', you just need to append "[ckey]|" to it (with the += operator).
In response to Kaioken
There seems to be no reason in using findText() there, and you should be using sleep(), not spawn.
In response to Popisfizzy
sweet i got it...you rock Kaioken :)

next how do i save the infomation on each turf so if the server is restarted it still is owned.
In response to Popisfizzy
Popisfizzy wrote:
There seems to be no reason in using findText() there,

If you actually read the topic, you should of understood. Ckeys are stored in the text string (surrounded by '|' chars, so it can end up like this: "|kaioken|popisfizzy|". This approach separates between keys so if somebody has a key named 'kaio' the entry for 'kaioken' won't be confused for it, for example). findText() is used to check if the ckey is present in the string.

and you should be using sleep(), not spawn.

No. It would be pretty pointless if I have used sleep() - not only that sleeping in built-in procs like Enter() returns them automatically (and rightfully so), you need the proc to continue and return the default return value to allow movement or not, which will now be what we want since we've set the door's density to 0. Later, the spawned code executes and 're-denses' the door.
Page: 1 2