ID:267832
 
Heh. I've been two whole years on BYOND by now, I think, and I still don't know this question...

"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=--
*shakes his head sadly* Logic, man, use your logic! =)

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).
In response to Crispy
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).

On the other hand, do you know how many people will complain that there's no cancel if you have it as a button instead of an option in the list? :P
In response to Hedgemistress
None, I would hope. Certainly nobody with half a brain. =P (Yes, I'm aware that only a small percentage of BYONDers qualify for that distinction, but stupid people don't deserve to play good games. =D )
In response to Hedgemistress
Hedgemistress wrote:
On the other hand, do you know how many people will complain that there's no cancel if you have it as a button instead of an option in the list? :P

That's downright sad, considering making Cancel a button instead of an option in the list is the better way to go all around. But since the way to do it isn't immediately obvious to newbies, Cancel ends up as a list option in the average DBZ game.

Lummox JR
In response to Crispy
Looking at the bug reports users file on my games, "No option to cancel!" is a big one, and it's not always from dbzing noobs.