1) There are 7 elements in arrayModel, but really only 4 models. This is because there are multiple sets from two of the models (Marie and Monica). Each of these elements also allows me to change the difficulty and photos for that particular set so that a model may have different difficulties from one set to another. The way things are currently, every set creates a button, but what I'd ultimately is some way to randomly select unique models with the ones having multiple sets being chosen randomly (in other words, sometimes Marie 1, sometimes Marie 2, but either way there's just one button that says Marie). I have no idea how to make that happen though.
2) The overRide.addButton function on the start page apparently can support sorting the buttons in order, which I'd like, but I can't get it to work. I'm sure its just syntax, but I can't seem to find the right one. This is no biggie, but any help sorting it would be fantastic.
With those two things, this will be done. Appreciate any help you can provide.
As I think more on it, what would be even better is a way to select x unique models from the array and only put buttons for them. Really, really have no idea how to pull that one off though.
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<Tease>
<Title>At thier whim v5</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
var arrayModel = [
{ Name: "Abha", Difficulty: 0, Path: "Abha" },
{ Name: "Marie", Difficulty: 1, Path: "Marie\\Marie-1" },
{ Name: "Marie", Difficulty: 2, Path: "Marie\\Marie-2" },
{ Name: "Monica", Difficulty: 3, Path: "Monica\\Monica-1" },
{ Name: "Monica", Difficulty: 4, Path: "Monica\\Monica-2" },
{ Name: "Monica", Difficulty: 5, Path: "Monica\\Monica-3" },
{ Name: "Viki", Difficulty: 3, Path: "Viki" },
];
//Time is in seconds, chances must add to 100
var arrayDifficulty = [
{ Level: "Very Easy", DelayMin: 60, DelayMax: 180, AllowChance: 33, RuinChance: 33},
{ Level: "Easy", DelayMin: 120, DelayMax: 300, AllowChance: 12, RuinChance: 15},
{ Level: "Medium", DelayMin: 180, DelayMax: 360, AllowChance: 9, RuinChance: 10},
{ Level: "Hard", DelayMin: 300, DelayMax: 480, AllowChance: 5, RuinChance: 7},
{ Level: "Very Hard", DelayMin: 420, DelayMax: 600, AllowChance: 3, RuinChance: 4},
{ Level: "Insane", DelayMin: 600, DelayMax: 900, AllowChance: 1, RuinChance: 2},
];
var arrayAllow = [
"Allow 1",
"Allow 2",
"Allow 3",
];
var arrayRuin = [
"Ruin 1",
"Ruin 2",
"Ruin 3",
];
var arrayDeny = [
"Deny 1",
"Deny 2",
"Deny 3",
];
]]>
</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);
var arrayAllow = scriptVars.get("arrayAllow");
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;
overRide.addButton("Confirm", vName, "", "", "setModel(" + i +")", "", "");
}
overRide.setHtml("Last time you visited " + arrayModel[vSelected].Name);
}
function setModel(i)
{
scriptVars.put("vSelected", i);
}
]]>
</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 vPath = arrayModel[i].Path;
overRide.setHtml("Hello. Are you ready to begin?");
overRide.image = vPath + "/ready.jpg";
}
]]>
</javascript>
<Button target="start">Changed my mind</Button>
<Button target="Wait">Let's Begin</Button>
</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 vPath = arrayModel[i].Path;
var vDiff = parseInt(arrayModel[i].Difficulty,10);
var vLvl = arrayDifficulty[vDiff].Level;
var vMinDel = arrayDifficulty[vDiff].DelayMin;
var vMaxDel = arrayDifficulty[vDiff].DelayMax;
var vDelay = Math.floor(Math.random() * (vMaxDel - vMinDel + 1)) + vMinDel;
overRide.setHtml("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 vPath = arrayModel[i].Path;
var vDiff = parseInt(arrayModel[i].Difficulty,10);
var vAllowCase = 100 - parseInt(arrayDifficulty[vDiff].AllowChance,10);
var vRuinCase = vAllowCase - parseInt(arrayDifficulty[vDiff].RuinChance,10);
var rand = guide.getRandom("(1..100)");
switch (true)
{
case rand > vAllowCase:
overRide.addButton("Allow", "Please...", "", "", "", "", "");
break;
case rand > vRuinCase:
overRide.addButton("Ruin", "Please...", "", "", "", "", "");
break;
default:
overRide.addButton("No", "Please...", "", "", "", "", "");
}
overRide.setHtml("Ask nicely");
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 vPath = arrayModel[i].Path;
var vResponse = arrayAllow[Math.floor(Math.random()*arrayAllow.length)];
overRide.setHtml(vResponse);
overRide.image = vPath + "/Yes/*.jpg";
}
]]>
</javascript>
<Button target="start">Someone else?</Button>
<Button target="Wait">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 vPath = arrayModel[i].Path;
var vResponse = arrayRuin[Math.floor(Math.random()*arrayRuin.length)];
overRide.setHtml(vResponse);
overRide.image = vPath + "/No/*.jpg";
}
]]>
</javascript>
<Button target="start">Someone else?</Button>
<Button target="Wait">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 vPath = arrayModel[i].Path;
var vResponse = arrayDeny[Math.floor(Math.random()*arrayDeny.length)];
overRide.setHtml(vResponse);
overRide.image = vPath + "/No/*.jpg";
}
]]>
</javascript>
<Button target="start">Someone else?</Button>
<Button target="Wait">Try Again?</Button>
</Page>
</Pages>
</Tease>