|
|
Am 16.03.2011 17:07, schrieb Trevor G Quayle:
> I want to use an array inside a function, for example:
>
> function(x,y,z){MYARRAY[][]}
>
> I can hard code an array index, and it is fine:
>
> eg. function(x,y,z){MYARRAY[2][3]}
>
> , however I can't create an array index from a function. I get an error "Float
> expected but vector or color expression found"
>
> e.g. function(x,y,z){MYARRAY[max(min(int(x),9),0)][max(min(int(y),9),0)]}
Note that inside a function declaration, any and all variables (except
for references to the function parameters) are evaluated at parse time;
this is also true for array variables. But at parse time the function
parameters x and y are unknown for obvious reasons.
BTW, evaluation of the variables is delegated to the general SDL parser,
not the specialized function syntax parser; therefore in your case x and
y are interpreted as the respective axis vectors rather than the
function parameters.
Post a reply to this message
|
|