Page 12 of 13
Re: GuideMe Scripting Engine
Posted: Wed May 22, 2019 7:23 pm
by RemiHiyama
mantrid wrote: Wed May 22, 2019 9:44 amStrange, my globalScript section has less than 3586 lines. You find a listing in jscript.log. Are you sure that you are using SE 1.53?
That's what the name of the file would suggest I've got.
I think I'm going to need to try commenting out different parts and seeing what happens.
Nice trick. Indeed, the function is called now without an error. But the button always stops the execution of th page and jumps to the next one.
That's really weird. I've followed the code around a few times and can't see where it would do that.
Now i also see the misunderstanding. You and the docs write "expression" but mean "assignment". In computer science all these are expressions:
Well, if I'm understanding the docs right (and I may not be), there are expressions that aren't assignments in the engine. But only expressions that are assignments will actually get run through the expression processor in certain places. (Like button targets.)
Re: GuideMe Scripting Engine
Posted: Wed May 22, 2019 9:12 pm
by mantrid
RemiHiyama wrote: Wed May 22, 2019 7:23 pm
mantrid wrote: Wed May 22, 2019 9:44 amStrange, my globalScript section has less than 3586 lines. You find a listing in jscript.log. Are you sure that you are using SE 1.53?
That's what the name of the file would suggest I've got.
Length of 'ScriptEngine.js' I use is 3500 lines.
Nice trick. Indeed, the function is called now without an error. But the button always stops the execution of th page and jumps to the next one.
That's really weird. I've followed the code around a few times and can't see where it would do that.
It's in 'ScriptEngine.xml'. The call of 'overRide.addButton(String target, ...)' has a non-empty target argument.
I'm not sure whether empty targets are allowed. If not, it may be impossible.
Now i also see the misunderstanding. You and the docs write "expression" but mean "assignment". In computer science all these are expressions:
Well, if I'm understanding the docs right (and I may not be), there are expressions that aren't assignments in the engine. But only expressions that are assignments will actually get run through the expression processor in certain places. (Like button targets.)
Of course there are expressions that aren't assignments: expressions in SE syntax. Probably (i did not checked it any further)
- SE first tries to evaluate In SE syntax. If that fails:
- If it is no assignment: Treat is as literal (text)
- If it is an assignment: Try to evaluate it in JavaScript like syntax. If that fails:
- Treat is as literal
Button labels seem to be processed differently. First as literal (is it a valid label or page?), ....
IMHO this is a little bit odd. But if one knows the rules, it's not a problem.
Re: GuideMe Scripting Engine
Posted: Thu May 23, 2019 4:54 am
by RemiHiyama
mantrid wrote: Wed May 22, 2019 9:12 pmLength of 'ScriptEngine.js' I use is 3500 lines.
That's what I've got too. I think that line number would have to be with the included files inlined in memory, not the file as it was. (Since it's also saying it's an xml error, not a javascript error.)
If I comment out the includes for htmlTools.js and PlayingCards.js, it no longer gives that error and instead goes
Code: Select all
2019-05-22T23:47:21,828 ERROR Jscript - FileRunScript ReferenceError: "ListAllScripts" is not defined. (pageScript#21)
org.mozilla.javascript.EcmaError: ReferenceError: "ListAllScripts" is not defined. (pageScript#21)
Which seems peculiar.
It's in 'ScriptEngine.xml'. The call of 'overRide.addButton(String target, ...)' has a non-empty target argument.
Huh.
The wiki says target is mandatory, but it doesn't say an empty target won't work either...
Re: GuideMe Scripting Engine
Posted: Thu May 23, 2019 8:03 am
by mantrid
RemiHiyama wrote: Thu May 23, 2019 4:54 am
mantrid wrote: Wed May 22, 2019 9:12 pmLength of 'ScriptEngine.js' I use is 3500 lines.
That's what I've got too. I think that line number would have to be with the included files inlined in memory, not the file as it was. (Since it's also saying it's an xml error, not a javascript error.)
If I comment out the includes for htmlTools.js and PlayingCards.js, it no longer gives that error and instead goes
I never included these files. This explains while my GlobalJavascript section is shorter. You should find a listing of this section 'jscript.log' (search for "GlobalJavascriptText"). If not, maybe debugging must be enabled in GuideMe. (I only activated debugging, none of the Javascript debugging options)
Code: Select all
2019-05-22T23:47:21,828 ERROR Jscript - FileRunScript ReferenceError: "ListAllScripts" is not defined. (pageScript#21)
org.mozilla.javascript.EcmaError: ReferenceError: "ListAllScripts" is not defined. (pageScript#21)
Which seems peculiar.
This seems to be the error I reported in the
GM thread
Workaround for me is to insert 'ScriptEngine.js' directly.
Bobhill claims this is a setup issue (here, a few posts above and in the GM thread).
At least it is proven now that I'm not hallucinating
It's in 'ScriptEngine.xml'. The call of 'overRide.addButton(String target, ...)' has a non-empty target argument.
Huh.
The wiki says target is mandatory, but it doesn't say an empty target won't work either...
I think it is not a problem: It should be possible to define a button in HTML (GuideMe supports it) and connect it to a Javascricpt action. This also avoids modification of SE.
Re: GuideMe Scripting Engine
Posted: Fri May 31, 2019 4:28 am
by PlayfulGuy
Hi all,
Sorry I haven't been around much and checking in here. There are several issues being discussed so I'll make a couple posts to clarify what I can. I'll start with this:
RemiHiyama wrote: Tue May 21, 2019 3:48 pm
Is this supposed to work in GuideMe 3.8? When I try opening any of the examples in the 1.53 package in that GM version, it pops up two blank javascript error windows and then just sits on "Something went wrong".
No, but yes. Guideme 3.6 (and higher) changed the way javascript files are loaded. In older versions of Guideme the contents of the javascript file had to be wrapped in a <globaljavascript> and "CDATA" tag like this:
Code: Select all
<GlobalJavascript>
<![CDATA[
function myFunction() (
// contents of function
}
]]>
</GlobalJavascript>
Note the first two lines, and the last two lines.
Starting with Guideme 3.6 this is no longer required and you have to remove those lines to get the javascript to load properly. So the example above would just look like this:
Code: Select all
function myFunction() (
// contents of function
}
You can edit the ScriptEngine.js file and remove those lines, and then it should work. If you are using any of the other javascript files included in the script engine package you will need to edit those as well. I've been trying to get an updated package released but life is not cooperating.
mantrid wrote: Sun May 19, 2019 10:14 pm
Just a small small cross posting.
Today I lost a few hours to the GuideMe state data bug. Unfortunately the workarounds stated
here did not help. The problem for me was that the functions defined in 'ScriptEngine.js' couldn't be found, including 'ExitAllScripts()' and 'loadScript(...)'.
The workaround (for me) is to insert 'ScriptEngine.js' directly. Thats not wired enough: If I now overwrite the state file of the old version (with the 'include' statement) with the state file of the new version, the old version now works to.
The full report can be found in the
GuideMe thread.
Mantrid, see the above in response to RemiHiyama. This is why the javascript functions were not being found, and why inserting the contents of the ScriptEngine.js file directly in the xml file fixed it.
This is completely different from, and separate from the state data bug.
I have no explanation for how overwriting the state file of the old version with the state file of the new version would cause the old version to work. The old version will never "include" the ScriptEngine.js file until that file is updated as described above. Unless Guideme is somehow saving the ScriptEngine code in the new state file. Don't know about that.
I'll try and review the other posts here and see if I can add anything, and try to clarify what the state file bug is more clearly. At the moment I only have about half an hour and then I have to go to work, so it may be tomorrow before I can post more comments.
PG
GuideMe Scripting Engine and GuideMe state data bug
Posted: Fri May 31, 2019 4:44 am
by PlayfulGuy
For clarity, "the state data bug" is a bug in Guideme versions 3.6 and higher.
It may also be present in Guideme versions 3.3 and 3.4 but I did not spend much time using those versions as they had too many bugs to be considered stable.
As of Guideme version 3.8 this bug is still not fixed.
What the bug is:
In the affected versions of Guideme, the saved state data gets corrupted under certain circumstances when your javascript code uses arrays, and particularly arrays of arrays. The Guideme Script Engine uses these extensively. The result is that if you close Guideme while a Script Engine script is running, the state usually gets corrupted, and you can't reload the tease later and continue from where you left off. The error manifests in different ways including 404 page not found errors, or the tease just not working at all.
In my testing I found that usually you could close Guideme while a script was running, then reload it later and continue without any problem, but at this point the state file is corrupted and you can not exit Guideme a second time, and then load and continue the tease a second time.
If the script completes and you are at some "regular" Guideme page before you close Guideme, the script engine is basically "unloaded" and the bug does not occur.
Unfortunately this is a bug in Guideme itself, and we need philo to fix it, or someone else has to download a fork of Guideme, figure out how it all works, and find and fix the bug. I don't have the time and energy to do that, and likely never will, even though I really want to.
Hope that helps clarify things.
PG
Re: GuideMe Scripting Engine
Posted: Fri May 31, 2019 4:54 am
by PlayfulGuy
mantrid wrote: Wed May 22, 2019 9:44 am
Now i also see the misunderstanding. You and the docs write "expression" but mean "assignment". In computer science all these are expressions:
- globalButton Test, foo = findTarget("floor_1-",1,20)
- Test
- foo = findTarget("floor_1-",1,20)
- findTarget("floor_1-",1,20)
- "floor_1-"
- 1
- 20
Exactly right. I did use the term "expression" rather loosely. In the context of the script engine expressions means assignments, or the expression part of an IF command. I generally wrote the documentation assuming the audience was primarily non-programmers.
PG
Re: GuideMe Scripting Engine
Posted: Fri May 31, 2019 5:04 am
by PlayfulGuy
mantrid wrote: Tue May 21, 2019 6:42 pm
What I really need is a button that executes a JS function without interrupting the page actions (interrupting the sound, because I'm interested in EStim teases)
I think you've figured this out already but Guidme doesn't support this yet. There was a request for enhancement, but I'm not holding my breath that it will ever get implemented. A button always ends the current page and tries to go to some other page. You can't have a button just run some javascript and stay on the same page.
Timers are the only guideme feature that can be used to change things on the page without going to a new page, but they are still somewhat limited in what can be changed (page image and page text if I recall correctly).
PG
Re: GuideMe Scripting Engine
Posted: Fri May 31, 2019 1:30 pm
by mantrid
PlayfulGuy wrote: Fri May 31, 2019 4:28 am
You can edit the ScriptEngine.js file and remove those lines, and then it should work. If you are using any of the other javascript files included in the script engine package you will need to edit those as well. I've been trying to get an updated package released but life is not cooperating.
Yes, that's it: 'Include' treats files differently depending on suffix. Changing it to .xml works too (and is backward compatible).
I have no explanation for how overwriting the state file of the old version with the state file of the new version would cause the old version to work. The old version will never "include" the ScriptEngine.js file until that file is updated as described above. Unless Guideme is somehow saving the ScriptEngine code in the new state file. Don't know about that.
GuideMe saves all JS objects, i.e. code and data. That's why it works with the other state file.
Re: GuideMe Scripting Engine
Posted: Sat Jun 01, 2019 10:39 pm
by RemiHiyama
PlayfulGuy wrote: Fri May 31, 2019 4:28 amStarting with Guideme 3.6 this is no longer required and you have to remove those lines to get the javascript to load properly.
Huh. I thought I'd -tried- that and it still didn't work, but after you posted this I finally got it working. Thank you.
mantrid wrote: Thu May 23, 2019 8:03 amI think it is not a problem: It should be possible to define a button in HTML (GuideMe supports it) and connect it to a Javascricpt action. This also avoids modification of SE.
Were you able to get things working with this workaround? I tried it, but while it displays the button, nothing happens when pushing it.
Re: GuideMe Scripting Engine
Posted: Sun Jun 02, 2019 12:50 am
by mantrid
RemiHiyama wrote: Sat Jun 01, 2019 10:39 pm
mantrid wrote: Thu May 23, 2019 8:03 amI think it is not a problem: It should be possible to define a button in HTML (GuideMe supports it) and connect it to a Javascricpt action. This also avoids modification of SE.
Were you able to get things working with this workaround? I tried it, but while it displays the button, nothing happens when pushing it.
No, did not tested it. Was just a quick idea. Obviously the HTML engine of GuideMe does not execute Javascript.
Another option is to use Ren'Py (a few people here on Milovana use it).
I also had the idea of writing a Script Engine to HTML translator. The story is translated into a set of HTML pages and commands like buttons are macros that generate JavaScript code snippets. The whole story logic is then executed in a browser. That would be lightweight easy to maintain, very flexible and not to difficult to implement.
But currently I'm busy with my EStim software and sound library (and maybe a tease). Probably I'm also not the first person who has this idea ...
Re: GuideMe Scripting Engine
Posted: Sun Jun 02, 2019 4:26 pm
by philo
RemiHiyama wrote: Sat Jun 01, 2019 10:39 pm
mantrid wrote: Thu May 23, 2019 8:03 amI think it is not a problem: It should be possible to define a button in HTML (GuideMe supports it) and connect it to a Javascricpt action. This also avoids modification of SE.
Were you able to get things working with this workaround? I tried it, but while it displays the button, nothing happens when pushing it.
There is code in the latest version which will hopefully be released soon.
I was playing around with converting the whole screen to html and replacing all the java buttons etc into html.
I accidentally delete all the html I had done to test this, so I don't have any examples at the moment.
However It did involve setting the status text in the browser (not displayed in GuideMe) to a pipe separated string, I think it was something like setting it to
"ButtonClick|Set|UnSet|scriptVar|javaScript"
Where Set, UnSet, scriptVar and javaScript are the normal things you set the buttons to in the XML
So setting window.status in the button click event in javascript (this would be javascript that would be in your html page, not in guideme) so runs in the embedded browser in GuideMe, not in the script engine (if that makes sense).
Re: GuideMe Scripting Engine
Posted: Sat Feb 11, 2023 11:10 pm
by whd
Hello
It is a very old Subject, hopefully someone is still reading this.
I try to make a snakes and ladders tease by script engine.
Why not in EOS Tease? Because I don't like the picture size which in my opinion is too small on EOS.
Second, with offline tease, I could do it with videos instead of pictures, which I may include later.
Is there a possibility to work with arrays in the script? I get errors which say, my array is not defined. I used JSript naming for the arrays:
e.g. EdgeList.splice(1, 0, Girl<GirlNumber>) to add Girlx to the array and later
EdgerGirlPosition = EdgeList.indexOf(Girl<GirlNumber> ,-1) to find out if the array EdgeList does contain Girlx.
Cheers
whdmusic
Re: GuideMe Scripting Engine
Posted: Sun Feb 12, 2023 2:18 pm
by PlayfulGuy
whdmusic wrote: Sat Feb 11, 2023 11:10 pm
Hello
It is a very old Subject, hopefully someone is still reading this.
I try to make a snakes and ladders tease by script engine.
Why not in EOS Tease? Because I don't like the picture size which in my opinion is too small on EOS.
Second, with offline tease, I could do it with videos instead of pictures, which I may include later.
Is there a possibility to work with arrays in the script? I get errors which say, my array is not defined. I used JSript naming for the arrays:
e.g. EdgeList.splice(1, 0, Girl<GirlNumber>) to add Girlx to the array and later
EdgerGirlPosition = EdgeList.indexOf(Girl<GirlNumber> ,-1) to find out if the array EdgeList does contain Girlx.
Cheers
whdmusic
Hi, and thanks for the interest in the script engine. The picture size is my biggest complaint with EOS as well.
What you want is sort of possible (more below). The latest script engine version released does not support arrays directly, but I have actually been looking into adding that support for myself recently. I can't make any promises on when it might happen though. I'm trying to get a newer version released (I've made a lot of improvements over time) but time and motivation are an issue.
The way you could do it though is to include some javascript functions in the <GlobalJavascript> section of your tease, then use those functions in your script. For example, write an addGirl() function that does what you need, then in your script you can say
Code: Select all
Girl = "Marcy"
temp = addGirl(Girl)
To get a girl you would write a getGirl() function then use something like
Code: Select all
EdgerGirlPosition = getGirl(GirlNumber)
Or
EdgerGirlPosition = getGirl("Marcy")
I can't remember exactly what was supported in version 1.53, but I have a much newer and more advanced version of the script engine I would be happy to share with you. In fact I'm willing to just post it as-is for anyone that's interested and then answer questions and deal with issues later. My current version is much better than the previous version.
I'm away on vacation at the moment so wouldn't be able to do anything until next week probably, but let me know your thoughts. This could help get me moving on that long overdue update.
Hope those ideas help, and I'm happy to help further, but like I said I'm away and you'll have to be patient. I only checked in this morning because I had a bit of time to kill. I'll be back home late this week, and more settled and back into the swing of things next week.
Cheers,
PG
Re: GuideMe Scripting Engine
Posted: Mon Feb 27, 2023 11:29 pm
by whd
sorry for my late answer.
I did find a solution. Instead of using an array I used variables with numbers what comes out to the same behavior like an array.
See attachment, which works fine.
At last, the most disturbing point is the delay from pushing button "edge" to changing screen to "hold it". But everything else runs as wanted. I might try also to include video instead of pictures, but I am afraid, speed will slow down too much. But trying is better than guessing.
array like variables:
--------------------------
PageEdged:
set UserEdged
if ( NumberEdges > 0 ) NumberEdges = NumberEdges - 1
EdgeListLength = EdgeListLength + 1
EdgeList<EdgeListLength> = <GirlNumber>
----------------------------
I store the edging girlnumber in the last position of the "array". Instead from an array with name EdgeListXY (XY as position in the array), I use single variables with name EdgeList and a counter. This works fine. Since I read out a random girl out of the "array", sort order is not important.