ID:172131
 
i was wondering how to check in 2 list at the same time i tried this but doesnt work
var/list/Team1=list()
var/list/Team2=list()
mob/verb/Tell(var/mob/M in Team1||Team2)
if(M.Tell==src.Tell)
var/T = input("Private msg to [M]")as text
src<<"You Tell)[M]:[html_encode(T)]"
M<<"<usr](Tells You):[html_encode(T)]"

Seems like its only checking the first List...I want to be able to pick people in both teams but not other non client mobs in world.Im not really sure what operator i need to use.I have tried many like || && ^ ect thanks in advance

I know i dont want && cause its only true if the person is in both teams right?Which is pointless i dont want || cause it will only checks 1 team or the other right? ugh i dont know what to do

Brokenleg wrote:
i was wondering how to check in 2 list at the same time i tried this but doesnt work
> var/list/Team1=list()
> var/list/Team2=list()
> mob/verb/Tell(var/mob/M in Team1||Team2)
> if(M.Tell==src.Tell)
> var/T = input("Private msg to [M]")as text
> src<<"You Tell)[M]:[html_encode(T)]"
> M<<"<usr](Tells You):[html_encode(T)]"
>
>

Brokenleg wrote:
i was wondering how to check in 2 list at the same time i tried this but doesnt work
> var/list/Team1=list()
> var/list/Team2=list()
> mob/verb/Tell(var/mob/M in Team1||Team2)
> if(M.Tell==src.Tell)
> var/T = input("Private msg to [M]")as text
> src<<"You Tell)[M]:[html_encode(T)]"
> M<<"<usr](Tells You):[html_encode(T)]"
>
>


I'm not too sure, someone who knows a little more than I do can confirm this, but when you'r trying to search through two lists like that, using a literal "or"(||) operator like that just won't work. And whenever you do do something like that in an if() statement, you have to treat it lke two seperate conditions entirely:

if(M.Tell==src.Tell || M.Tell==5)


That would return true if either or those conditons were true. You couldn't do something like this:

if(M.Tell==src.Tell||5)


So, the way you want to do this is combine the lists for the two teams into one list, then put that list into the verbs parameters, like so:

var/list/Team1=list()
var/list/Team2=list()
var/list/Teamcombine = new()
proc/Combine()
for(var/t in Team1) Teamcombine += t
for(var/f in Team2) teamcombine += f
mob/verb/Tell(var/mob/M in Teamcombine)
if(M.Tell==src.Tell)
var/T = input("Private msg to [M]")as text
src<<"You Tell)[M]:[html_encode(T)]"
M<<"<usr](Tells You):[html_encode(T)]"


Now, make sure to delete or at least empty out the Teamcombine list whenever you're done with it in your code, unless of coure you want the list to remain with the same vaule as it originally combines.

Resonating Light
In response to Resonating_Light
Thanks that idea would work but is alittle to hardcore for what i need.I just decided to make a seperate list beside the one's for team and just add all clients in it but thanks for setting me on the right path though
In response to Brokenleg
Actually, the easiest way would just be to concatenate (stick together) the lists, like this:

<code>mob/verb/Tell(var/mob/M in Team1+Team2)</code>

You may have noticed that's actually very close to what you had, just with a + instead of ||. =)

But yeah, having a list of all player mobs in the game is very useful anyway, so I recommend you do that. It's probably slightly faster than adding the lists together all the time anyway.
In response to Crispy
LOL i knew there was a operator i could use to check in 2 lists but using a simple + never crossed my mind ^_^ i learn something new on this forum everyday thanks