I've had the opportunity to 'pre-beta test' the 'setstate' functionality and I can attest that it's very powerful.
For example, in anticipation of 2.1.0 b1, I have written VA commands with turn off and on the speech responder...
VA Command 'Data Interface off' :
Execute external plugin 'EDDI 2.1.0-b1' and wait for return (with context = disablespeechresponder)
VA Command 'Data Interface on' :
Execute external plugin 'EDDI 2.1.0-b1' and wait for return (with context = enablespeechresponder)
Additionally, I've created a Boolean 'state object' variable called 'verbose', which controls how chatty the speech responder scripts can be...
VA Command 'Data Interface brief' :
Set Boolean [verbose] to False
Set Text [State Variable] to 'verbose'
Execute external plugin 'EDDI 2.1.0-b1' and wait for return (with context = setstate & Text Variables = State Variable)
VA Command 'Data Interface verbose' :
Set Boolean [verbose] to True
Set Text [State Variable] to 'verbose'
Execute external plugin 'EDDI 2.1.0-b1' and wait for return (with context = setstate & Text Variables = State Variable)
For example, using 'verbose', I can do this with the 'Galnet news published' script...
Code:
{if state.verbose:
{set regexfilter to "^(?!(.*Weekly|Report.*)|(.*Powerplay|Update.*)|(.*Starport|Update.*)).*$"}
{if len(event.items) = 1:
A new Galnet article has been published, entitled {event.items[0].title}.
{if match(event.items[item].title, regexfilter):
it reads
{Pause(1000)}
{event.items[0].content}.
}
|elif len(event.items) > 1:
{len(event.items)} new Galnet articles have been published.
{set item to 0}
{while item < len(event.items):
{if item = 0:
The first is entitled {event.items[item].title},
{if match(event.items[item].title, regexfilter):
and reads
{Pause(1000)}
{event.items[item].content}.
}
|elif item = 1:
The second is entitled {event.items[item].title},
{if match(event.items[item].title, regexfilter):
and reads
{Pause(1000)}
{event.items[item].content}.
}
|elif item = len(event.items) - 1:
The last is entitled {event.items[item].title},
{if not(match(event.items[item].title, regexfilter)):
and reads
{Pause(1000)}
{event.items[item].content}.
}
|else:
The next is entitled {event.items[item].title},
{if not(match(event.items[item].title, regexfilter)):
and reads
{Pause(1000)}
{event.items[item].content}
}
}
{set item to item + 1}
{Pause(1000)}
}.
}
|else:
{if len(event.items) = 1:
A new Galnet article has been published, entitled {event.items[0].title}.
|elif len(event.items) > 1:
{len(event.items)} new Galnet articles have been published. Their titles are
{set item to 0}
{while item < len(event.items):
{if item = len(event.items) - 1:
and {event.items[item].title}
|else:
{event.items[item].title},
}
{set item to item + 1}
}.
}
}
Another example, I can now repeat the landing pad location after 'docking granted'...
VA Command 'Pad location' :
Set integer [landingpad] value to the value of [EDDI docking granted landingpad]
Set Text [station] to [EDDI docking granted station]
Set Text [State Variable] to 'landingpad'
Execute external plugin 'EDDI 2.1.0-b1' and wait for return (with context = setstate & Text Variables = State Variable)
Set Text [State Variable] to 'station'
Execute external plugin 'EDDI 2.1.0-b1' and wait for return (with context = setstate & Text Variables = State Variable)
Set Text [Script] to 'Pad location'
Execute external plugin 'EDDI 2.1.0-b1' and wait for return (with context = speech & Text Variables = Script)
Speech Responder script called 'Pad location'
Code:
{set station to StationDetails(state.station)}
{if station.model = "Coriolis Starport" || station.model = "Orbis Starport" || station.model = "Ocellus Starport" || station.model = "Unknown Starport":
{Pause(500)}
Landing pad {state.landingpad} is at
{if state.landingpad = 1:
six o'clock near
|elif state.landingpad = 2:
six o'clock near
|elif state.landingpad = 3:
six o'clock far
|elif state.landingpad = 4:
six o'clock far
|elif state.landingpad = 5:
seven o'clock near
|elif state.landingpad = 6:
seven o'clock near
|elif state.landingpad = 7:
seven o'clock
|elif state.landingpad = 8:
seven o'clock far
|elif state.landingpad = 9:
eight o'clock near
|elif state.landingpad = 10:
eight o'clock far
|elif state.landingpad = 11:
nine o'clock near
|elif state.landingpad = 12:
nine o'clock near
|elif state.landingpad = 13:
nine o'clock
|elif state.landingpad = 14:
nine o'clock far
|elif state.landingpad = 15:
nine o'clock far
|elif state.landingpad = 16:
ten o'clock near
|elif state.landingpad = 17:
ten o'clock near
|elif state.landingpad = 18:
ten o'clock far
|elif state.landingpad = 19:
ten o'clock far
|elif state.landingpad = 20:
eleven o'clock near
|elif state.landingpad = 21:
eleven o'clock near
|elif state.landingpad = 22:
eleven o'clock
|elif state.landingpad = 23:
eleven o'clock far
|elif state.landingpad = 24:
twelve o'clock near
|elif state.landingpad = 25:
twelve o'clock far
|elif state.landingpad = 26:
one o'clock near
|elif state.landingpad = 27:
one o'clock near
|elif state.landingpad = 28:
one o'clock
|elif state.landingpad = 29:
one o'clock far
|elif state.landingpad = 30:
one o'clock far
|elif state.landingpad = 31:
two o'clock near
|elif state.landingpad = 32:
two o'clock near
|elif state.landingpad = 33:
two o'clock far
|elif state.landingpad = 34:
two o'clock far
|elif state.landingpad = 35:
three o'clock near
|elif state.landingpad = 36:
three o'clock near
|elif state.landingpad = 37:
three o'clock
|elif state.landingpad = 38:
three o'clock near
|elif state.landingpad = 39:
four o'clock near
|elif state.landingpad = 40:
four o'clock far
|elif state.landingpad = 41:
five o'clock near
|elif state.landingpad = 42:
five o'clock near
|elif state.landingpad = 43:
five o'clock
|elif state.landingpad = 44:
five o'clock far
|elif state.landingpad = 45:
five o'clock far
}
, as you enter with the green lights on your right.
}
This should give you a little taste as to the power of State objects. I hope you find this useful.
H/T to Cmdr Tkael for his excellent Galnet reader script.