Meaningful Shortcut Keys Listing.

 From:  Michael Gibson
2134.20 In reply to 2134.17 
Hi Burr,

> If you just put "script:var dir = moi.view.lightDirection; if ( dir.x == 1
> && dir.y == (.....continued....)" into a file named "fred.js" does it run
> by calling that file or does the js file need "other" properly formatted
> syntax to be functional?

To use the separate .js file style, you just need to remove the script: label at the front there.

That initial script: label is something special for the shortcut key editor to clarify whether the stuff typed there is an inline script or the name of a command. Actually there is a new experimental thing in the current v2 beta where you can eliminate that label if you want even from inline scripts because it will assume that the contents are inline script if it does not match a command name and does not end in a script file extension (like .js). But the script: label is required for inline scripts to work with version 1.0 though.

Also when you have the script in the separate .js file you don't need to jam it all on a single line like the inline script, and you can use an #include "library_filename.js" directive in the .js file to combine other script libraries into the current script file when it is executed. (the #include does not work with inline scripts, only with separate-file scripts).

Other than that all the syntax and stuff that is available to it is all the same as the inline script.


Then to use the separate script file there are 2 options - you can either place the full path to the script file in the Command part of the keyboard shortcut, like:
c:\scripts\MyScript.js or you can put just the file name itself, like: MyScript.js in which case it will look in a \scripts subfolder inside of MoI's main installation folder for it. This folder is not created by default, just create it if you want to place scripts there.

But you may want to use the full path method because then you won't need to move files around when you get new betas, etc...


Oh yeah one other thing is that it should be theoretically possible to make a script using the VBScript language instead of JavaScript, if you use a .vbs file extension for the script file instead of .js but I have not really tested that. Inline scripts are assumed to be JavaScript.


And actually come to think of it, you probably do not need to even remove that script: label at the front of the content for the separate file method, because it will actually be parsed by the script parser as a label and is legal JavaScript syntax I think. But you would normally remove it.

- Michael