ID:156189
 
Alrighty, Im trying to make a verb that searches for players who have a certain race in view. I figure I have to use list, but I dont know ho to set it up?

This was my first attempt, but it just doesnt look right:
var/list/witches = list(src.race = "Witches")


Can anyone help?
mobs in view of a certain race.. i would approach this with the oview() proc and a for loopmaybe? why do you need the list?

var/mob/M

for(M in oview(6)); if(M.race==x); M.money+=100 ...
In response to Rapmaster
Like I have one verb that "hides" your race from others, so when a mob uses a verb that searches for a particular race within view or an area, then user of the hiding verb would be undetected. I have no idea how how to make the verb to search, and thought I would need a list, do I need one?
In response to HaffCaff
mob/var/race=""
mob/var/canbesearched

now you still use oview() as before but this time modify it to check if the mob can be searched. and then u get your list of mobs which you can add to a list if you wanted. list.Add(M)
In response to Rapmaster
Ok, I think I did a bad job explaining. Ill show you my code so it makes more sense:
mob/var
soultype = "" // consider this as race
soulprotect = 0 //mean they are not hiding their soul type


mob
Witch
verb
Soul_Protect() //Hide their soul
if(usr.soulprotect)
usr.soulprotect = 0
usr<< "You stop using Soul Protect"
return
usr.soultype = "Human" //Changes Soul type to human, making them seem normal
usr.soulprotect = 1 //the are currently soul protecting(hiding their race)


var/mob/m

mob
Meister
verb
Soul_Perception(M/mob in oview(6)) //Checking the Soul Type (races) of those in view
//What now?""

See? Now I dont know what to do?
In response to HaffCaff
mob/var/tmp/list/souls=list()//define the list
Meister
verb
Soul_Perception() //Checking the Soul Type (races) of those in view
var/mob/m

for(m in oview(6,src))//read oview poc for correct syntax u hadnt done it correctly.
src.souls.Add(s)//you mentioned you wanted a list?

src.displaysouls()//diplay them to the user

proc
displaysouls()
var/mob/m//typecast

for(m in src.souls)
var/dist=get_dist(src,m)// this part is theoretical i dont know if it would work runtime, try it
src<<"[m.name],[m.soultype],distance=[dist]//display souls to him

var/number=src.souls.len
src<<"[number] souls in view."

for(m in src.souls)//to make the list empty again for next search.
src.souls.Remove(m)//just wait for garthor or kaioken to mention whether u can simply delete the list.


seeing as this is not compiled by me, i am not sure whether there are bugs in it so use at your own peril aha
In response to Rapmaster
Alright, compiled that code and got this:
mob/var/tmp/list/souls=list()//define the list
Meister
verb
Soul_Perception() //Checking the Soul Type (races) of those in view
var/mob/m

for(m in oview(6,src))//read oview poc for correct syntax u hadnt done it correctly.
src.souls.Add(s)//you mentioned you wanted a list?

src.displaysouls()//diplay them to the user

proc
displaysouls()
var/mob/m//typecast

for(m in src.souls)
var/dist=get_dist(src,m)// this part is theoretical i dont know if it would work runtime, try it
src<<"[m.name],[m.soultype],distance=[dist]"//display souls to him

var/number=src.souls.len
src<<"[number] souls in view."

for(m in src.souls)//to make the list empty again for next search.
src.souls.Remove(m)//just wait for garthor or kaioken to mention whether u can simply delete the list.



loading Soul Eater.dme
SoulSystem.dm:91:error: mob/var/tmp/list/souls: duplicate definition
SoulSystem.dm:91:error: list: instruction not allowed here
SoulSystem.dm:91:error: : duplicate definition
SoulSystem.dm:91:error: ==: instruction not allowed here
SoulSystem.dm:98:error: s: undefined var
SoulSystem.dm:92:error: : empty type name (indentation error?)
SoulSystem.dm:98:error: src.souls.Add: undefined var
SoulSystem.dm:106:error: src.souls: undefined var
SoulSystem.dm:110:error: src.souls.len: undefined var
SoulSystem.dm:113:error: src.souls: undefined var
SoulSystem.dm:114:error: src.souls.Remove: undefined var


Any Ideas?
Im sorry about the wholelist thing, If you know a way I can do it without them then please let me know, I just thought I needed one.


EDIT**
Ok, I looked at the errors and changed a few things, and it worked, this is the working compiled code

mob/var/tmp/list/souls=list()//define the list
mob
Meister
verb
Soul_Perception() //Checking the Soul Type (races) of those in view
var/mob/m

for(m in oview(6,src))//read oview poc for correct syntax u hadnt done it correctly.
src.souls.Add()//you mentioned you wanted a list?

src.displaysouls()//diplay them to the user

proc
displaysouls()
var/mob/m//typecast

for(m in src.souls)
var/dist=get_dist(src,m)// this part is theoretical i dont know if it would work runtime, try it
src<<"[m.name],[m.soultype],distance=[dist]"//display souls to him

var/number=src.souls.len
src<<"[number] souls in view."

for(m in src.souls)//to make the list empty again for next search.
src.souls.Remove(m)//just wait for garthor or kaioken to mention whether u can simply delete the list.
In response to HaffCaff
seperate mob/var... and the mob/proc into two seperate lines. also by the looks of things you might have to rename the list to like soulssearch? up to you, it says you have a list called souls already.