GuideMe Scripting Engine
Moderator: 1885
- bobhill
- Explorer At Heart
- Posts: 164
- Joined: Tue Mar 15, 2016 8:49 pm
- Gender: Male
- Sexual Orientation: Straight
- I am a: None of the above
Re: GuideMe Scripting Engine
Deleted and combined in prior post
Last edited by bobhill on Thu Sep 27, 2018 2:42 pm, edited 1 time in total.
- bobhill
- Explorer At Heart
- Posts: 164
- Joined: Tue Mar 15, 2016 8:49 pm
- Gender: Male
- Sexual Orientation: Straight
- I am a: None of the above
Re: GuideMe Scripting Engine
PlayfulGuy, I know you've been away, but two issues I've identified in 1.5: getVariable doesn't process boolean scriptVars correctly (returns NaN) and if you use more that one parameter in a js function called in a script, in evaluateExpression, the comma isn't parsed out correctly, which causes an error. Not sure if these are addressed in 1.53.
I fixed them this way in the js file: (you may have a better way)
I fixed them this way in the js file: (you may have a better way)
Code: Select all
// We reach here if str was an alphanumeric string like a variable name, or just a string.
// Check to see if it's the name of a defined variable
var temp = scriptVars.get(str);
// jscriptLog(myName+"temp=" + temp);
if ( temp != undefined ) {
// It was a defined scriptvar so return it's value
if (temp === true || temp === false) return temp; //BOBHILL ADD
else if ( ! isNaN(temp) ) { //It's either a number or a string
// It's a number so just return it in the proper form
if ( parseInt(temp) == parseFloat(temp) ) return parseInt(temp); // Must be an int
else return parseFloat(temp); // It's a float. Not a root beer float, a number float.
}
else return temp; // Must be a string so just return it
}
Code: Select all
else {
// We have the start of some other expression element
// Find the next delimiter character (opening or closing parentheses, operator or space) **** OR COMMA **** BOBHILL
// If we are parsing a special function argument we ignore plus signs
if ( isFunctionArg ) while (end < expression.length && expression.charAt(end).search(/[\s\(\)\<\>\,\=\!\-\*\/\"]/) == -1 ) end++; //added comma BOBHILL
else while (end < expression.length && expression.charAt(end).search(/[\s\(\)\<\>\,\=\!\+\-\*\/\"]/) == -1 ) end++; //added comma BOBHILL
// jscriptLog(myName+"end=" + end + ", char=\"" + expression.charAt(end) + "\"");
- PlayfulGuy
- Explorer At Heart
- Posts: 801
- Joined: Sat Jul 07, 2012 10:08 pm
- Gender: Male
- Sexual Orientation: Bisexual/Bi-Curious
- I am a: Switch
- Dom/me(s): No domme
- Sub/Slave(s): No sub
- Location: British Columbia, Canada
Re: GuideMe Scripting Engine
Hi bobhill,bobhill wrote: ↑Wed Sep 19, 2018 12:20 pm I am calling a script from a GM page.
On the final page of the script, I have buttons to exit, such as "North", "South" and I have GM pages that these buttons should go to. Here's the updated code:
<snip>
I've tried various methods - and they do go to the correct GM page, but for some reason, the text portion of ShowScriptPage is displayed ("Something went wrong") before proceeding to the target GM page called from the script. I don't see anything in the js or gm logs that indicate why this is happening. I've stepped through the js code and and ShowScriptPage appears to be working. It recognizes the "Exit" command in the script and goes to the correct target GM page - it's just that ShowScriptPage displays the <text> component before 'target' is loaded.
EDITED: Updated script code, identified code in ScriptEngine.xml, and combined with next post
Update: this happens with Script Engine 1.50 and GM 0.3.7 combination but not with Engine 1.50 and GM 1.5.32b, so I guess it's a compatibility issue in one of the GM updates?
Sorry I haven't been around Milovana much lately, and when I have been I keep forgetting to check this thread.
The code snippets you posted are interesting. I'm very curious about what you're building and how it works.
I have encountered this issue of that page text displaying before an overRide kicks in with GM 3.6 and 3.7. You can safely remove the text node from the ShowScriptPage page in ScriptEngine.xml and that should fix it. That was only there as an error indication so if the code crashed at least you got some indication that something was wrong. Otherwise you would just see a blank page.
I'll reply to your other post separately.
PG
I'd rather be stroking!
New tease downloader for GuideMe with EOS support.
Downloads of teases I've converted to GuideMe
New tease downloader for GuideMe with EOS support.
Downloads of teases I've converted to GuideMe
- PlayfulGuy
- Explorer At Heart
- Posts: 801
- Joined: Sat Jul 07, 2012 10:08 pm
- Gender: Male
- Sexual Orientation: Bisexual/Bi-Curious
- I am a: Switch
- Dom/me(s): No domme
- Sub/Slave(s): No sub
- Location: British Columbia, Canada
Re: GuideMe Scripting Engine
Interesting. I've never had need to use boolean variables in a script before so never encountered that. I've added your fix to the code for the next release.bobhill wrote: ↑Wed Sep 26, 2018 8:33 pm PlayfulGuy, I know you've been away, but two issues I've identified in 1.5: getVariable doesn't process boolean scriptVars correctly (returns NaN) and if you use more that one parameter in a js function called in a script, in evaluateExpression, the comma isn't parsed out correctly, which causes an error. Not sure if these are addressed in 1.53.
I fixed them this way in the js file: (you may have a better way)
Code: Select all
// We reach here if str was an alphanumeric string like a variable name, or just a string. // Check to see if it's the name of a defined variable var temp = scriptVars.get(str); // jscriptLog(myName+"temp=" + temp); if ( temp != undefined ) { // It was a defined scriptvar so return it's value if (temp === true || temp === false) return temp; //BOBHILL ADD else if ( ! isNaN(temp) ) { //It's either a number or a string // It's a number so just return it in the proper form if ( parseInt(temp) == parseFloat(temp) ) return parseInt(temp); // Must be an int else return parseFloat(temp); // It's a float. Not a root beer float, a number float. } else return temp; // Must be a string so just return it }
Code: Select all
else { // We have the start of some other expression element // Find the next delimiter character (opening or closing parentheses, operator or space) **** OR COMMA **** BOBHILL // If we are parsing a special function argument we ignore plus signs if ( isFunctionArg ) while (end < expression.length && expression.charAt(end).search(/[\s\(\)\<\>\,\=\!\-\*\/\"]/) == -1 ) end++; //added comma BOBHILL else while (end < expression.length && expression.charAt(end).search(/[\s\(\)\<\>\,\=\!\+\-\*\/\"]/) == -1 ) end++; //added comma BOBHILL // jscriptLog(myName+"end=" + end + ", char=\"" + expression.charAt(end) + "\"");
As for the multiple arguments to a javascript function I did run into that bug myself after version 1.53 was released so that will be in the next release as well. As usual I've no idea when I'll get around to that.
Thanks,
PG
I'd rather be stroking!
New tease downloader for GuideMe with EOS support.
Downloads of teases I've converted to GuideMe
New tease downloader for GuideMe with EOS support.
Downloads of teases I've converted to GuideMe
- bobhill
- Explorer At Heart
- Posts: 164
- Joined: Tue Mar 15, 2016 8:49 pm
- Gender: Male
- Sexual Orientation: Straight
- I am a: None of the above
Re: GuideMe Scripting Engine
Hi PG,
Thanks for the replies, they are very helpful!
A new question, when you return: In 1.53 and GM 3.7 I am having problems with GlobalButton command, as the ScriptEngine treats it as regular text and it never runs through the "processCommands" function. I've run through the java debugger and haven't been able to identify an error yet. Thanks! BH
Thanks for the replies, they are very helpful!
Great - that's what I did.You can safely remove the text node from the ShowScriptPage page in ScriptEngine.xml and that should fix it.
For the boolean test, I used the strict equality initially and it worked with GM 3.7, but I had to drop to loose equality "==" when testing with some of the other GM versions. That really doesn't make sense to me, but it works and I was tired of debugging it.I've added your fix to the code for the next release.
It's a big project and I never have enough time, but I've finally finished most of the 'infrastructure'. Even the small coding parts tend to take me a lot of trial and error to work out syntax, etc. Next, I've been working on story and scripts. I need to do more work, but will release a partial version when it's far enough along.The code snippets you posted are interesting. I'm very curious about what you're building and how it works.
A new question, when you return: In 1.53 and GM 3.7 I am having problems with GlobalButton command, as the ScriptEngine treats it as regular text and it never runs through the "processCommands" function. I've run through the java debugger and haven't been able to identify an error yet. Thanks! BH
- bobhill
- Explorer At Heart
- Posts: 164
- Joined: Tue Mar 15, 2016 8:49 pm
- Gender: Male
- Sexual Orientation: Straight
- I am a: None of the above
Re: GuideMe Scripting Engine
Hi PG - two more items I've found. I just want to mention, otherwise I will forget.
I'm having trouble using if with <= or >=. evaluateExpression seems to have problem parsing both together, but does fine if only one is used. I just adjusted to use < or > not <= or >=, I haven't found the exact point in the code where it happens yet.
This works, 31 evaluates to a number:
This doesn't work, 30 evaluates to a string:
Also, in the Wait.xml, if you list an image as an argument, the Wait page gets the full image path, which is also retrieved in getImage, so the path is repeated twice, resulting in image not found. I was able to work around by specifically using the "Image" parameter with the image name:
I'm having trouble using if with <= or >=. evaluateExpression seems to have problem parsing both together, but does fine if only one is used. I just adjusted to use < or > not <= or >=, I haven't found the exact point in the code where it happens yet.
This works, 31 evaluates to a number:
Code: Select all
if (vElapsedTime < 31) goto Begs30
Code: Select all
if (vElapsedTime <= 30) goto Begs30
Code: Select all
Wait <vWait> minutes Image 161.jpg "Rest for <vWait> minutes"
- PlayfulGuy
- Explorer At Heart
- Posts: 801
- Joined: Sat Jul 07, 2012 10:08 pm
- Gender: Male
- Sexual Orientation: Bisexual/Bi-Curious
- I am a: Switch
- Dom/me(s): No domme
- Sub/Slave(s): No sub
- Location: British Columbia, Canada
Re: GuideMe Scripting Engine
bobhill wrote: ↑Mon Oct 22, 2018 4:06 am A new question, when you return: In 1.53 and GM 3.7 I am having problems with GlobalButton command, as the ScriptEngine treats it as regular text and it never runs through the "processCommands" function. I've run through the java debugger and haven't been able to identify an error yet. Thanks! BH
Hi Bob,bobhill wrote: ↑Sun Oct 28, 2018 10:19 am Hi PG - two more items I've found. I just want to mention, otherwise I will forget.
I'm having trouble using if with <= or >=. evaluateExpression seems to have problem parsing both together, but does fine if only one is used. I just adjusted to use < or > not <= or >=, I haven't found the exact point in the code where it happens yet.
Also, in the Wait.xml, if you list an image as an argument, the Wait page gets the full image path, which is also retrieved in getImage, so the path is repeated twice, resulting in image not found. I was able to work around by specifically using the "Image" parameter with the image name:
Code: Select all
Wait <vWait> minutes Image 161.jpg "Rest for <vWait> minutes"
I did a quick setup of a Guideme 3.7 installation with the release code for script engine 1.53 modified so the javascript files load properly, and I'm unable to reproduce these errors. Here's the script I used to test.
Code: Select all
// Testing stuff for bobhill
imageFolder Models/Sarah // Sets the default image folder
GlobalButton Yes Mistress
temp = 30
if (temp <= 30) *.jpg Temp is 30 or less
set DEBUG
Wait <temp> minutes Image *.jpg "Rest for <temp> minutes"
Wait <temp> minutes Image no-06.jpg "Rest for <temp> minutes"
unset DEBUG
exit
I know you've made a couple other changes to the script engine code to fix some other issues and I have not replicated those code changes for this test, so perhaps one of your other changes has introduced some other issue.
If I have time and energy later I'll go back and update the code with the changes you reported earlier and see what happens. And if you could post the ScriptEngine,js file you are using and the relevant portion of the script you're building I will do some tests and try to nail it down.
Regards,
PG
I'd rather be stroking!
New tease downloader for GuideMe with EOS support.
Downloads of teases I've converted to GuideMe
New tease downloader for GuideMe with EOS support.
Downloads of teases I've converted to GuideMe
- PlayfulGuy
- Explorer At Heart
- Posts: 801
- Joined: Sat Jul 07, 2012 10:08 pm
- Gender: Male
- Sexual Orientation: Bisexual/Bi-Curious
- I am a: Switch
- Dom/me(s): No domme
- Sub/Slave(s): No sub
- Location: British Columbia, Canada
Re: GuideMe Scripting Engine
Hi Bob,bobhill wrote: ↑Wed Sep 19, 2018 12:20 pm I am calling a script from a GM page.
On the final page of the script, I have buttons to exit, such as "North", "South" and I have GM pages that these buttons should go to. Here's the updated code:
<snip>
I've tried various methods - and they do go to the correct GM page, but for some reason, the text portion of ShowScriptPage is displayed ("Something went wrong") before proceeding to the target GM page called from the script. I don't see anything in the js or gm logs that indicate why this is happening. I've stepped through the js code and and ShowScriptPage appears to be working. It recognizes the "Exit" command in the script and goes to the correct target GM page - it's just that ShowScriptPage displays the <text> component before 'target' is loaded.
This is the part of ShowScriptPage that is being executed. Upon the 'return' command, is when the text is displayed.
Code: Select all
// Check for an Exit command (exit the script) if ( page.text == "exit" ) { // Exit the script and go somewhere else jscriptLog(myName+"Exiting script " + page.filename); target = ExitCurrentScript(); overRide.setPage(target); return; // And go do it. }
I've been digging in to this and have discovered that it seems to be an issue with the overRide.setPage() command in the newer GM versions. In the code snippet you posted above you can see the command
Code: Select all
overRide.setPage(target);
Code: Select all
overRide.setDelay(target,"0","","hidden","","","");
Just above that you'll also find another reference to setPage() in the code that checks for a gotoPage command. It looks like
Code: Select all
overRide.setPage(page.text);
Code: Select all
overRide.setDelay(page.text,"0","","hidden","","","");
Regards,
PG
I'd rather be stroking!
New tease downloader for GuideMe with EOS support.
Downloads of teases I've converted to GuideMe
New tease downloader for GuideMe with EOS support.
Downloads of teases I've converted to GuideMe
- bobhill
- Explorer At Heart
- Posts: 164
- Joined: Tue Mar 15, 2016 8:49 pm
- Gender: Male
- Sexual Orientation: Straight
- I am a: None of the above
Re: GuideMe Scripting Engine
PG - Sorry, I've been away and haven't had a chance to respond. Thanks for looking at this. I'll try to run your code first to confirm I'm not doing something stupid and then I'll recheck any changes I made in the js vs a clean download.PlayfulGuy wrote: ↑Sat Nov 03, 2018 5:46 pm
I did a quick setup of a Guideme 3.7 installation with the release code for script engine 1.53 modified so the javascript files load properly, and I'm unable to reproduce these errors. Here's the script I used to test.When I run that I get the screen saying Temp is 30 or less with the global button I defined, and then I get the wait page with a random image, and then the wait page with the specified image exactly as I'd expect.Code: Select all
// Testing stuff for bobhill imageFolder Models/Sarah // Sets the default image folder GlobalButton Yes Mistress temp = 30 if (temp <= 30) *.jpg Temp is 30 or less set DEBUG Wait <temp> minutes Image *.jpg "Rest for <temp> minutes" Wait <temp> minutes Image no-06.jpg "Rest for <temp> minutes" unset DEBUG exit
I know you've made a couple other changes to the script engine code to fix some other issues and I have not replicated those code changes for this test, so perhaps one of your other changes has introduced some other issue.
Ok, thanks. If the steps above don't show anything clearly wrong to me, then I'll post the js and script. It may be a few days before I can reply.PlayfulGuy wrote: ↑Sat Nov 03, 2018 5:46 pm
If I have time and energy later I'll go back and update the code with the changes you reported earlier and see what happens. And if you could post the ScriptEngine,js file you are using and the relevant portion of the script you're building I will do some tests and try to nail it down.
- bobhill
- Explorer At Heart
- Posts: 164
- Joined: Tue Mar 15, 2016 8:49 pm
- Gender: Male
- Sexual Orientation: Straight
- I am a: None of the above
Re: GuideMe Scripting Engine
Great, thanks! I'll make these changes!PlayfulGuy wrote: ↑Wed Nov 07, 2018 8:16 pm I've been digging in to this and have discovered that it seems to be an issue with the overRide.setPage() command in the newer GM versions.
- bobhill
- Explorer At Heart
- Posts: 164
- Joined: Tue Mar 15, 2016 8:49 pm
- Gender: Male
- Sexual Orientation: Straight
- I am a: None of the above
Re: GuideMe Scripting Engine
Hi PG - I reran my script and I am not able to reproduce my error and your script works fine. If I have the problem again, I'll let you know.PlayfulGuy wrote: ↑Sat Nov 03, 2018 5:46 pm
I did a quick setup of a Guideme 3.7 installation with the release code for script engine 1.53 modified so the javascript files load properly, and I'm unable to reproduce these errors. Here's the script I used to test.
Separately, given the addTimer functionality in GM, would it be possible to implement a similar command in the script engine that would change the right pane html but keep the same GM page? My specific use is to have changing text/buttons on right pane with a single video playing on left pane.
- PlayfulGuy
- Explorer At Heart
- Posts: 801
- Joined: Sat Jul 07, 2012 10:08 pm
- Gender: Male
- Sexual Orientation: Bisexual/Bi-Curious
- I am a: Switch
- Dom/me(s): No domme
- Sub/Slave(s): No sub
- Location: British Columbia, Canada
Re: GuideMe Scripting Engine
Excellent!
I've actually had a couple times where I would have liked the same functionality myself, and have thought about ways to implement it, but haven't settled on a good solution. Do you have a suggestion on how you would like to see it? How would you like to be able to code it?bobhill wrote: ↑Thu Dec 27, 2018 11:12 pm Separately, given the addTimer functionality in GM, would it be possible to implement a similar command in the script engine that would change the right pane html but keep the same GM page? My specific use is to have changing text/buttons on right pane with a single video playing on left pane.
I don't know if Guideme lets you change the buttons in a timer. Have to look at that.
Anyway, the script engine wasn't really designed with this functionality in mind and it's structured to process commands in a very linear, line by line sort of fashion. If you have some thoughts on how you would like to see it done it might help stimulate my creativity a bit. And since I'd like to have the functionality myself I have some motivation
Cheers,
PG
I'd rather be stroking!
New tease downloader for GuideMe with EOS support.
Downloads of teases I've converted to GuideMe
New tease downloader for GuideMe with EOS support.
Downloads of teases I've converted to GuideMe
- bobhill
- Explorer At Heart
- Posts: 164
- Joined: Tue Mar 15, 2016 8:49 pm
- Gender: Male
- Sexual Orientation: Straight
- I am a: None of the above
Re: GuideMe Scripting Engine
I had not thought about it, but in v1.5, with the Enhanced Page Command, the default if the image field is blank is to keep the same, but it changes the page (and the right pane)(so leaving the image blank would not work for this purpose) and under the old notation, a quotation mark also keeps the same image. So, using the old syntax, would it make sense to use a different marker that could indicate to change the right pane only and not to change the GM page, such as a "#" or "%"?PlayfulGuy wrote: ↑Fri Dec 28, 2018 6:05 am Do you have a suggestion on how you would like to see it? How would you like to be able to code it?
As a potential sample, here's something adapted from the GM I'm working on:
- Spoiler: show
Edit - p.s. - this is very exciting, I'm glad you are interested in adding, also!!
- PlayfulGuy
- Explorer At Heart
- Posts: 801
- Joined: Sat Jul 07, 2012 10:08 pm
- Gender: Male
- Sexual Orientation: Bisexual/Bi-Curious
- I am a: Switch
- Dom/me(s): No domme
- Sub/Slave(s): No sub
- Location: British Columbia, Canada
Re: GuideMe Scripting Engine
I've spent a bit of time looking at this and have a comment on a question you ask in your sample code, and a thought on adding the timer functionality.bobhill wrote: ↑Fri Dec 28, 2018 5:42 pmI had not thought about it, but in v1.5, with the Enhanced Page Command, the default if the image field is blank is to keep the same, but it changes the page (and the right pane)(so leaving the image blank would not work for this purpose) and under the old notation, a quotation mark also keeps the same image. So, using the old syntax, would it make sense to use a different marker that could indicate to change the right pane only and not to change the GM page, such as a "#" or "%"?PlayfulGuy wrote: ↑Fri Dec 28, 2018 6:05 am Do you have a suggestion on how you would like to see it? How would you like to be able to code it?
As a potential sample, here's something adapted from the GM I'm working on:
As you said, I'm not sure you can add buttons, I'm still working on this in GM. I may need to have the buttons on the page from the start of the video and enable / disable them when applicable. Philo did mention adding a target page to the Delay commands (it needs to be both overRide and Guide, I think), which would increase flexibility around content.
- Spoiler: show
Edit - p.s. - this is very exciting, I'm glad you are interested in adding, also!!
First, in your sample code you had
Code: Select all
// replace 'next' with 30, which is the Delay
// could we have a label to go to when video is complete and if no label then it's assumed there's a 'wait' + button
// what can change in right pane - text and buttons or only text?
Video media/video/model.mp4 00:00:00 00:15:00, 30, EndLabel {
<vHeaderText>\n
gt Start stroking - once per second.\n\n
}
vTemp = fChangeXP(30)
You also ask if we can have a label to go to when the video completes. This is probably doable too, but I think you can actually get the same effect now with one of the following (but I'm too lazy to test it):
Code: Select all
Video media/video/model.mp4 00:00:00 00:15:00 wait // Wait means wait for a button press
" 30 { // The timer here should make it continue even if there's no button pressed
<vHeaderText>\n
gt Start stroking - once per second.\n\n
}
vTemp = fChangeXP(30)
goto EndLabel // And then you go to EndLabel
OR the following should show 15 seconds of video then goto EndLabel
Code: Select all
// Next means go to next page, which actually means continue processing with the next
// command, so the goto kicks in.
Video media/video/model.mp4 00:00:00 00:15:00 next
" {
<vHeaderText>\n
gt Start stroking - once per second.\n\n
}
vTemp = fChangeXP(30)
goto EndLabel // And then you go to EndLabel
I'd rather be stroking!
New tease downloader for GuideMe with EOS support.
Downloads of teases I've converted to GuideMe
New tease downloader for GuideMe with EOS support.
Downloads of teases I've converted to GuideMe
- PlayfulGuy
- Explorer At Heart
- Posts: 801
- Joined: Sat Jul 07, 2012 10:08 pm
- Gender: Male
- Sexual Orientation: Bisexual/Bi-Curious
- I am a: Switch
- Dom/me(s): No domme
- Sub/Slave(s): No sub
- Location: British Columbia, Canada
Re: GuideMe Scripting Engine
Looking at the code for the script engine and the way it's structured, and looking at the addTimer() documentation and the other options it has, it occurred to me that the simplest approach is to add a Timer command to the text block processing so you could saybobhill wrote: ↑Fri Dec 28, 2018 5:42 pmI had not thought about it, but in v1.5, with the Enhanced Page Command, the default if the image field is blank is to keep the same, but it changes the page (and the right pane)(so leaving the image blank would not work for this purpose) and under the old notation, a quotation mark also keeps the same image. So, using the old syntax, would it make sense to use a different marker that could indicate to change the right pane only and not to change the GM page, such as a "#" or "%"?PlayfulGuy wrote: ↑Fri Dec 28, 2018 6:05 am Do you have a suggestion on how you would like to see it? How would you like to be able to code it?
Edit - p.s. - this is very exciting, I'm glad you are interested in adding, also!!
Code: Select all
InitialImage.jpg {
Initial text
Timer 10 New text 1
Timer 10 New text 2
Timer 10 Image newImage.jpg
}
The above would show "Initial text" first with InitialImage.jpg, and set the timer to change the text 10 seconds later to "New text 1", and then 10 seconds later to "New text 2", and 10 seconds later change the image to newImage.jpg
This actually fits very nicely with how the script engine processes commands now, and the implementation of it would be similar to how I handle buttons, so I'd say it's looking pretty good.
And it would work with videos too.
And then if I smarten up the page command so it detects videos and handles the other options you suggest as well, things start looking pretty sweet.
I'm making no promises on when I might be able to get that done, but that gave me the creative boost I needed
Cheers,
PG
I'd rather be stroking!
New tease downloader for GuideMe with EOS support.
Downloads of teases I've converted to GuideMe
New tease downloader for GuideMe with EOS support.
Downloads of teases I've converted to GuideMe
Who is online
Users browsing this forum: hadtodoittoem and 3 guests