"How to make a special kind of mob displayed in a list"
The following code
for(var/mob/player/M)
M = input("Who? Selecting yourself will cancel.") as mob in world
t = M
break
This code does NOT work. It lists all the mobs (including NPCs)
The following code...
for(var/mob/M)
if(M.client)
M = input("Who? Selecting yourself will cancel.") as mob in world
t = M
break
Also doesn't work. It still lists all the mobs.
If I hadn't got a 'break' in it, it would display it over and over...
Problem is, I want only specific mobs listed, and perhaps, if possible, mobs with only a certain variable on listed.
How do I do this?
Thanks for any incoming help. :)
--=Phoenix Man=--
You're looping through every mob in the world, and then displaying an input() for each one. It's displaying all of the mobs in the input() because there's no "in whatever" bit with the input() statement.
What you need to do is add all of the mobs you want to a list, and then use that list in the input() statement:
<code>//Get list of mobs var/moblist[0] for (var/mob/player/P) moblist+=P //Display input() var/X=input("Who?") as null|anything in moblist //Did they cancel? if (!X || X==src) //They pressed cancel, or chose themselves return</code>
The handy "as null|anything" bit gives you a cancel button (something that many people don't know, which unfortunately means that a lot of games just have a "Cancel" option in the list rather than the button).