Semenar
New member
This was noticed first when Pantocyclus said that their JS script was failing to find any locketable monsters. It appeared that taking a number and incrementing it (i++), then calling toMonster with it as an argument always yields None.
During some prodding, the following was determined. The function toMonster fails because it thinks that the input variable is a float, so it is parsed to a string like "3.0", and of course there is no monster with ID "3.0". I modified the function and recompiled Mafia to return the type of input variable; the results are below. The listed variable is substituted as an argument for the toMonster function, like toMonster(3).
Int:
3
3.0
2.0 + 1.0
2.5 + 0.5
0.5 * 6
1.0 * 3
3 as a variable
Float:
3.0000001
2++ (a variable with the value of 2 is incremented before it is substituted)
Math.round(3)
Math.floor(3)
2.5 as a variable + 0.5 as a variable
1.0 as a variable * 3
1 as a variable * 3
2 as a variable + 1 as a variable
2 as a variable + 2 as a variable
2 as a variable + 2
1
0
-1
There are several weird results. For instance, -1, 0 and 1 are apparently floats, but any other integer is correctly identified as an integer. Additionally, using any operation on variables guarantees that the result will be a float, even if it should not be the case. This affects all functions that work with ID inputs, not only toMonster().
During some prodding, the following was determined. The function toMonster fails because it thinks that the input variable is a float, so it is parsed to a string like "3.0", and of course there is no monster with ID "3.0". I modified the function and recompiled Mafia to return the type of input variable; the results are below. The listed variable is substituted as an argument for the toMonster function, like toMonster(3).
Int:
3
3.0
2.0 + 1.0
2.5 + 0.5
0.5 * 6
1.0 * 3
3 as a variable
Float:
3.0000001
2++ (a variable with the value of 2 is incremented before it is substituted)
Math.round(3)
Math.floor(3)
2.5 as a variable + 0.5 as a variable
1.0 as a variable * 3
1 as a variable * 3
2 as a variable + 1 as a variable
2 as a variable + 2 as a variable
2 as a variable + 2
1
0
-1
There are several weird results. For instance, -1, 0 and 1 are apparently floats, but any other integer is correctly identified as an integer. Additionally, using any operation on variables guarantees that the result will be a float, even if it should not be the case. This affects all functions that work with ID inputs, not only toMonster().
Last edited: