Page 1 of 1

EOS creating choice actions with script

Posted: Sun Sep 29, 2024 5:43 pm
by Moonwhore
does any javascript pros know if it's possible to create choice actions with a script
basically i have a large set and want to choose a subset and make them options in a choice module, but there are a looot of combinations

Re: EOS creating choice actions with script

Posted: Sun Sep 29, 2024 6:26 pm
by kerkersklave
Could be give an example of what you want?

Choice actions can only have a fixed set of choices with fixed labels, you can just hide choices via a javascript condition. So you could make a big choice action listing all possible choices and enable just the subset you need. If there are two many options to do that you can give them generic names like A,B,C, use a say option to list the active choices. If there are too many active options to show them all you can use a text input and ask the reader to type in his choice.

Re: EOS creating choice actions with script

Posted: Mon Sep 30, 2024 12:21 am
by Moonwhore
well say the user is given a choice between 3 tasks, out of 25 total possible different tasks.
would be 2300 different combinations, way too obnoxious to manually create the modules for it
but maybe it's not possibe to do with a script idk.

Re: EOS creating choice actions with script

Posted: Mon Sep 30, 2024 8:16 am
by Thamrill
Unfortunately it's not directly possible. One alternative to achieve something similar is to have the choice action to have only options identifiers (e.g., "A", "B", "C") and have a "Say" action that can be procedurally written to associate a task to one of the options

Re: EOS creating choice actions with script

Posted: Mon Sep 30, 2024 12:55 pm
by kerkersklave
Do you mean something like that: https://milovana.com/webteases/showteas ... d7eb3516cb
I made the example for 5 tasks, but it should be easy enough to scale up to 25.

Get source-code: https://milovana.com/webteases/geteossc ... d7eb3516cb

Re: EOS creating choice actions with script

Posted: Tue Oct 01, 2024 2:55 pm
by PlayfulGuy
kerkersklave wrote: Mon Sep 30, 2024 12:55 pm Do you mean something like that: https://milovana.com/webteases/showteas ... d7eb3516cb
I made the example for 5 tasks, but it should be easy enough to scale up to 25.

Get source-code: https://milovana.com/webteases/geteossc ... d7eb3516cb
Nice solution!

You could even add a function to the init module like recordTask(name, page) to build two lists, one that holds the task name and the other the name of the page that implements that task. Then you just step through the list of page names going to the next one in sequence to perform the tasks.

Good stuff!

Re: EOS creating choice actions with script

Posted: Wed Oct 02, 2024 4:55 pm
by kerkersklave
PlayfulGuy wrote: Tue Oct 01, 2024 2:55 pm You could even add a function to the init module like recordTask(name, page) to build two lists, one that holds the task name and the other the name of the page that implements that task. Then you just step through the list of page names going to the next one in sequence to perform the tasks.
Not sure what you want exactly. After the choice-step you've got a list currentChoices of the names of tasks. Do you want to use the goto-Action with a dynamic page name to go through the tasks? So you need a mapping from task names to page names, as you do not want to use the same name for both? In Javascript you can define a mapping like this:

Code: Select all

var taskToPage = {"task 1": "pageSomething", "task 2": "pageWhatever"}
and then look it up like this:

Code: Select all

taskToPage["task 1"]

Re: EOS creating choice actions with script

Posted: Mon Oct 14, 2024 3:06 am
by PlayfulGuy
kerkersklave wrote: Wed Oct 02, 2024 4:55 pm
PlayfulGuy wrote: Tue Oct 01, 2024 2:55 pm You could even add a function to the init module like recordTask(name, page) to build two lists, one that holds the task name and the other the name of the page that implements that task. Then you just step through the list of page names going to the next one in sequence to perform the tasks.
Not sure what you want exactly. After the choice-step you've got a list currentChoices of the names of tasks. Do you want to use the goto-Action with a dynamic page name to go through the tasks? So you need a mapping from task names to page names, as you do not want to use the same name for both? In Javascript you can define a mapping like this:

Code: Select all

var taskToPage = {"task 1": "pageSomething", "task 2": "pageWhatever"}
and then look it up like this:

Code: Select all

taskToPage["task 1"]
I wasn't really asking anything there, I was complimenting you on your solution and observing that it opened further possibilities... The way I worded my reply was just awkward when I said "you could even add" with a generic "you", not meaning you specifically. Sorry about that. I try to be more clear in my replies but blew it there.

PG