PDA

View Full Version : definning paramerters and variables suggestion


roofy
10-14-2006, 12:56 PM
I know that Alice is now in the hands of EA sports, but could who ever knows how to contact EA sports, mention to them that parameters and variables include the difference between float, integer values? I already had two incidents so far when Alice returned a parameter false becuase the parameter was an integer and the check condition was a float.

for example.
I got an event that says this

When anykey is typed,
do sphere.speak whichKey=code

the method sphere.speak looks like this
parameters whichKeyCode

if whichKeyCode == 38 then
sphere say the upArrow key was pressed
else
nothing

now when I originally did this, the parameter whichKey was 38. However the if statement was checking it like this...

if 38 == 38.0

these are totally two different types of varibles. The "38" is a integer, and the "38.0" is a float. In addition, even if you put the round function in front of the value 38.0 it still reads as 38.0 which causes the if statement to always be false, and this is annoying.

DrJim
10-14-2006, 02:05 PM
I agree that this is one of the more annoying design choices made in Alice 2.0 (although from an educational standpoint, I agree with it). Think you can solve your immediate problem by a de facto integer to floating point conversion by adding a small, non-integer amount to both your integer and your test variable, i.e., add 0.01 to 38 and then test for 38.01.

I've tested this about a half dozen times and it seems to work, but please let me know if it fails for you. :confused: I think (or at least hope) the long term solution will be in Alice 2.1 where you will have access to true Java functionality.

Jim