Skip to content
Andrey Vakhterov edited this page Jan 31, 2016 · 3 revisions

Workspace

Workspace is a storage of variables, event listeners and timers. All scripts on a server running within the workspace environment.

When a player runs script, it uses the workspace that is associated with his name. Workspace stores all variables created by player. You can change your workspace by command /workspace set <name>. Example:
/workspace set ws1 - switch to ws1
/> a = 1 - set variable a = 1
/workspace set ws2 - switch to ws2
/> println a - Error! a is not defined
/> a = 2 - set variable a = 2
/> println a - prints 2
/workspace set ws1 - switch back to ws1
/> println a - prints 1
If two players want to use shared variables, they want to switch to the same workspace.

All registered triggers (timers and events) are stored in workspace. When workspace is stopped, removed or reloaded, all triggers will also be stopped
/> interval(20) {println "spam!"} - start interval
/workspace stop - stop workspace and all intervals

When workspace are created:

  • on server startup, if exists autorun file associated with its name.
  • when you using command /> at first time.
  • when calling global.getOrCreateWorkspace(...).
  • by command /workspace create <name> or /workspace reload <name>.

When workspace are created, it tries to find file plugins/VarScript/autorun/<name>.groovy. If file exists, it will be executed first.

API

Clone this wiki locally