ID:157277
 
How might I use a list in a switch(input)) sequence? like this?

Switch(input("yadda yadda yadda") in list(list))
if()

If that is how, then what might I put in the If() spot. And if not, please explain/show me an example. Help would be greatly appreciated, thanks.
switch(input("Select a gender for your character.", "Your Gender", usr.gender)in list("male","female","neuter"))
if("male")
usr.gender = "male"
if("female")
usr.gender = "female"
if("neuter")
usr.gender = "neuter"
In response to HolyDoomKnight
Thats not necessarily what I meant. Using a pre-existing list. Like, say I made a list, and it was based on what feathers you had. And, in the list, slot 1 has white feathers, slot 2 has brown feathers, and 3 has black feathers. How would I make a switch(input()) that would let me choose from the things in the already pre-existing list?
In response to Koriami
input("What kind of feather?","Feathers") in Myfeatherlist
In response to Jan90ster9
Ok, so I am trying this, and I don't have any options to select from that. How would I manage to make a selection? Like, I want to choose what to select from that list, but when I use the code, I get nothing happening. The game just does as it would have if I didn't click the verb.
In response to HolyDoomKnight
HolyDoomKnight wrote:
> switch(input("Select a gender for your character.", "Your Gender", usr.gender)in list("male","female","neuter"))
> if("male")
> usr.gender = "male"
> if("female")
> usr.gender = "female"
> if("neuter")
> usr.gender = "neuter"
>


As a follow up on this example, if you are only using switch() to define a single value (such as the above), then you should think "How can I compact this to affect just a single variable based on the option chosen?", which you'll (eventually... possibly...) arrive to this conclusion:
src.gender = input(src, "Select a gender for your character.", "Your Gender", src.gender)in list("male","female","neuter"))
In response to Koriami
Do you have a list defined containing what people want to select? And does your list have more than one entry?

If there is a single choice and the input does not have a cancel button, it will cause that choice to be chosen.
In response to GhostAnime
Thanks, this is working.
In response to GhostAnime
Ok, I have another question. Say I want him to pick up feathers. He picks up a brown feather, and then he goes to pick up another brown feather, how would I get it so that it counts each feather as their own seperate thing?
Or, to put it another way, how can I make it so identical items in a list are considered different?
In response to Koriami
Koriami wrote:
Ok, I have another question. Say I want him to pick up feathers. He picks up a brown feather, and then he goes to pick up another brown feather, how would I get it so that it counts each feather as their own seperate thing?
Or, to put it another way, how can I make it so identical items in a list are considered different?

That's not doable with input(), since it combines like names. The only way you could manage it would be to use an associative list and give each item a slightly different name, like "brown feather #2" or such, and then use that name in the list to look up the correct feather.

Lummox JR
In response to Lummox JR
Thanks, that got them seperated. But, Now, I have it so you can move the feathers when you use them. However, it will only work for one of them.

mob/verb
Release()
if(usr.controlling == 1)
return
var/mob/Feather/Z = input("What feather do you want to use?","Feather") in Feather
Z.loc = usr.loc
usr.controlling = 1
Z.owner = usr
usr.client.perspective = EYE_PERSPECTIVE
usr.client.eye = Z
Gather()
usr.client.eye = usr
for(var/mob/Feather/Z in view(usr.client.eye))
if(Z.owner == usr)
Z.loc = usr.FTHR
usr.controlling = 0
client/North()
if(usr.controlling == 1)
for(var/mob/Feather/M in world)
if(M.owner == usr)
step(M, NORTH)
return
else
..()
client/South()
if(usr.controlling == 1)
for(var/mob/Feather/M in world)
if(M.owner == usr)
step(M, SOUTH)
return
else
..()
client/East()
if(usr.controlling == 1)
for(var/mob/Feather/M in world)
if(M.owner == usr)
step(M, EAST)
return
else
..()
client/West()
if(usr.controlling == 1)
for(var/mob/Feather/M in world)
if(M.owner == usr)
step(M, WEST)
return
else
..()


Well, with this. What I do is release a single feather. I can take it back too. But, when I put out the second one, it won't move. Nothing will happen. Can anyone help with this?
In response to Koriami
That would be because you are using return there, so after it finds one it ends the proc.

Also want to point out how wasteful it is to loop through EVERY mob in the world. Just loop through the Feather list.