So just like the title says, I spent the day working on a widget that behaves the same way as a <<cyclinglink>>, and will also assign a value to a simple object's property, (in this case, $senses.smell.desc).
I got it working, fine, but I was curious about a quirk I stumbled over along the way.
This doesn't work:
@<</widget>>
But this does:
@<</widget>>
I've tried a bunch of different variations, and finally, while typing this all out, I found the only way I can get it to print out (let alone, work) correctly.
A works. B doesn't.
A.
<<= _arr>>
<<set _arr = _arr.push(_arr.shift())>>
<<set _arr = $args>> /% reinitialize? %/
<<= _arr>>
B.
<<= _arr>>
<<set _arr = _arr.push(_arr.shift())>>
<<= _arr>>
I'm curious what's happening to _arr here, because it seems to me that in the process of 'talking to' the $args, _arr is getting turned into an integer, which appears to be the length of $args at the time that the macro was called. (which might explain why it changes to 5 on the first recursion, then to 1 on the second and all subsequent recursions)
Comments
This line isn't right. It should be:
What you were doing was overwriting array with the return value of push (which is the length of the array, not its content as you expected). Hence _arr becoming an int. You should have just been pushing.