I'm here to suggest something I think would be very useful!
What about a function like:
or pragma("script", { ... });
...that would let create a script inline without the need of making a script in the resource tree.. sometimes creating this scripts make the resource tree very overcrowded and sometimes you just need the script in a particular case just to be passed as an argument to another function (for example).
select_squares(grid, condition);
"condition" here is a function..
here I have to create a function for just one simple thing.. it's not very practical.
what if I want to change the "5"... what if I want another logical operation "<" or ">="?
okay... I know condition could be:
but this would be a nightmare to maintain..
the script could even be dynamic, meaning you could use script_free(script) to release it!
What about a function like:
Code:
script_create({
var a = argument[0];
var b = argument[1];
return a+b;
});
...that would let create a script inline without the need of making a script in the resource tree.. sometimes creating this scripts make the resource tree very overcrowded and sometimes you just need the script in a particular case just to be passed as an argument to another function (for example).
select_squares(grid, condition);
"condition" here is a function..
Code:
#select_squares
var grid = argument0;
var condition = argument1;
var out = ds_list_create();
for( i ...) {
for( j...) {
value = grid[# i, j]
if (script_execute(condition, value)) {
ds_list_add(out, value);
}
}
}
return out;
#condition
var value = argument0;
return value > 5;
what if I want to change the "5"... what if I want another logical operation "<" or ">="?
okay... I know condition could be:
Code:
#condition
var value = argument0;
var test = argument1;
var valid = argument2;
switch (test) {
case TEST.EQUAL:
return value == valid;
break;
case TEST.NOTEQUAL:
return value != valid;
break;
case TEST.GREATER:
return value > valid;
break;
default:
return false;
}
the script could even be dynamic, meaning you could use script_free(script) to release it!