I've done some testing, and I figured out the var_declare function will only make script vars outside of blocks. I've tried changing the context of the script, but it only works when changing the context of the var block.
Although the "this script" block needs to be a sprite.
If anyone can help I'm looking for a way to declare variables using a block, but can function in another block.
This allows script variables to be created in the script that called the create [script V] [{var}] @delInput @verticalEllipsis @addInput :: variables block.
This is the intended way to use this function. If you wish to create variables within scripts, use the "create variables" library, or create a block that contains the extension function, and don't directly use the extension function. Plus, if you're creating script variables you're better off just using the script variables ((a)) @addInput block.
Yes, I would recommend that you avoid using the extension block directly, and instead us it in the context that it was used in the library. If at all possible you should just import the library you want and keep the blocks that you need rather than fiddling with the undocumented extension block.
Turns out things are a little strange, since this works.
I can see why this happens. The variable blocks know what context the variables are supposed to be in, before the script even gets ran. The create [script V] var [{var}] @delInput @verticalEllipsis @addInput :: variables block doesn't define the variables before script gets ran (like the script variables ((a)) @addInput block, or any upvars do), so snap doesn't know that a variable with that name will be created, so the block assumes it's supposed to be a global var. If you use the (var [ v] :: variables) block from the "create variables" library, it gets the variable at runtime, so it first checks if the variable name exists in the scope it was called in (unlike the variable block).
Of course I am just making an educated guess, I don't actually know how snap handles variable blocks, I'm just using what it looks like is happening to make this assumption.
The difference there, is that the script in the c-slot gets called after the variables are defined, whereas in the original post, the variables were being defined in the same script as the variable blocks.