dim3 Forum

Full Version: Object Parameters question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to make a script that is almost completely done using object parameters so you don't have to alter the script at all.
Now I have a problem.
Code:
    obj.event.chain(camera_time,'buttonBack');
    var camera_time = obj.setting.getParameter(5);
Object parameter 5 is set to 20.
If I replace it with only
Code:
    obj.event.chain(20,'buttonBack');
it works.
Are parameters automaticaly converted into strings?
Is there any work around for this? It's really urgent. Sad

EDIT: For now, I'm going to use a fixed value in order to finish my game in time, but it would be nice if someone could explain this to me. Smile
Bink Wrote:I'm trying to make a script that is almost completely done using object parameters so you don't have to alter the script at all.
Now I have a problem.
Code:
    obj.event.chain(camera_time,'buttonBack');
    var camera_time = obj.setting.getParameter(5);
Object parameter 5 is set to 20.
If I replace it with only
Code:
    obj.event.chain(20,'buttonBack');
it works.
Are parameters automaticaly converted into strings?
Is there any work around for this? It's really urgent. Sad

EDIT: For now, I'm going to use a fixed value in order to finish my game in time, but it would be nice if someone could explain this to me. Smile

It's a string and remains that way until you hard convert it. Use parseInt, i.e.:

Code:
var camera_time = parseInt(obj.setting.getParameter(5));

You'll find this problem every once and a while with math, also, for instance, dividing two integers can get you a float which might need to be hard-converted back to an integer.

Javascript is a weakly typed language, so everything just auto-converts to everything else, and sometimes it's not what you want. That makes it very easy to learn to program in and write programs, but it has it's downsides sometimes (see above.)

[>] Brian
That's what I thought. Smile
parseInt(); is exactly what I was looking for! Now I don't have to make 10 different scripts just to change one value. Thanks! :D
Reference URL's