ID:2368748
 
(See the best response by Lummox JR.)
Code:
var/X= input("Do this") in list(1,2)


Problem description:

I've been using a work around for some time, but things are just beginning to pile up on being held back for an RP tool program. How do i make it recognize these as numbers to assign without doing some 10 line workaround?
Every time I have tried doing this, it has screwed with my math formulas and not done the proper stuff even on basic 1+var
Doing what? Workaround for what? What's even happening?
It refuses to recognize the input as numbers. So regardless of if I pick 1 or 2, it defaults it to 0 in equations
you need to show more context around your code
Ok. SO a bit of an update. I somehow got it to recognize variables, but now it isn't recognizing a decimal variable.
mob/verb/AudiBliss_AllBattle()
set category = "Farm"
var/Base= input("Choose the Fodder") in list(390, 608)
var/Egg= input("Egg?") in list(1 , 1.5)//Problem line
var/Lvl1= input("Choose a level for your pokemon.","Your level") as num
var/A= 210
var/B= ((Base*100/5)*1.5)
var/C= 100+Lvl1+10
world<< (round(round(sqrt(A)*(A*A))*B/round(sqrt(C)*(C*C)))+1)*Egg
world<< "--------------"
var/Poke2= 110+Lvl2
var/Poke3= 110+Lvl3
var/Poke4= 110+Lvl4
var/Poke5= 110+Lvl5
var/Poke6= 110+Lvl6
var/EXP2=((round(round(sqrt(A)*(A*A))*B/round(sqrt(Poke2)*(Poke2*Poke2)))+1)/2)*Egg
var/EXP3=((round(round(sqrt(A)*(A*A))*B/round(sqrt(Poke3)*(Poke3*Poke3)))+1)/2)*Egg
var/EXP4=((round(round(sqrt(A)*(A*A))*B/round(sqrt(Poke4)*(Poke4*Poke4)))+1)/2)*Egg
var/EXP5=((round(round(sqrt(A)*(A*A))*B/round(sqrt(Poke5)*(Poke5*Poke5)))+1)/2)*Egg
var/EXP6=((round(round(sqrt(A)*(A*A))*B/round(sqrt(Poke6)*(Poke6*Poke6)))+1)/2)*Egg
world<< "The rest of your party gets [EXP2], [EXP3], [EXP4], [EXP5], [EXP6]"
Try adding "as num" before the "in list". Although you should have "as num|null" in both of those inputs, and handle the null case which means the user canceled. Not allowing a cancel choice is bad form.
Exp.dm:98:warning: it is recommended that you use an object filter or 'anything' when combining constant input types with lists

    var/Egg= input("Egg?") as num|null in list(1 , 1.5)

Tried without 'null' too. This is a tool so I had no reason to add a "Cancel" in there
And it strangely only affects decimals. I looked up all I could find on decimals, and the only related searches that pull up were for Round() and checking if it is a decimal, not using the decimal
Hmm, true, the "as num|null" won't work with the list; it really should be as "as anything|null".

I think the problem with the decimals may well be a parsing bug. You may have stumbled on a bug inadvertently.
Tested and found that there are no issues with input() given a list of numbers, including non-integers.
mob
verb
do_stuff()
var x = input(src, "") in list(1, 2, 3, 4.5, 5.5)
var y = input(src, "") in list(1, 2, 3, 4.5, 5.5)
src << "[x] + [y] = [x + y]"
src << "[x] + [y] = [x - y]"
src << "[x] * [y] = [x * y]"
src << "[x] / [y] = [x / y]"
I tried some editing. If I change 608 to 608.5 there is a difference, yet it ignores 1.5 despite being an identical line. If i change it to 1 , 2 then it reads the 2
In response to Kaiochao
I wonder if you'd get the same results if one of the .5 numbers had a matching integer. Maybe the 1 and 1.5 together is the issue.
In response to Lummox JR
Bug confirmed, huh.
mob
verb
do_stuff()
var x = input(src, "") in list(1, 2, 3, 1.5, 2.5)
var y = input(src, "") in list(1, 2, 3, 4.5, 5.5)
src << "[x] + [y] = [x + y]"
src << "[x] - [y] = [x - y]"
src << "[x] * [y] = [x * y]"
src << "[x] / [y] = [x / y]"

After choosing x = 1.5 and y = 1:
1 + 1 = 2
1 - 1 = 0
1 * 1 = 1
1 / 1 = 1
Very weird. as 1, 2.5 it actually has a difference
Has someone here reported it, or can link me to where I can?
Best response
I don't think it's been reported, so you should just go ahead and post in Bug Reports.
In response to Lummox JR
Lummox JR wrote:
Parsing of numbers was incorrect in some cases where a similar number was available in a list of choices and a decimal point was in play.
When the parsing is for an input() in list() or argument in list() case, this is handled on the server. Therefore this fix impacts both the client and server.

Didn't want to post on a resolved bug report, but is there some update out now? I don't see anything unless it wasn't released yet.
Keep an eye on this thread for new releases.

According to your Bug Reports thread, the issue is resolved in the next build which hasn't been released yet.