Initial Tutorial

Nathan Glover 2018-03-08 15:15:10 -05:00
parent 0b3e9dc2d6
commit 5d9faa4b9e

38
Your-First-Script.md Normal file

@ -0,0 +1,38 @@
## Creating Your Script
JavaScript-Expansions are all written in JavaScript (as the name implies).
Here is an example "Hello, world!" script:
```JavaScript
function helloWorld() {
return "Hello, world!";
}
helloWorld();
```
As you can see, the scripts return one value.
## 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!
```YAML
hello_world:
expression: 'file: hello_world.js'
type: string
```
Then, after reloading PAPI (`/papi reload`) you can use your placeholder!
To test it, run `/papi parse %javascript_hello_world%`
## Advanced Scripts
You can save data with your script and also access the Bukkit API!
// coming soon