Updated Advanced Scripts (markdown)

thienbao860 2021-01-11 17:56:33 +07:00
parent d94dddaf72
commit 936a99dafd

@ -1,6 +1,8 @@
## Arguments
When calling a JavaScript placeholder, arguments may be supplied for extra functionality. These arguments are included after the placeholder name, and are separated by commas. When included, the arguments are passed to the script through an array called `args`.
When calling a JavaScript placeholder, arguments may be supplied for extra functionality. These arguments are included after the placeholder name, and are separated by commas (`,`) by default, can be changed via [configuration](https://github.com/PlaceholderAPI/Javascript-Expansion/wiki#configuration)
When included, the arguments are passed to the script through an array called `args`.
For example, the arguments in the placeholder `%javascript_example_test,3,args%` would be `test`, `3`, and `args`.
@ -123,6 +125,18 @@ viewCount();
Produces: ![data-example](https://i.imgur.com/rmuRQcQ.png) when parsed for the first and second times for a given player.
**NOTE:** If you have a straight-forward string key, you can use `DataVar` instead of `Data.get(String)`:
```Javascript
function viewCount() {
var views = DataVar.constantNum // in replacement of Data.get("constantNum")
return views;
}
viewCount();
```
**Valid Methods**:
- `Data.getData()` returns a `Map<String, Object>` of the entire placeholder script's data.
- `Data.clear()` removes all data.
@ -130,5 +144,6 @@ Produces: ![data-example](https://i.imgur.com/rmuRQcQ.png) when parsed for the f
- `Data.get(key)` returns the value stored under `key`.
- `Data.remove(key)` removes a key from the data.
- `Data.set(key, value)` stores a `value` under `key`.
- `Data.setIfNull(key, value)` stores a `value` under `key` only if this data doesn't exist in cache.
- `Data.isEmpty()` returns true if the data is empty; else false.
- `Placeholder.saveData()` saves the current data state to the data file.