forked from VanceCole/macros
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflags.js
28 lines (23 loc) · 806 Bytes
/
flags.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Create module flag on a scene
await canvas.scene.setFlag('myModule', 'myFlag', 'myValue');
// Retrieve module flag on a scene
let x = canvas.scene.getFlag('myModule', 'myFlag');
// Unset a module flag on a scene
await canvas.scene.unsetFlag('myModule', 'myFlag');
// Special syntax to unset a nested property
await canvas.scene.setFlag('myModule', 'myFlag.some.nested.-=property', null);
// React to changes to flag
Hooks.on('updateScene', (scene, data) => {
if (hasProperty(data, 'flags.myModule')) {
console.log(data);
}
});
// Flags can be arrays, objects, numbers etc as well
// Anything that can be stringified
let data = {
myString: 'hello',
myNum: 42,
myBool: true,
myArray: ['a','b','c']
}
await canvas.scene.setFlag('myModule', 'myFlag', data);