état is not defined
/ state is not defined
are the key informations here, a javascript variable defined in one script is not available for the other widgets, because each script has its own execution scope (see Scope - MDN Web Docs Glossary: Definitions of Web-related terms | MDN and var - JavaScript | MDN, very important concepts when working with javascript).To share data between widgets, either
- use a variable widget to hold the state
// save_button
var state = stateGet('...')
set('variable_widget_id', state)
// load_button
var state = get('variable_widget_id')
stateSet(state)
- use
setVar()
andgetVar()
to store the value in the widget's custom variables
// save_button
var state = stateGet('...')
setVar('load_button', 'my_var', state)
// load_button
var state = getVar('this', 'my_var')
stateSet(state)
- use the
globals
object that is shared between all scripts (not recommended)
// save_button
var state = stateGet('...')
globals.my_state = state
// load_button
var state = globals.my_state
stateSet(state)
- use the
storage
object (see Save and Load states directly through editor? - #9 by suspect), but it's currently broken and will be fixed in next release.