GuideMe (TeaseMe v2.0) - Current Build 0.4.4

Webteases are great, but what if you're in the mood for a slightly more immersive experience? Chat about Tease AI and other offline tease software.

Moderator: 1885

RemiHiyama
Explorer At Heart
Explorer At Heart
Posts: 203
Joined: Thu Feb 28, 2019 3:30 pm
I am a: Switch

Re: GuideMe (TeaseMe v2.0) - Current Build 0.4.4

Post by RemiHiyama »

EroticDevelopment wrote: Fri Feb 18, 2022 4:20 am put this in a new debug.bat).
Maybe we should consider adding this to the build?

Anyway, yeah, the problem was that issue that shows up periodically where startup.state ends up containing something like this:

Code: Select all

<scope><![CDATA[ignore]]></scope>
And then when the GuideSettings constructor is run, ComonFunctions.getSavedObject hits an error trying to turn "ignore" into a Scriptable, and then because of the way the exception is handling it just returns the string "ignore". Then it tries to cast that into a Scriptable object that fails and nothing catches the exception.

I'm not really sure of the best way to handle this.
Auto: Replaces selected instances of the word "not" with the word "definitely".
User avatar
PlayfulGuy
Explorer At Heart
Explorer At Heart
Posts: 792
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 (TeaseMe v2.0) - Current Build 0.4.4

Post by PlayfulGuy »

ashikoki wrote: Mon Feb 14, 2022 5:12 pm Hello, does this currently work with GuideMe? https://milovana.com/webteases/showtease.php?id=52907
I only get a black screen when trying to load the XML file.

Edit: I've tried another tease and it loaded and worked just fine.
No it doesn't. There's some odd code in that one that the downloader doesn't convert properly.
It's on my list.

And please post questions related to the downloader in that thread so I can more easily keep track.
Link in my signature.

PG
User avatar
PlayfulGuy
Explorer At Heart
Explorer At Heart
Posts: 792
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 (TeaseMe v2.0) - Current Build 0.4.4

Post by PlayfulGuy »

FCK88 wrote: Fri Feb 18, 2022 4:31 am
But now, of course, I've encountered a NEW problem(sorry for being an annoying a** :blush: ).. When I used the MiloDownloader that supports downloading EOS teases I don't get shown any pics in GuideMe.. Maybe you know a solution to that problem as well?

Thanks in advance :-)

FCK88
Please post in the Downloader thread (link below) with info on the tease or teases you tried to download. I've not encountered that issue with any teases.

PG
User avatar
PlayfulGuy
Explorer At Heart
Explorer At Heart
Posts: 792
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 (TeaseMe v2.0) - Current Build 0.4.4

Post by PlayfulGuy »

FCK88 wrote: Fri Feb 18, 2022 4:31 am
But now, of course, I've encountered a NEW problem(sorry for being an annoying a** :blush: ).. When I used the MiloDownloader that supports downloading EOS teases I don't get shown any pics in GuideMe.. Maybe you know a solution to that problem as well?

Thanks in advance :-)

FCK88
I believe I ran across the tease you had this issue with. Is it this one (number 54718) published recently that has the name and everything in all asian characters?
There was a unique problem in the conversion of that one caused by the language characters. It's fixed in the new version of the downloader (version 0.96c) which I uploaded yesterday.

Cheers!

PG
User avatar
FCK88
Explorer At Heart
Explorer At Heart
Posts: 132
Joined: Tue Mar 26, 2013 8:29 pm
Gender: Male
Sexual Orientation: Straight
I am a: Switch
Location: Silkeborg, Denmark

Re: GuideMe (TeaseMe v2.0) - Current Build 0.4.4

Post by FCK88 »

PlayfulGuy wrote: Mon Feb 21, 2022 10:21 pm
FCK88 wrote: Fri Feb 18, 2022 4:31 am
But now, of course, I've encountered a NEW problem(sorry for being an annoying a** :blush: ).. When I used the MiloDownloader that supports downloading EOS teases I don't get shown any pics in GuideMe.. Maybe you know a solution to that problem as well?

Thanks in advance :-)

FCK88
I believe I ran across the tease you had this issue with. Is it this one (number 54718) published recently that has the name and everything in all asian characters?
There was a unique problem in the conversion of that one caused by the language characters. It's fixed in the new version of the downloader (version 0.96c) which I uploaded yesterday.

Cheers!

PG
Hey - no it was an older tease called Gynocracy Prison by Kerkersklave.. But after I downloaded the newest version of the Milodownloader it downloaded just fine(somehow my antivirus blocked the access to a file called beta.jpg and when I gave the program the green light to bypass the detection of files like that it suddenly downloaded like it should :-P )
wheresmything
Explorer
Explorer
Posts: 62
Joined: Tue Nov 16, 2010 2:02 pm

Re: GuideMe (TeaseMe v2.0) - Current Build 0.4.4

Post by wheresmything »

Going bonkers with parseInt, would appreciate assistance. I've greatly abbreviated the script below while trying to retain it well enough to see what's going on. The challenge I'm having is that I've added a variable "vModifier" as the last bit of the global java. Everywhere it is called, I see the correct value, and on the "Ask" page the math works with the random value and vModifier being added together as intended.

