Hi there,
I'm currently exploring the features of the Eos editor, and I have some questions about what exactly I am able to do programmatically in Eos.
For example, am I able to set images via the API? And if so, what would a path look like? Let's assume I have a gallery called foo with an image bar.jpg. Is it possible to do something like: pages.setImage('foo/bar.jpg')?
In a similar vein, can I set the option labels and their corresponding target pages for a choice programmatically?
And finally, can I construct a timer programmatically, in terms of the duration, visual style and behaviour?
These features, which essentially allow you to build a page via the API, would be very helpful since they would greatly decrease the number of pre-defined (i.e. static) pages required to capture randomized behaviour.
Cheers
Eos API Questions
-
- Explorer At Heart
- Posts: 559
- Joined: Sun Jul 06, 2014 2:11 pm
- Gender: Male
- Sexual Orientation: Open to new ideas!
- I am a: Slave
Re: Eos API Questions
There is no such API to build pages. You can however build pages were certain parts are determined by JavaScript code.
You can have eval actions at many places to modify variables etc., this works also for the actions of choices.
You can use JavaScript to calculate the duration of a timer.
You cannot use JavaScript for the name of an image or the options of choices.
I solved the issue with the images using a massive if-then-else-cascade. I wanted a page were 1 of about 100 images was shown based on certain conditions. So there are just 1 hundred ifs with respective image actions.
As this is very time consuming to do in the editor, I just exported the JSON opended it in a text-editor and generated the if statements. I might even have used some script to do that. The structure of the JSON file is very easy to understand, so generating it is also an option for more complicated things.
You can have eval actions at many places to modify variables etc., this works also for the actions of choices.
You can use JavaScript to calculate the duration of a timer.
You cannot use JavaScript for the name of an image or the options of choices.
I solved the issue with the images using a massive if-then-else-cascade. I wanted a page were 1 of about 100 images was shown based on certain conditions. So there are just 1 hundred ifs with respective image actions.
As this is very time consuming to do in the editor, I just exported the JSON opended it in a text-editor and generated the if statements. I might even have used some script to do that. The structure of the JSON file is very easy to understand, so generating it is also an option for more complicated things.
-
- Curious Newbie
- Posts: 2
- Joined: Fri Mar 06, 2020 11:14 pm
Re: Eos API Questions
Thank you for the reply!
I tried your approach with an eval, followed by an if-then-else construction. This is a good option to avoid having many static pages, but the downside is that your 'dynamic' pages become very messy very quickly
Could you share the JS code for setting a timer's duration? That would be much appreciated.
I tried your approach with an eval, followed by an if-then-else construction. This is a good option to avoid having many static pages, but the downside is that your 'dynamic' pages become very messy very quickly
Could you share the JS code for setting a timer's duration? That would be much appreciated.
- lolol2
- Explorer At Heart
- Posts: 507
- Joined: Mon Feb 20, 2017 10:33 am
- Gender: Male
- Sexual Orientation: Straight
Re: Eos API Questions
I also miss the option to set images and audio from the script part and use variables to build up the names. Would be so much more flexible to show stuff based on conditions.
Or do I get this wrong?
Why not having one if/else loop to check the condition, if it not match just show a random pic out of the galery with the other 99 pics. When the condition match then show the one special image.kerkersklave wrote: ↑Thu Mar 26, 2020 1:37 pm I wanted a page were 1 of about 100 images was shown based on certain conditions. So there are just 1 hundred ifs with respective image actions.
Or do I get this wrong?
My creations:
- Spoiler: show
-
- Explorer At Heart
- Posts: 559
- Joined: Sun Jul 06, 2014 2:11 pm
- Gender: Male
- Sexual Orientation: Open to new ideas!
- I am a: Slave
Re: Eos API Questions
Well, what I wanted to do is to randomly generate a maze. So I basically had one page that was shown over and over again and kept track of the location of the user. But of course I wanted to show the same picture each time when you came back to a room.
So I could not just select a random one each time but had to randomize in the beginning and then pic the picture from a list.
The only way to achieve that is to have a if-branch for each picture.
-
- Explorer At Heart
- Posts: 559
- Joined: Sun Jul 06, 2014 2:11 pm
- Gender: Male
- Sexual Orientation: Open to new ideas!
- I am a: Slave
Re: Eos API Questions
I put the whole thing into one if with "true" as condition. So it does not show in the main action list of the page. This way I could still edit that page without scrolling to all these ifs. It is not ideal but it is a hack.JohnDoe91741 wrote: ↑Thu Mar 26, 2020 1:58 pm I tried your approach with an eval, followed by an if-then-else construction. This is a good option to avoid having many static pages, but the downside is that your 'dynamic' pages become very messy very quickly
You have to do it in the settings of the timer. There, you can switch to JavaScript expressions for the duration.JohnDoe91741 wrote: ↑Thu Mar 26, 2020 1:58 pm Could you share the JS code for setting a timer's duration? That would be much appreciated.
The reason for there being no API to change pictures and images is apparently that the viewer is doing some preloading of the next pages, so it has to know what these are. Of course my approach makes it preload all images immediately. And indeed there is a little pause before visiting that page the first time.
-
- Explorer
- Posts: 42
- Joined: Sun Jan 04, 2015 7:22 pm
- Gender: Male
- Sexual Orientation: Straight
Re: Eos API Questions
It would be great if we could preload the picture manually and then set it later via code.
Who is online
Users browsing this forum: Baidu [Spider], Frenchsissysarah and 5 guests