Hello,
I’m just starting to learn ChatScript, and I haven’t found a solution to a problem I’m having trying to use ^argument(n) from within an outputmacro to loop through all its arguments.
outputmacro: ^testmacro variable ( ^arg1 ^arg2 ^arg3 ^arg4 )
{
$_argIndex = 1
^loop( 4 )
{
$_argValue = ^argument($_argIndex)
...code using that value...
$_argIndex += 1
}
}
^argument($_argIndex) will return matching variables _0 to _3 for $_argIndex = 1 to 4.
However, I couldn’t find a way to read the value of _0 rather than the matching variable name. I have tried ^$_argValue to no avail.
Enabling :trace all gives me:
System call ^argument(`1`)
NOPROBLEM ^argument(1) => `_0`
$_argvalue = ^argument(_0)
System call ^return(`$_argvalue`)
ENDCALL ^return(_0) => `_0`
How should I proceed if I want to use the value of an argument within the outputmacro itself?
Apologies in advance if this is answered in the docs, I did do my research and came out empty.
Thank you
EDIT: I should note that when accessing _0 directly (in a comparison for instance, or logging something like ^“value is: _0”) I get the value of that argument just fine.