Hey there kids, its your friendly neighboorhood Deadlocke :D How y'all folk doin? Well I has one itty bitty question. In the game i am Developing (or Painting as I like to call it) players are able to build cities. I associate the city with that particular player, sot that way only she may see its stats. The question is, is there a way to delete the cities a player has made once she logs off?
Thank you in advance :-D
ID:179957
Oct 1 2001, 9:34 am
|
|
In response to Foomer
|
|
Why do you say it is inefficient?
|
In response to Deadlocke
|
|
Because its looping through all the cities
If you have the cities a player controls as a list, you can just loop through that list ie for(var/obj/City/O in src.Cities) del(O) Alathon |
In response to Alathon
|
|
Thanks Dude, I checked out the List thingy and it turns out that it might be INCREDIBLY usefull!! :-D Thanks again!
|
In response to Deadlocke
|
|
A common missconception is that lists are super special and weird, their not. A list, for example is just a text string which can have multiple text strings. The finding something from the list can be different at times, but its easy to get used to. To add something to a list you add it like you do a number to another, heres an example
mob/verb/BuildCity(cityname as text) obj/city/O = new(src.loc) O.name = cityname src.Cities += O // Adds the city, which is the object O to the list, just like adding a number to a variable. Cycling through a list can be done by a for loop Heres an example of one to go with this mob/verb/Current_Cities() for(var/obj/City/O in src.Cities) src << O This goes through the list Cities, and for every object thats an /obj/City in the list, it does src << O, which just displays the name of O to src. Hope that clears it up a little Alathon |
then...
mob/Logout()
for(var/obj/building/O in world)
if(O.owner == src.name)
del(O)
..()
This is probably a really inefficient way to do it though :oP