ID:1731268
 
(See the best response by Mightymo.)
Hey guys. Lists have been acting strangely for me lately, specifically when I try to add, find, or remove something from/to them. They're considered 'null', even though I'm absolutely certain I'm defining them correctly. Care to shed some light?
Code:
var/list/squads = list()//The global list that houses all squads that have been created by players
//I've attempted adding some values to the list,
//such as var/list/squads = list("asd","dsa","DASD")
mob/var/InSquads = 0
mob/var/SquadsName = "None"

mob
proc
SquadsCheck()
if(src.InSquads&&squads.Find(src.SquadsName))
src.verbs += //Here, squad verbs would be given.
else if(src.InSquads)
//Here, considering the squad they were in doesn't exist any longer, they will be kicked out and considered squadless
else
src.verbs+=/mob/verb/Squads/Create_A_Squad


More information can be provided if necessary. The error I'm receiving is...

Error:
runtime error: Cannot execute null.Find().
proc name: SquadsCheck (/mob/proc/SquadsCheck)
usr: PLAYER (/mob)
src: PLAYER (/mob)
call stack:
PLAYER (/mob): SquadsCheck()


The line number it's referencing would be...
if(src.InSquads&&squads.Find(src.SquadName))


Are you sure that you've typed this correctly? That first line shouldn't even compile.
Mightymo wrote:
Are you sure that you've typed this correctly? That first line shouldn't even compile.


My bad. Fixed.
Best response
It seems likely that you are modifying the squads list elsewhere in your code; nothing seems wrong with the bit that you've provided.
I see now. My apologies, I hadn't scanned the rest of my source. I had loaded the list from a savefile, but considering the savefile didn't exist (I didn't use the if(fexists statement) it made the list null. Thanks for making me look twice!