2021-07-05 17:25:23 +02:00
|
|
|
WA.onInit().then(() => {
|
|
|
|
console.log('Trying to read variable "doorOpened" whose default property is true. This should display "true".');
|
|
|
|
console.log('doorOpened', WA.room.loadVariable('doorOpened'));
|
2021-07-02 11:31:44 +02:00
|
|
|
|
2021-07-05 18:29:34 +02:00
|
|
|
console.log('Trying to set variable "not_exists". This should display an error in the console, followed by a log saying the error was caught.')
|
|
|
|
WA.room.saveVariable('not_exists', 'foo').catch((e) => {
|
|
|
|
console.log('Successfully caught error: ', e);
|
|
|
|
});
|
2021-07-02 11:31:44 +02:00
|
|
|
|
2021-07-06 10:58:12 +02:00
|
|
|
console.log('Trying to set variable "myvar". This should work.');
|
|
|
|
WA.room.saveVariable('myvar', {'foo': 'bar'});
|
2021-07-02 11:31:44 +02:00
|
|
|
|
2021-07-06 10:58:12 +02:00
|
|
|
console.log('Trying to read variable "myvar". This should display a {"foo": "bar"} object.');
|
|
|
|
console.log(WA.room.loadVariable('myvar'));
|
|
|
|
|
|
|
|
console.log('Trying to set variable "config". This should not work because we are not logged as admin.');
|
|
|
|
WA.room.saveVariable('config', {'foo': 'bar'}).catch(e => {
|
|
|
|
console.log('Successfully caught error because variable "config" is not writable: ', e);
|
|
|
|
});
|
2021-07-05 17:25:23 +02:00
|
|
|
});
|