verb abc() switch (input ("Select one option") in list ("a [a]","b","c") if ("a [a]") usr << "a" if ("b") usr << "b" if ("c") usr << "c"
Problem description:
As you can see, I put the "a" var in the "a" option of the input list, but, in the condition (if ("a [a]") it doesn't work.
It shows: "8:error: : expected a constant expression"
How can I put the "a" var in the condition?
> mob > var > a = 0 > > verb > abc() > input ("Select one option") in list ("a [a]","b","c") > if ("a [a]") > usr << "a" > if ("b") > usr << "b" > if ("c") > usr << "c" >
Actually Hashir is correct, when checking the value of an input() outside of switch() you need to set a variable to the value input() returns and check against that value. You can't just if(value) outside of switch() you need to if(variable == value).
You need to specify a variable for input() to return the selected choice to, e.g:
> var/value = input("Input a number")as num > usr << value >
You are not understanding...
I don't want to input the value, I want to show it in the option.
In the real code it is one room system, and it need to be like this: "Room 1 (4 players)", for example.
In this case, "a" var is the number of the players. I don't want to choose the number of the players. Just show it.
I made this "a" version because I thought it could make you understand better, but it don't G_G
#10 Oct 29 2011, 7:22 pm (Edited on Oct 30 2011, 1:58 am)
You need to specify a variable for input() to return the selected choice to, e.g:
> > var/value = input("Input a number")as num > > usr << value > >
You are not understanding...
I don't want to input the value, I want to show it in the option.
In the real code it is one room system, and it need to be like this: "Room 1 (4 players)", for example.
In this case, "a" var is the number of the players. I don't want to choose the number of the players. Just show it.
I made this "a" version because I thought it could make you understand better, but it don't G_G
It was just an example to show you how input() works.
mob var/a=0 verb/abc() var/list/selection = list ("a [a]"="you selected a","b"="that\'s b","c"="c, the last option") var/select=input ("Select one option") in selection src << selection[select]