In the future, if you're going to show a widget, please show the entire widget (incl. the <<widget>> bits), not simply some chunk of its contents, how you're calling it, and what you're calling it with. Making us guess about some or all of these things is not conducive to getting you the help you want.
Tangential question: can array functions be used with <<set>>?
It is my understanding that passing the variable name in quotes like this passes the variable itself to the widget and not the value. Is that correct?
Partially, however, there's more to it than that. That passes the name, which may then be used to assign a new value to the variable, though not directly (see: State.getVar() and State.setVar()). If you're not attempting to assign a value to it, however, then doing so is unnecessary. In your case, you simply seem to be attempting to modify the existing array and object members of said array.
When I start the story, a popup error tells me the for loop is referring to an undefined object, even though the if statement should prevent it being called in that case. Even stranger, it keeps throwing the same error even when the $party and $enemies arrays are fully defined.
Because you're attempting to operate on the variable's name, a string.
Anyway. Moving on to your shown code example. You have several issues:
- You're passing the name of the variable, rather than its value, and attempting to use the name directly, rather than using it to pull the value. As noted above, for your use case, you should simply be able to pass the variable as normal.
- You're using <<script>> when there's no need.
- You're using v1 APIs in v2 (i.e. state.active.variables vs. State.variables).
- You're attempting to access temporary variables as though they were story variables (i.e. […].variables.i vs. […].temporary.i).
- You seem to be attempting to remove the effect if the duration is 0, but you're splicing the effect itself, rather than the effects array.
Try something like the following: (using <<for…range>> and the <Array>.deleteAt() method for readability)
<<for _member range $args>>
<<for _j, _effect range _member.effects>>
<<if _effect.duration is 0>>
I wrapped it within a <<silently>> because you don't need output to be generated by this thing (not that it matters much if you only call in within PassageDone, but best practices).
Also. As noted above, try calling the widget thus:
<<if def $party>>
<<if def $enemies>>