A rather abnormal use of a StopEventList.

This is a weird one…

I was wondering if it’s possible to make an EventList, a StopEventList specifically, go through certain events if a certain property is set to true, and another event if it’s set to nil. In short, if a == true, show these events and if a == nil, show these others.

To catch the obvious question of why not simply trigger another StopEventList, I’m brutalizing somebody else’s code and finding a way to redirect this to another EventList would be an enormous amount of extra work. That’s why I was wondering if it’s possible to insert the check within the stopEventList itself.

Yes, although the implementation depends on how you want to track your position in each list. Here’s one approach that treats the lists as independent - they can have a different number of events and can reach the stopped state at different times.

modify StopEventList
	altList = []

	getAltState() {
		return altScriptState;

	advanceAltState() {
		if (altScriptState < altList.length())

	altScriptState = 1

	altDone() {

	doScript() {
		local idx, lst, done;
		if (check()) {
			idx = getScriptState();
			lst = eventList;
			done = &scriptDone;
		else {
			idx = getAltState();
			lst = altList;
			done = &altDone;

		if (idx >= 1 && idx <= lst.length()) {

	check() {
		return true;

And here is a simple test case.

testEvents: StopEventList
	eventList = ['Yes', 'Affirmative', 'Understood', 'OK']
	altList = ['No', 'Never', 'Negative', 'Stop']

	check() {
		_value ++;
		return (_value % 2 == 0 ? true : nil);
	_value = 1


modify WaitAction
	execAction() {

The modified StopEventList class will work as usual unless you override the check() function. If check() returns nil then it will display an event from altList.

That did it. I wanted only a few specific EventLists to have this behaviour, so all I have to do is make check() look for the state of the relevant property and return true or nil depending on its state.

Thank you very much, you saved me a really big load of work.

Crap, I’m still not done.

There’s one, and I think final, hitch I need to sort. In the above problem, both the plain EventList and the AltList are StopEventLists. For the behaviour I’m thinking of, it would work better if the altList where a ShuffledEventList instead.

…thinking about it, the best idea I get is to stick an embedded expression in the altList to fire a separate ShuffledEventList which contains the events previously in the altList. So if A == true, the regular StopEventList will fire and if A == nil, the altList will redirect things into the ShuffledEventList.

I know I can stick an embedded expression in an EventList like

EventList [ {: “<<something()>>” } ]
But I don’t know how to trigger an EventList from scratch (I’ve always worked by piggybacking on pre-existing code like atmospereList and the stuff I’m clumsily defacing right now). Can I do that?

Yes. You probably also want to redefine advanceAltState() to roll back around, or to do nothing at all.

myCrazyList: StopEventList
   altList = [ {: someShuffledEventList.doScript() } ]

   advanceAltState() {}

Haha, I deserved the “crazy” thing.

That worked perfectly, thank you.