Skip to content

Commit bf1caf8

Browse files
authored
Update showscript3.md
1 parent 8645469 commit bf1caf8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

docs/showscript3.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,35 @@ for (int i=1; i<=42; i++) { // there are 42 frames in this video, named `001.png
279279

280280

281281

282+
### Global Variables
283+
284+
ShowScript 3 has the ability to get and set variables that can be accessed across shows. Currently, these values will not persist across server restarts.
285+
286+
`setGlobalVariable(String name, Object value)`:
287+
`getGlobalVariable(String name)`:
288+
`getGlobalVariable(String name, Object defaultValue)`:
289+
290+
```groovy
291+
// testShow.groovy
292+
293+
ticks(0) {
294+
setGlobalVariable("x", 5)
295+
}
296+
```
297+
298+
```groovy
299+
// test2.groovy
300+
ticks(0) {
301+
def x = getGlobalVariable("x") // this will be 5
302+
def y = getGlobalVariable("y") // this will be `null`
303+
def yWithDefaultValue = getGlobalVariable("y", 10) // this will default to 10
304+
}
305+
```
306+
307+
### Sharing data between shows: `export` and `load`
308+
309+
// TODO: add
310+
282311
### Accessing server info
283312

284313
ShowScript 3 has some convenience methods for accessing information from the Minecraft server that you can use in programming to make certain decisions.

0 commit comments

Comments
 (0)