I will go through the code step by step.
I know this looks like a lot but I think this can be implemented
in 20 minutes once you understood how it works.
Here comes the steps to reproduce
1. Your tease should be finished by the time you implement this. The visual editor doesn't really understand what is going on and will not allow you to edit the pages anymore. It will display something like 'fix your script'. Of course you can still manually edit the script.
2. Count the possible outcomes. Minus one. That is because one outcome is 'you have less than X points, you failed', which we don't need to count. For each of those outcomes, add a 'counting' page, that nobody will ever go to.
I did it like this:
Code: Select all
1001#page('1001 counter',go(start#));
1002#page('1002 counter',go(start#));
1003#page('1003 counter',go(start#));
for four possible outcomes, including the 'you failed' page. The outcomes will be called
stages from here on.
2a. Of course you need the possible final stages, too. You should have them already, since your tease is already finished (see step 1
). In this example, the pages 701 to 704 are the entry pages of the stages. 701 is the 'you failed' page, 704 is the best outcome. All of these can consist of multiple pages, where the user goes via button or timer to the next page.
3. Introduce the entry pages of the stages at the start of the script. Not sure where this has to go, but putting it at the start of the script works fine. The first parameter refers to the page that you are 'allowed to enter' for each stage. Let's say the looser bracket is page 701, next stage is 702, and so on. There is no command here for the looser page, as there is no counter page for it. All the commands link a (invisible) counter page to a (real) reward page.
Code: Select all
mustnot(702#,1001#);
mustnot(703#,1002#);
mustnot(704#,1003#);
This links a page the user will see (701..704) to one of the invisible 'counter pages'. They don't need to be continuous numbers.
4. Setup how many points you need to enter the stages. The first parameter of each line is the minimum point count to reach that page, the second parameter is the counting page. Of course the looser bracket is also not here, as there is no minimum for it.
Code: Select all
repeatdel(20,1001#);
repeatdel(40,1002#);
repeatdel(60,1003#);
As you can see stage 2 (which will be page 702 in this example) can be reached with 20 points, stage 3 (page 703) with 40 points.
5. Every time points are given or subtracted, you need to add one command for each of the counter pages. The code looks like this:
Code: Select all
6#page(
'Added 20',
action:mult(
repeatadd(20,1001#),
repeatadd(20,1002#),
repeatadd(20,1003#),
go(2#)
)
);
7#page(
'Minus 10. Sorry!',
action:mult(
repeatdel(10,1001#),
repeatdel(10,1002#),
repeatdel(10,1003#),
go(2#)
)
);
I hope the code is self explanatory. The 'mult' action is used to combine multiple commands into one, in order to combine all the adding points and removing points with the 'continue' button. If points should be added, use
repeatadd, to substract use
repeatdel, the first parameter is always the amount of points.
6. This part is kind of hard to explain. This is also where all the magic happens.
You don't have one branching page that splits into all the possible results. Instead, you actually have the user go to the first page of the first reward stage, but also add a special command to forward to the next stage, if he has enough points.
On the first page of the second reward stage, you as well add a similar command to go to the next stage, if possible.
And so on.
The command is this:
Code: Select all
701#page('Welcome to the looser bracket. Press continue',
action:mult(
go(looserbracket2#),
goto(range(702,702))
));
So the 'looserbracket2#' part makes a continue button for the user to go to the next page of this stage. The line 'goto(range(y,y))' makes the page evaluate if it can go to page Y, and if it can, go there. If it can't because the user doesn't have enough points, it won't and the user will actually be stuck in this stage.
The page the goto command refers to (in this case 702) should be the first page of the next stage, which should also have the same command structure. Of course the last stage does not have this.
Also having the range command inside the goto is really important. The range command does evaluate if you can somewhere, the command 'goto(702)' would ignore points and go there either way.
That's it! One last important thing to notice is, if you test this, you have to reload the editor every time you start over. A click on the 'Reset' button doesn't do anything, the counters will all be messed up.