ID:273536
 
Is there a way to use list associations without always having to check for the list & making a new one (else get a bad index error)??
    PatchUp()
if(!Number) Number=new() //these lines here
if(!MissingNumber) MissingNumber=new()
if(Number[src]==(MissingNumber[src.Village]+1))
Number[src]--; MissingNumber[src.Village]++


Can you just define them with it? What are the ramifications of that if you can?
var/list
MissingNumber[]=new()
Number[]=new()
var/list
MissingNumber = list()
Number = list()

But make sure you never do MissingNumber = null to empty list, better MissingNumber = list()
In response to Ripiz
what about MissingNumber[src]=null??
In response to Saucepan Man
If MissingNumber[src] is number, text or reference it's fine, but if it's another list you'll have to do MissingNumber[src] = list()
In response to Ripiz
:O YOU CAN DO THAT?

SO like....
var/PeopleOnline=list()
Login()
PeopleOnline[src.Colour]+=src

mob/verb/Dance()
if(src in PeopleOnline["White"])
usr<<"You failed to perform any notable dance moves and no ladies thought you were cool. In fact all you achieved was knocking some big guys drink out of his hand... You had best run!"
else if(src in PeopleOnline["Black"])
usr<<"Your fantastic dance moves astound everyone! You score 1,000 ladies! Well done."
else if(src in PeopleOnline["Green"]
usr<<"Your alien dance moves are lost on these earthlings..."
In response to Saucepan Man
Doesn't mean src.Colour will be there >.>
If it's only 3 colors, you can define it in variable
var/list/PeopleOnline = list("White" = list(), "Black" = list(), "Green" = list())
In response to Ripiz
If it were a bajillion colours, would the initial method work (i'm sensing: no)
In response to Saucepan Man
Sadly no, you'll have to check if it's exists in list, if not then add and initialize list for it.
In response to Ripiz
src.Colour="slightly offish shade of red with a hint of magnolia"
if(!(src.Colour in PeopleOnline)) PeopleOnline+=list(src.Colour= list())
PeopleOnline[src.Colour]+=src


Like that?
In response to Saucepan Man
Colour = "slightly offish shade of red with a hint of magnolia"
if(!(Colour in PeopleOnline))
PeopleOnline += Colour
PeopleOnline[Colour] = list(src)
In response to Ripiz
Thankyou ^_^
enjoy this Old Spice Guy video as thanks :D
http://www.youtube.com/watch?v=SLz5ArupElA
In response to Ripiz
From my experience with lists(caching random crap), you don't need to add an item to associate it with something.
if(!(Colour in PeopleOnline))
PeopleOnline[Colour] = list(src)