/*
This is the affinity system which the NPC will keep a list of players of whom he likes the most,
whoever is at the top of that list will get a special quest from that NPC or a Item whichever the NPC is willing to give.
*/
mob/NPCs/Interactive
var
affinityListNames = newlist("NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL")//This is the list that every NPC will have that will have the players names stored in.
affinityListAffin = newlist(0,0,0,0,0,0,0,0,0,0)//This is the affinity Levels which corresponds with the location of the name in the other list.
proc
CheckTopAffin()
for(var/i = 1 to affinityListAffin.len)
Problem description:
Im pulling my hair out because i try to follow the guides and im getting errors left and right. idk if its just because i dont really understand this language completely yet but what im trying to do is to have NPCS keep a list of players that they like its an affinity system. And i want them to be checking that list to see who is at the top of the list and when they next talk to the NPC they will recieve something special.
I am getting an error at affinityListAffin.len
var/list/mylist
Next, you don't want newlist() here, just list().
You don't need to initialize any elements here since you'll be adding data per-player.
Next, you'll probably want an associative list instead of two lists.
This would make mylist["Name"] come out as 10, so you'd just add the player's name to the list, then use the associated value to determine the affinity. You can also loop directly over the contents of a list without using another variable.
This would output
Using the above list.
For adding and removing from the list, you can simply use +=, but since we're gonna be using associated values, you don't even need to go that far.
Would add src's name to the list with an associated value of 0.
And for changing/setting the value it's as easy as
And removing is as easy as