• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

[SOLVED]Range of script Arguments

C

Cooltrain

Guest
Hey all,

So I've got a script that needs to accept either two, or three arguments. The current problem being that by setting it to its maximum of 3 it always requires 3. I'm trying to use the argument count/array for having between 2 or 3, but I'm not sure I'm using it correctly.

This is a section of the step event in the object that calls the script. These variables are going to be sent to the script

obj_textController step
Code:
            pos = array_height_2d(textList); //size of array
            textList[pos, 0] = section[0] //line1
            textList[pos, 1] = section[1] //line2
            textList[pos, 2] = section[2] //line3
Further down when ready we send the vars to the script
Code:
pos = array_height_2d(textList); 
        for (i = 0; i < pos; i += 1) {
        scr_textInput(textList[i, 0], textList[i, 1],textList[i, 2]);
        }

This is the top of the receiving script
Code:
if(argument_count<=2){
///scr_textInput(value0,value1,value2)
var arg0 = argument[0];
var arg1 = argument[1];
}else{
var arg0 = argument[0];
var arg1 = argument[1];
var arg2 = argument[2];
}
So as said above, some times i might only use the first two arguments which leaves textList[pos, 2] blank throwing an exception because its still expecting three arguments.

Thanks for any help.
 

FrostyCat

Redemption Seeker
If you want argument_count to see 2, you must write out the call to that script with exactly 2 arguments. You didn't do that anywhere. And no, leaving something like undefined or an uninitialized value in the third argument doesn't count.
 
C

Cooltrain

Guest
If you want argument_count to see 2, you must write out the call to that script with exactly 2 arguments. You didn't do that anywhere. And no, leaving something like undefined or an uninitialized value in the third argument doesn't count.
Well It needs to see 2 or 3 arguments, and it always expects the maximum amount ?
 
Top