diff --git a/Your-First-Script.md b/Your-First-Script.md index a46a901..18467ea 100644 --- a/Your-First-Script.md +++ b/Your-First-Script.md @@ -1,6 +1,6 @@ ## Creating Your Script -JavaScript-Expansions are all written in JavaScript (as the name implies). +JavaScript-Expansions scripts are all written in JavaScript coding language (as the name implies). Here is an example "Hello, world!" script: @@ -13,22 +13,24 @@ helloWorld(); ``` As you can see, the scripts return one value. - +**NOTE: ** Semicolons (`;`) are not required in JS language. However, this is required with multiple statements stacked in 1 line of script ## Using Your Script To use our hello_world script, first let's save the above as `hello_world.js` inside the `plugins/PlaceholderAPI/javascripts/` folder. Next, add it to the `plugins/PlaceholderAPI/javascript_placeholders.yml` file so the expansion knows to load it! +Specifying script engine is optional, as it will be defaulted to 'nashorn' if not initialized ```YAML hello_world: file: hello_world.js + engine: nashorn #optional, can be deleted ``` -Then, after reloading PlaceholderAPI plugin (`/papi reload`) you can use your placeholder! +Then, after reloading with JS-Expansion command (`/jsexpansion reload`) or PlaceholderAPI plugin (`/papi reload`), you can use your placeholder! -To test it, run `/papi parse me %javascript_hello_world%` +To test it, run `/papi parse me %javascript_hello_world%` (doesn't work in console) And ta-da! ![example](https://i.imgur.com/1RdtmUR.png)