ID:149488
 
If you have a list,


var/list/temp


with a variable number of components, and you want to include it in a switch statement:


switch(input("","",) in temp)



how can you return the chosen component from within temp? I tried the following:



switch(input("","",) in temp)
if(temp[1])
. . . . .


but it said that the if() statement expected a constant expression
The list/Find() proc returns the index number of the first instance of a list item.

switch(temp.Find(input("","",) in temp))
if(1)

In response to Shadowdarke
ok, that took care of part of the problem, but is there a way to make it so that you don't have to write states for

if(1)
if(2)
if(3)
.
.
.

to infinity?

something that just assigns the chosen value of the switch to some other variable would be ideal
In response to Gakumerasara
perhaps switch is not what you are looking for. What specifically are you trying to do?
In response to Gakumerasara
It seems that some people (presumably you, as well) overuse switch(). switch() is used for when you know what a value is going to be, but you don't want to use a whole lot of if()s. For example

proc/switch_example()
var/switch = input(usr,"") in list("One","Two")
switch(switch)
if("One") world << "[usr] chose number one!"
if("Two") world << "[usr] did not choose one, /he chose two!"

If you just wanted to make usr.name into "One" or "Two," for example, you would simply:

proc/set_name()
usr.name = input("") in list("One","Two")

Hope I could help you!

-Lord of Water