The console doesn't maintain its own variables. As soon as you call :local, the next line doesn't have it. That's why "set" fails - there's no variable to be changed. The previous lines that reference the variable don't fail - they resolve the variable to a value of type "nothing".
You can workaround this by wrapping the whole script with "{" and "}". Alternatively, have it in "/system script", and then run it with "/system script run".
Thanks for the explanation.
So basically it comes down to:
- :local variables are local in scope
- the console only has only global scope, but no local scope
- there is a block statement `{}` in which there is local scope
That raises more questions:
- when nesting multiple block statements, are locals defined in the outer block valid for read/write in the inner block?
- when nesting multiple block statements, are locals defined in the inner block valid for read/write in the outer block?
- is a pair of `{}` the only way to start a block statement?
- is there some kind of "Language Reference" or, even better, EBNF or BNF specification of the language?
--jeroen