View Single Post
Old 12-16-2020, 03:49 PM   #107
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
Quote:
Originally Posted by chaley View Post
@capink: a random thought. I think that you can get a usable form of action branching if you add an option to run an action only if a template returns a value. You would add this option as another column in the chain links table. Doing this would permit creating a chain where actions are run only if they make sense for the current book.

You could simplify things by requiring use of a zero-parameter stored template. That would ensure you only need a name in the table, and as a side effect would make it easier for the user to test the template.
Funny you mention templates as way to implement flow control, because I had the same idea when writing the plugin, but instead of a separate column for the template, make a template based action that can be placed ahead of an action(s) to optionally jump (skip) over it. The idea is that the template returns a number, if it returns 1 the chain goes on to the next action, if it returns 2 it will skip the next action to the one that follows it, ... and so on (a number more than the total actions remaining would stop the chain).

The current code even have an instance variable in the chain_loop called step_length (default is 1), that is used by the chain loop to jump to the next action (and is ofcourse reset to default after each jump). I was not sure whether this would be useful or not so I deferred it.

Quote:
Originally Posted by chaley View Post
You could go a bit further and add a check for what the template returns (another column?). If the template returns that value then the action is run. If it does not, the action isn't. That would permit using the same stored template in multiple places.
This bit about a separate column for a check is not clear to me.
capink is offline   Reply With Quote