Where I'm running into trouble is that I would like to update the vModifier on the Allow, Ruin, and No pages by a static amount (i.e vModifier + 3) and no matter how I try, the math doesn't work (I've tried many different parseInts, along with static numbers, variabilized increments, etc). I'd also want that value to be persisent throughout the session (resetting only on a new session or restart).

So if anyone could help me work out how to have the value of vModifier be 0 on startup, and then add a number to it (that then remains as an offset) when it hits any of the Allow, Ruin, or No pages, I'd really appreciate it.

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<Tease>
  <Title>At thier whim v11</Title>
  <Author id="">
    <Name>""</Name>
  </Author>

  <MediaDirectory>At thier whim</MediaDirectory>

  <Settings>
    <AutoSetPageWhenSeen>false</AutoSetPageWhenSeen>
	<ForceStartPage>true</ForceStartPage>
  </Settings>

  <GlobalJavascript>
  <![CDATA[

    //Difficulty settings: Very Easy = 0, Easy = 1, Medium = 2, Hard = 3, Very Hard = 4, Insane = 5, TESTING = 6
	var arrayModel = [
		{ Name: "TEST", 	sortOrder:  999, Sets: [
			{Difficulty: 6, Path: "Test\\Test-1" },
			{Difficulty: 6, Path: "Test\\Test-2" },
			{Difficulty: 6, Path: "Test\\Test-3" },
			{Difficulty: 6, Path: "Test\\Test-4" },
			{Difficulty: 6, Path: "Test\\Test-5" },
			{Difficulty: 6, Path: "Test\\Test-6" }]},
		];

	//Time is in seconds
	var arrayDifficulty = [
		{ Level: "Very Easy", 	DelayMin: 0, 	DelayMax: 0, AllowChance: 0, RuinChance: 0},
		{ Level: "Easy", 		DelayMin: 0, 	DelayMax: 0, AllowChance: 0, RuinChance: 0},
		{ Level: "Medium", 		DelayMin: 0, 	DelayMax: 0, AllowChance: 0, RuinChance: 0},
		{ Level: "Hard", 		DelayMin: 0, 	DelayMax: 0, AllowChance: 0, 	RuinChance: 0},
		{ Level: "Very Hard", 	DelayMin: 0, 	DelayMax: 0, AllowChance: 0, 	RuinChance: 0},
		{ Level: "Insane", 		DelayMin: 0, 	DelayMax: 0, AllowChance: 0, 	RuinChance: 0},
		{ Level: "TEST", 		DelayMin: 3, 	DelayMax: 3, AllowChance: 33, 	RuinChance: 33},
	];

	var arrayAllow = [
		"yes",
	];
	
	var arrayRuin = [
		"oops",
	];

	var arrayDeny = [
		"no",
	];
	
	var vModifier = 0;  //Modifier adds to the "Ask" roll, slowly increasing the chance of success with each model
	
]]>
  </GlobalJavascript>

  <Pages>
    <Page id="start">
      <Text>Who'd you like to see?</Text>
      <Image id="Welcome.jpg" />
      <javascript>
		  <![CDATA[
		  function pageLoad() {
  			var i = 0;
  			var vSelected = parseInt(scriptVars.get("vSelected"),10);
			

  			jscriptLog("vSelected = " + vSelected);
  			if ( isNaN(vSelected) || vSelected == undefined ) {
  			  vSelected = 0;
  			  scriptVars.put("vSelected", vSelected);
  			  jscriptLog("vSelected initialized to " + vSelected);
  			}

			for (i=0; i < arrayModel.length; i++) {
				var vName = arrayModel[i].Name;
				var vSort = arrayModel[i].sortOrder.toString();		//sortOrder parameter needs to be a string
				overRide.addButton("Confirm", vName, "", "", "setModel(" + i +")", "", "", vSort, false, "");
			}
			
			var i = parseInt(scriptVars.get("vSelected"),10);

  			overRide.setHtml("Who'd you like to see this time?  <br/>Last time you visited " + arrayModel[vSelected].Name + "<br/><br/>Current modifier value = " + vModifier);
			overRide.addButton("Confirm", "Revist Last", "", "", "setModel(" + i +")", "", "", "", false, "");
			overRide.addButton("Confirm", "You Choose", "", "", "setRandomModel()", "", "");
			}

			function setModel(i)
			{
				scriptVars.put("vSelected", i);

				// And randomly select a set to use and save this for other pages to access
				var vSet = Math.floor(Math.random()*arrayModel[i].Sets.length);
				scriptVars.put("vSet", vSet);  
			}
			
			function setRandomModel()
			{
				var i = Math.floor(Math.random()*arrayModel.length);
				
				scriptVars.put("vSelected", i);
				var vSet = Math.floor(Math.random()*arrayModel[i].Sets.length);
				scriptVars.put("vSet", vSet); 
			}
		  ]]>
	  </javascript>
    </Page>

	<Page id="Confirm">
      <Text>Seeing this means something went wrong on the page - Confirm</Text>
	  <Image id="test.jpg" />
		<javascript>
			<![CDATA[
				function pageLoad() {
					var i = parseInt(scriptVars.get("vSelected"),10);
					var vSet = parseInt(scriptVars.get("vSet"),10);
					var vPath = arrayModel[i].Sets[vSet].Path;
					var vDiff = arrayModel[i].Sets[vSet].Difficulty;
					var vLvl = arrayDifficulty[vDiff].Level;

					var text = arrayModel[i].Name + ":<br/>Are you ready to begin?<br/><br/>";

			  overRide.setHtml(text);
			  overRide.image = vPath + "/ready.jpg";

				}

			]]>
		</javascript>

	<Button target="start">Someone Else</Button>
	<Button target="ChangeSet">Different Set</Button>
	<Button target="Wait">Let's Begin</Button>
	</Page>

	<Page id="ChangeSet">
      <Text>Seeing this means something went wrong on the page - ChangeSet</Text>
		<javascript>
			<![CDATA[
				function pageLoad() {
				
				var i = parseInt(scriptVars.get("vSelected"),10);
				scriptVars.put("vSelected", i);
				var vSet = Math.floor(Math.random()*arrayModel[i].Sets.length);
				scriptVars.put("vSet", vSet);  
				}
			]]>
		</javascript>
	<Delay seconds="0" target="Confirm" style="hidden"/>
	</Page>
	
	<Page id="Retry">
      <Text>Seeing this means something went wrong on the page - ChangeSet</Text>
		<javascript>
			<![CDATA[
				function pageLoad() {
				
				var i = parseInt(scriptVars.get("vSelected"),10);
				scriptVars.put("vSelected", i);
				var vSet = Math.floor(Math.random()*arrayModel[i].Sets.length);
				scriptVars.put("vSet", vSet);  
				var vPath = arrayModel[i].Sets[vSet].Path;
				var vDiff = arrayModel[i].Sets[vSet].Difficulty;
				var vLvl = arrayDifficulty[vDiff].Level;				
				}
			]]>
		</javascript>
	<Delay seconds="0" target="Wait" style="hidden"/>
	</Page>
	
	<Page id="Wait">
      <Text>Seeing this means something went wrong on the page - Wait</Text>
		<javascript>
			<![CDATA[
				function pageLoad() {
					var i = parseInt(scriptVars.get("vSelected"),10);
					var vSet = parseInt(scriptVars.get("vSet"),10);
					var vPath = arrayModel[i].Sets[vSet].Path;
					var vDiff = arrayModel[i].Sets[vSet].Difficulty;
					
					var vMinDel = arrayDifficulty[vDiff].DelayMin;
					var vMaxDel = arrayDifficulty[vDiff].DelayMax;

					var vDelay = Math.floor(Math.random() * (vMaxDel - vMinDel + 1)) + vMinDel;

			  overRide.setHtml(arrayModel[i].Name + ":  Waiting...");
			  overRide.image = vPath + "/Wait/*.jpg";
			  overRide.setDelay("Ask", vDelay, "", "hidden", "", "", "");

				}

			]]>
		</javascript>
  	  <!-- <Button target="Ask">proceed-test</Button> -->
	</Page>
	
	
	<Page id="Ask">
      <Text>Seeing this means something went wrong on the page - Ask</Text>
		<javascript>
			<![CDATA[
				function pageLoad() {
					var i = parseInt(scriptVars.get("vSelected"),10);

					var vSet = parseInt(scriptVars.get("vSet"),10);
					var vPath = arrayModel[i].Sets[vSet].Path;
					var vDiff = arrayModel[i].Sets[vSet].Difficulty;

					var vAllowCase = 100 - parseInt(arrayDifficulty[vDiff].AllowChance,10);
					var vRuinCase = vAllowCase - parseInt(arrayDifficulty[vDiff].RuinChance,10);

				    var rand = guide.getRandom("(1..100)");
					var roll = rand + vModifier;
					
					
				  switch (true)
					{
					 case roll > vAllowCase:
						overRide.addButton("Allow", "Please...", "", "", "", "", "");
						break;
					 case roll > vRuinCase:
						overRide.addButton("Ruin", "Please...", "", "", "", "", "");
						break;
					default:
						overRide.addButton("No", "Please...", "", "", "", "", "");
					}

				    overRide.setHtml("Ask nicely" + "  " + rand + "-" + vModifier + "-" + roll);
				    overRide.image = vPath + "/Ask/*.jpg";

				}

			]]>
		</javascript>
    </Page>
	
	<Page id="Allow">
      <Text>Seeing this means something went wrong on the page - Allow</Text>
		<javascript>
			<![CDATA[
				function pageLoad() {
					var i = parseInt(scriptVars.get("vSelected"),10);
					var vSet = parseInt(scriptVars.get("vSet"),10);
					var vPath = arrayModel[i].Sets[vSet].Path;

					var vResponse = arrayModel[i].Name + ": " + arrayAllow[Math.floor(Math.random()*arrayAllow.length)];

			  overRide.setHtml(vResponse + " - " + vModifier);
			  overRide.image = vPath + "/Yes/*.jpg";

				}

			]]>
		</javascript>
	  <Button target="start">Someone else?</Button>
	  <Button target="Retry">Try Again?</Button>
    </Page>	

	<Page id="Ruin">
      <Text>Seeing this means something went wrong on the page - Ruin</Text>
		<javascript>
			<![CDATA[
				function pageLoad() {
					var i = parseInt(scriptVars.get("vSelected"),10);
					var vSet = parseInt(scriptVars.get("vSet"),10);
					var vPath = arrayModel[i].Sets[vSet].Path;

					var vResponse = arrayModel[i].Name + ": " + arrayRuin[Math.floor(Math.random()*arrayRuin.length)];

			  overRide.setHtml(vResponse + " - " + vModifier);
			  overRide.image = vPath + "/No/*.jpg";

				}

			]]>
		</javascript>
	  <Button target="start">Someone else?</Button>
	  <Button target="Retry">Try Again?</Button>
    </Page>	
	
	<Page id="No">
      <Text>Seeing this means something went wrong on the page - No</Text>
		<javascript>
			<![CDATA[
				function pageLoad() {
					var i = parseInt(scriptVars.get("vSelected"),10);
					var vSet = parseInt(scriptVars.get("vSet"),10);
					var vPath = arrayModel[i].Sets[vSet].Path;
										
					var vResponse = arrayModel[i].Name + ": " + arrayDeny[Math.floor(Math.random()*arrayDeny.length)];

			  overRide.setHtml(vResponse + " - " + vModifier);
			  overRide.image = vPath + "/No/*.jpg";

				}

			]]>
		</javascript>
      <Button target="start">Someone else?</Button>
	  <Button target="Retry">Try Again?</Button>
	</Page>	
	
  </Pages>
</Tease>
RemiHiyama
Explorer At Heart
Explorer At Heart
Posts: 203
Joined: Thu Feb 28, 2019 3:30 pm
I am a: Switch

Re: GuideMe (TeaseMe v2.0) - Current Build 0.4.4

Post by RemiHiyama »

wheresmything wrote: Tue Feb 22, 2022 1:55 am Going bonkers with parseInt, would appreciate assistance.
You seem to be using parseInt some places where it shouldn't actually be necessary. For instance, if you use the debug shell, you can see that the values in the vSelected and vSet scriptvars are already stored as numbers, so reparsing them is unnecessary - Javascript is just going to turn them into a string and back, so basically it's doing nothing.

As for vModifier, since you don't appear to be storing it's value in a scriptvar when it changes and then retrieving it when you need it, it's going to be reset to 0 whenever you go to a new page or otherwise run a javascript function.

If that doesn't sound like how a variable defined in GlobalJavascript should work... welcome to GuideMe. It used to work differently but now it works like this. Every time you run a javascript function, it starts with a mostly-fresh context, runs your global javascript, runs your page javascript, and then calls whatever function you asked it for. Does this make doing complicated logic with a lot of variables obnoxious? Why yes, yes it does.
Auto: Replaces selected instances of the word "not" with the word "definitely".
User avatar
PlayfulGuy
Explorer At Heart
Explorer At Heart
Posts: 792
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 (TeaseMe v2.0) - Current Build 0.4.4

Post by PlayfulGuy »

wheresmything wrote: Tue Feb 22, 2022 1:55 am Going bonkers with parseInt, would appreciate assistance. I've greatly abbreviated the script below while trying to retain it well enough to see what's going on. The challenge I'm having is that I've added a variable "vModifier" as the last bit of the global java. Everywhere it is called, I see the correct value, and on the "Ask" page the math works with the random value and vModifier being added together as intended.

Where I'm running into trouble is that I would like to update the vModifier on the Allow, Ruin, and No pages by a static amount (i.e vModifier + 3) and no matter how I try, the math doesn't work (I've tried many different parseInts, along with static numbers, variabilized increments, etc). I'd also want that value to be persisent throughout the session (resetting only on a new session or restart).

So if anyone could help me work out how to have the value of vModifier be 0 on startup, and then add a number to it (that then remains as an offset) when it hits any of the Allow, Ruin, or No pages, I'd really appreciate it.
Spoiler: show

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<Tease>
  <Title>At thier whim v11</Title>
  <Author id="">
    <Name>""</Name>
  </Author>

  <MediaDirectory>At thier whim</MediaDirectory>

  <Settings>
    <AutoSetPageWhenSeen>false</AutoSetPageWhenSeen>
	<ForceStartPage>true</ForceStartPage>
  </Settings>

  <GlobalJavascript>
  <![CDATA[

    //Difficulty settings: Very Easy = 0, Easy = 1, Medium = 2, Hard = 3, Very Hard = 4, Insane = 5, TESTING = 6
	var arrayModel = [
		{ Name: "TEST", 	sortOrder:  999, Sets: [
			{Difficulty: 6, Path: "Test\\Test-1" },
			{Difficulty: 6, Path: "Test\\Test-2" },
			{Difficulty: 6, Path: "Test\\Test-3" },
			{Difficulty: 6, Path: "Test\\Test-4" },
			{Difficulty: 6, Path: "Test\\Test-5" },
			{Difficulty: 6, Path: "Test\\Test-6" }]},
		];

	//Time is in seconds
	var arrayDifficulty = [
		{ Level: "Very Easy", 	DelayMin: 0, 	DelayMax: 0, AllowChance: 0, RuinChance: 0},
		{ Level: "Easy", 		DelayMin: 0, 	DelayMax: 0, AllowChance: 0, RuinChance: 0},
		{ Level: "Medium", 		DelayMin: 0, 	DelayMax: 0, AllowChance: 0, RuinChance: 0},
		{ Level: "Hard", 		DelayMin: 0, 	DelayMax: 0, AllowChance: 0, 	RuinChance: 0},
		{ Level: "Very Hard", 	DelayMin: 0, 	DelayMax: 0, AllowChance: 0, 	RuinChance: 0},
		{ Level: "Insane", 		DelayMin: 0, 	DelayMax: 0, AllowChance: 0, 	RuinChance: 0},
		{ Level: "TEST", 		DelayMin: 3, 	DelayMax: 3, AllowChance: 33, 	RuinChance: 33},
	];

	var arrayAllow = [
		"yes",
	];
	
	var arrayRuin = [
		"oops",
	];

	var arrayDeny = [
		"no",
	];
	
	var vModifier = 0;  //Modifier adds to the "Ask" roll, slowly increasing the chance of success with each model
	
]]>
  </GlobalJavascript>

  <Pages>
    <Page id="start">
      <Text>Who'd you like to see?</Text>
      <Image id="Welcome.jpg" />
      <javascript>
		  <![CDATA[
		  function pageLoad() {
  			var i = 0;
  			var vSelected = parseInt(scriptVars.get("vSelected"),10);
			

  			jscriptLog("vSelected = " + vSelected);
  			if ( isNaN(vSelected) || vSelected == undefined ) {
  			  vSelected = 0;
  			  scriptVars.put("vSelected", vSelected);
  			  jscriptLog("vSelected initialized to " + vSelected);
  			}

			for (i=0; i < arrayModel.length; i++) {
				var vName = arrayModel[i].Name;
				var vSort = arrayModel[i].sortOrder.toString();		//sortOrder parameter needs to be a string
				overRide.addButton("Confirm", vName, "", "", "setModel(" + i +")", "", "", vSort, false, "");
			}
			
			var i = parseInt(scriptVars.get("vSelected"),10);

  			overRide.setHtml("Who'd you like to see this time?  <br/>Last time you visited " + arrayModel[vSelected].Name + "<br/><br/>Current modifier value = " + vModifier);
			overRide.addButton("Confirm", "Revist Last", "", "", "setModel(" + i +")", "", "", "", false, "");
			overRide.addButton("Confirm", "You Choose", "", "", "setRandomModel()", "", "");
			}

			function setModel(i)
			{
				scriptVars.put("vSelected", i);

				// And randomly select a set to use and save this for other pages to access
				var vSet = Math.floor(Math.random()*arrayModel[i].Sets.length);
				scriptVars.put("vSet", vSet);  
			}
			
			function setRandomModel()
			{
				var i = Math.floor(Math.random()*arrayModel.length);
				
				scriptVars.put("vSelected", i);
				var vSet = Math.floor(Math.random()*arrayModel[i].Sets.length);
				scriptVars.put("vSet", vSet); 
			}
		  ]]>
	  </javascript>
    </Page>

	<Page id="Confirm">
      <Text>Seeing this means something went wrong on the page - Confirm</Text>
	  <Image id="test.jpg" />
		<javascript>
			<![CDATA[
				function pageLoad() {
					var i = parseInt(scriptVars.get("vSelected"),10);
					var vSet = parseInt(scriptVars.get("vSet"),10);
					var vPath = arrayModel[i].Sets[vSet].Path;
					var vDiff = arrayModel[i].Sets[vSet].Difficulty;
					var vLvl = arrayDifficulty[vDiff].Level;

					var text = arrayModel[i].Name + ":<br/>Are you ready to begin?<br/><br/>";

			  overRide.setHtml(text);
			  overRide.image = vPath + "/ready.jpg";

				}

			]]>
		</javascript>

	<Button target="start">Someone Else</Button>
	<Button target="ChangeSet">Different Set</Button>
	<Button target="Wait">Let's Begin</Button>
	</Page>

	<Page id="ChangeSet">
      <Text>Seeing this means something went wrong on the page - ChangeSet</Text>
		<javascript>
			<![CDATA[
				function pageLoad() {
				
				var i = parseInt(scriptVars.get("vSelected"),10);
				scriptVars.put("vSelected", i);
				var vSet = Math.floor(Math.random()*arrayModel[i].Sets.length);
				scriptVars.put("vSet", vSet);  
				}
			]]>
		</javascript>
	<Delay seconds="0" target="Confirm" style="hidden"/>
	</Page>
	
	<Page id="Retry">
      <Text>Seeing this means something went wrong on the page - ChangeSet</Text>
		<javascript>
			<![CDATA[
				function pageLoad() {
				
				var i = parseInt(scriptVars.get("vSelected"),10);
				scriptVars.put("vSelected", i);
				var vSet = Math.floor(Math.random()*arrayModel[i].Sets.length);
				scriptVars.put("vSet", vSet);  
				var vPath = arrayModel[i].Sets[vSet].Path;
				var vDiff = arrayModel[i].Sets[vSet].Difficulty;
				var vLvl = arrayDifficulty[vDiff].Level;				
				}
			]]>
		</javascript>
	<Delay seconds="0" target="Wait" style="hidden"/>
	</Page>
	
	<Page id="Wait">
      <Text>Seeing this means something went wrong on the page - Wait</Text>
		<javascript>
			<![CDATA[
				function pageLoad() {
					var i = parseInt(scriptVars.get("vSelected"),10);
					var vSet = parseInt(scriptVars.get("vSet"),10);
					var vPath = arrayModel[i].Sets[vSet].Path;
					var vDiff = arrayModel[i].Sets[vSet].Difficulty;
					
					var vMinDel = arrayDifficulty[vDiff].DelayMin;
					var vMaxDel = arrayDifficulty[vDiff].DelayMax;

					var vDelay = Math.floor(Math.random() * (vMaxDel - vMinDel + 1)) + vMinDel;

			  overRide.setHtml(arrayModel[i].Name + ":  Waiting...");
			  overRide.image = vPath + "/Wait/*.jpg";
			  overRide.setDelay("Ask", vDelay, "", "hidden", "", "", "");

				}

			]]>
		</javascript>
  	  <!-- <Button target="Ask">proceed-test</Button> -->
	</Page>
	
	
	<Page id="Ask">
      <Text>Seeing this means something went wrong on the page - Ask</Text>
		<javascript>
			<![CDATA[
				function pageLoad() {
					var i = parseInt(scriptVars.get("vSelected"),10);

					var vSet = parseInt(scriptVars.get("vSet"),10);
					var vPath = arrayModel[i].Sets[vSet].Path;
					var vDiff = arrayModel[i].Sets[vSet].Difficulty;

					var vAllowCase = 100 - parseInt(arrayDifficulty[vDiff].AllowChance,10);
					var vRuinCase = vAllowCase - parseInt(arrayDifficulty[vDiff].RuinChance,10);

				    var rand = guide.getRandom("(1..100)");
					var roll = rand + vModifier;
					
					
				  switch (true)
					{
					 case roll > vAllowCase:
						overRide.addButton("Allow", "Please...", "", "", "", "", "");
						break;
					 case roll > vRuinCase:
						overRide.addButton("Ruin", "Please...", "", "", "", "", "");
						break;
					default:
						overRide.addButton("No", "Please...", "", "", "", "", "");
					}

				    overRide.setHtml("Ask nicely" + "  " + rand + "-" + vModifier + "-" + roll);
				    overRide.image = vPath + "/Ask/*.jpg";

				}

			]]>
		</javascript>
    </Page>
	
	<Page id="Allow">
      <Text>Seeing this means something went wrong on the page - Allow</Text>
		<javascript>
			<![CDATA[
				function pageLoad() {
					var i = parseInt(scriptVars.get("vSelected"),10);
					var vSet = parseInt(scriptVars.get("vSet"),10);
					var vPath = arrayModel[i].Sets[vSet].Path;

					var vResponse = arrayModel[i].Name + ": " + arrayAllow[Math.floor(Math.random()*arrayAllow.length)];

			  overRide.setHtml(vResponse + " - " + vModifier);
			  overRide.image = vPath + "/Yes/*.jpg";

				}

			]]>
		</javascript>
	  <Button target="start">Someone else?</Button>
	  <Button target="Retry">Try Again?</Button>
    </Page>	

	<Page id="Ruin">
      <Text>Seeing this means something went wrong on the page - Ruin</Text>
		<javascript>
			<![CDATA[
				function pageLoad() {
					var i = parseInt(scriptVars.get("vSelected"),10);
					var vSet = parseInt(scriptVars.get("vSet"),10);
					var vPath = arrayModel[i].Sets[vSet].Path;

					var vResponse = arrayModel[i].Name + ": " + arrayRuin[Math.floor(Math.random()*arrayRuin.length)];

			  overRide.setHtml(vResponse + " - " + vModifier);
			  overRide.image = vPath + "/No/*.jpg";

				}

			]]>
		</javascript>
	  <Button target="start">Someone else?</Button>
	  <Button target="Retry">Try Again?</Button>
    </Page>	
	
	<Page id="No">
      <Text>Seeing this means something went wrong on the page - No</Text>
		<javascript>
			<![CDATA[
				function pageLoad() {
					var i = parseInt(scriptVars.get("vSelected"),10);
					var vSet = parseInt(scriptVars.get("vSet"),10);
					var vPath = arrayModel[i].Sets[vSet].Path;
										
					var vResponse = arrayModel[i].Name + ": " + arrayDeny[Math.floor(Math.random()*arrayDeny.length)];

			  overRide.setHtml(vResponse + " - " + vModifier);
			  overRide.image = vPath + "/No/*.jpg";

				}

			]]>
		</javascript>
      <Button target="start">Someone else?</Button>
	  <Button target="Retry">Try Again?</Button>
	</Page>	
	
  </Pages>
</Tease>
To elaborate a bit on RemiHiyama's answer, basically you can't use globals like that in GuideMe.
You would initialize the value of vModifier in your start page with

Code: Select all

scriptsVars.put("vModifier",3);
initializing it to 3 for example. This will happen every time the tease is loaded, assuming ForceStartPage is true.

Then in your other pages (like page "AsK" for example) you use it like

Code: Select all

var roll = rand + scriptVars.get("vModifier");
If GuideMe is returning vModifier as a string, only then would you need to wrap it in parseInt like

Code: Select all

var roll = rand + parseInt(scriptVars.get("vModifier"));
In your sample code you do not change the value of vModifier anywhere, but if/when you do you need to update the scriptvar using scriptVars.put() again.

If you don't want vModifier to reset on every load you can initialize it in your start page like this

Code: Select all

var vModifier = scriptVars.get("vModifier") || 3; // Retrieve value from last run, or initialize to 3
scriptsVars.put("vModifier",vModifier); // Save current value
Then it will only reset if you do a File/Restart in Guideme.

Hope that helps.

PG
wheresmything
Explorer
Explorer
Posts: 62
Joined: Tue Nov 16, 2010 2:02 pm

Re: GuideMe (TeaseMe v2.0) - Current Build 0.4.4

Post by wheresmything »

Ok, took some tweaking and such, but I got it working. Thanks much for the help.
EroticDevelopment
Explorer
Explorer
Posts: 36
Joined: Thu Oct 15, 2020 3:32 am
Gender: Male
Sexual Orientation: Straight
Location: USA

Re: GuideMe (TeaseMe v2.0) - Current Build 0.4.4

Post by EroticDevelopment »

RemiHiyama wrote: Fri Feb 18, 2022 4:53 am
EroticDevelopment wrote: Fri Feb 18, 2022 4:20 am put this in a new debug.bat).
Maybe we should consider adding this to the build?
Yeah, I think it wouldn't hurt. Hopefully these are rare, but it would make debugging easier when they happen.
RemiHiyama wrote: Fri Feb 18, 2022 4:53 am Anyway, yeah, the problem was that issue that shows up periodically where startup.state ends up containing something like this:

Code: Select all

<scope><![CDATA[ignore]]></scope>
And then when the GuideSettings constructor is run, ComonFunctions.getSavedObject hits an error trying to turn "ignore" into a Scriptable, and then because of the way the exception is handling it just returns the string "ignore". Then it tries to cast that into a Scriptable object that fails and nothing catches the exception.

I'm not really sure of the best way to handle this.
That's a good observation, and definitely something that needs work. I'll take a look at how error handling works during the state load and see if we can't make some changes. It seems like if a single property is bad or can't be read it could substitute the default value and go on, or worse case restore the factory-default state and re-launch.
RemiHiyama
Explorer At Heart
Explorer At Heart
Posts: 203
Joined: Thu Feb 28, 2019 3:30 pm
I am a: Switch

Re: GuideMe (TeaseMe v2.0) - Current Build 0.4.4

Post by RemiHiyama »

EroticDevelopment wrote: Fri Feb 25, 2022 12:25 amYeah, I think it wouldn't hurt. Hopefully these are rare, but it would make debugging easier when they happen.
It's also useful for developing teases with tricky javascript in them. (I like the way the console shows things better than how the log section of the debug window does.)
That's a good observation, and definitely something that needs work. I'll take a look at how error handling works during the state load and see if we can't make some changes. It seems like if a single property is bad or can't be read it could substitute the default value and go on, or worse case restore the factory-default state and re-launch.
That's about what I was thinking, except that I'm not sure which is the appropriate way to jump. It doesn't seem to assign *anything* to scope if the state file doesn't exist, and that seems to be okay, but I'm not at all clear on what it's even *for*, so I don't know if that's safe when the other stuff in the file has been assigned already. And how come a tease that corrupts it only corrupts startup.state, and not the state file for the tease with the broken code?
Auto: Replaces selected instances of the word "not" with the word "definitely".
User avatar
PlayfulGuy
Explorer At Heart
Explorer At Heart
Posts: 792
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

Javascript and global variables

Post by PlayfulGuy »

Hi guys,

I know it's been discussed before, but I want to see what the chances are of this ever getting changed.

This is currently the biggest stumbling block I have with development of the downloader and downloading advanced EOS teases. Many of the really complex ones use elaborate javascript that unfortunately relies on global variables (as in global across pages) for proper operation. Since EOS supports this, but GuideMe does not, conversion becomes a huge challenge. If Guideme supported globals across pages, some of the largest issues I have left in the downloader would disappear.

If memory serves, these used to work in older versions of Guideme but then something was changed later on so globals no longer persist across pages. I recall philo mentioning a change like that at some point (though I could be wrong).

Does any else recall anything about this, and why it was done, and what may be the ramifications of changing it back?

If I understand how Guideme works, I think the globaljavascript code gets executed for each page, resetting any global variables defined. EOS on the other hand uses an "init" module that gets executed once when the tease loads, and the javascript environment persists across pages so individual pages can use "evals" to execute functions defined in the init module, refer to global variables etc.

Or maybe I need to use a different approach? Right now I add the EOS init code to the global javascript, and try and modify it to work in GuideMe, which means implementing a javascript parser that's smart enough to modify the code. As I'm sure you can appreciate, this is not a trivial task, and in it's current state it badly mangles some stuff. If global variables worked "properly", I would presumable be able to just pass all the javascript through to Guideme, and conceivably everything would just work.

What are your thoughts?

PG
RemiHiyama
Explorer At Heart
Explorer At Heart
Posts: 203
Joined: Thu Feb 28, 2019 3:30 pm
I am a: Switch

Re: Javascript and global variables

Post by RemiHiyama »

PlayfulGuy wrote: Mon Feb 28, 2022 8:12 pmIf I understand how Guideme works, I think the globaljavascript code gets executed for each page, resetting any global variables defined.
Not quite true.

Global javascript (and then the javascript for your current page) gets executed once for every time a function is called. If you have any page javascript whatsoever, then that will all get run as part of calling pageLoad. If you have a timer that calls a function, same thing. If you have a button that does some javascript, same thing.

Every time seems to start with a fresh context, although I'm not really sure from looking at it where it does that. I'd have to hunt down the commit where that was changed again, I think.

In any case, the intent was to be able to script each page completely independently, without having to worry about name collisions and so forth. I'd be very surprised if just changing back to the old behavior doesn't break some teases.

What I do think would be worthwhile is having an optional configuration setting that makes all the resetting not happen and only runs global javascript once. Page javascript probably has to be rerun every time, and pageLoad would need to be used with caution. (If a page didn't have it defined, but did have other page javascript, it would run the last version of the function to be defined - not necessarily ideal!) This seems like it'd do what would be "expected" in most cases, though some things would require cautious handling.

I believe such an option would cover your needs, but I'm not sure exactly how to do all of it.
Auto: Replaces selected instances of the word "not" with the word "definitely".
philo
Explorer At Heart
Explorer At Heart
Posts: 831
Joined: Sun Jan 08, 2012 3:10 pm
Gender: Male
Sexual Orientation: Straight
Location: UK

Re: Javascript and global variables

Post by philo »

RemiHiyama wrote: Mon Feb 28, 2022 10:18 pm
PlayfulGuy wrote: Mon Feb 28, 2022 8:12 pmIf I understand how Guideme works, I think the globaljavascript code gets executed for each page, resetting any global variables defined.
Not quite true.

Global javascript (and then the javascript for your current page) gets executed once for every time a function is called. If you have any page javascript whatsoever, then that will all get run as part of calling pageLoad. If you have a timer that calls a function, same thing. If you have a button that does some javascript, same thing.
This was designed deliberately. Global variables are a pain and lead to bad programming practices and code that is hard to maintain / understand.
The purpose of the scriptvar object is to hold state between pages.
Global javascript was meant to be used for reusable functions, it was never designed to be used to hold state.
There was a bug where that was not cleared down in some circumstances, but was inconsistent, so setting a global variable worked by accident some of the time, that was fixed :-D
The design is supposed to give a clean state for each time you run a script.
It should run global javascript to set up any re-usable code.
It should then run the actual javascript for that event.
You can take a copy of a variable from the scriptvars and use it locally.
You can update a variable in scriptvars if you want to change the value.

I would recommend keeping that model, however you may want to rethink the implementation of scriptvars to make them easer to use / understand.
RemiHiyama
Explorer At Heart
Explorer At Heart
Posts: 203
Joined: Thu Feb 28, 2019 3:30 pm
I am a: Switch

Re: Javascript and global variables

Post by RemiHiyama »

philo wrote: Tue Mar 01, 2022 8:26 amThis was designed deliberately. Global variables are a pain and lead to bad programming practices and code that is hard to maintain / understand.
This may be true, but it doesn't really make any reference to PlayfulGuy's use case. For better or for worse, EOS handles variables the way it does, and if automatically converting between the two idioms was easy he would have already done so.

As for my personal feelings... well, maybe it comes down to where you learned to program. Scriptvars feels like I'm still using global variables, but with the addition of a voice at the back of my head screaming "Don't repeat yourself!" every time I write another scriptVars.get. Ultimately it makes for confusing and difficult to follow code, at least for me, and working within GuideMe places strict limitations on what other methods can be used.

That being said, I have no desire or intention to replace the existing model. (One of my major goals is to avoid breaking existing teases.) Just to make additional options available if there's a niche that doesn't seem to be filled.
you may want to rethink the implementation of scriptvars to make them easer to use / understand.
I'm not sure how you could. They'd be a lot more intuitive with subscript notation, but neither Java nor JavaScript have operator overloading so that's not on the table.
Auto: Replaces selected instances of the word "not" with the word "definitely".
Post Reply

Who is online

Users browsing this forum: eatsl and 28 guests