You cannot use the var or function keywords in a .skin command. Trying to do so gives you an unexpected token, syntax error in the JavaScript console.
The only workaround is to wrap the code in an eval() call.
Numbered Steps to Reproduce Problem:
1. Compile this code:
client
verb
TestJSvar()
winset(src, null, {"command=".skin \\"var myvar=7;console.log(myvar)\\"""})
TestJSvar_eval()
winset(src, null, {"command=".skin \\"eval('var myvar=7;console.log(myvar)')\\"""})
2. Host and connect to the world through the webclient.
3. Open the JavaScript console for your browser.
4. Test both verbs and notice how the eval() version works fine, but the other one just gives you "SyntaxError: Unexpected token var".
I should also point out that even without using the var or function keyword, you also cannot use semicolons ";" to chain together multiple commands, or it will complain that they are also unexpected tokens. A rather interesting and strange workaround is to use ampersands "&" instead.
Expected Results:
The code does what it's supposed to do.
Actual Results:
Really annoying errors.
Does the problem occur:
Every time? Or how often?
In other games?
In other user accounts?
On other computers?
I'm sure the problem would occur on the Moon if there was someone there to test it.
When does the problem NOT occur?
Hopefully, it doesn't occur in the future, once it gets fixed.
Did the problem NOT occur in any earlier versions? If so, what was the last version that worked?
I don't know. It was probably around as long as the webclient.
Workarounds:
Use eval().