How to count points in a nyx flash tease

All about the past, current and future webteases and the art of webteasing in general.
---
User avatar
onlytropics
Explorer At Heart
Explorer At Heart
Posts: 120
Joined: Tue Apr 10, 2018 6:10 pm
Gender: Male
Sexual Orientation: Straight
Location: Austria

How to count points in a nyx flash tease

Post by onlytropics »

I was asked recently if you can script something that counts points in a flash tease. So by visiting a specific page or pressing a button you can gather points, or maybe loose some. The final page(s) should be chosen according to the amount of points you gathered.

Well in flash it is certainly possible, but I wasn't sure about the Nyx 'script language', if you want to call it that. I tried for hours and hours and - actually I found a way. Since this might be useful for other people, I thought I should write a small howto.

This is the testing ground: https://milovana.com/webteases/showtease.php?id=38132

So first things first, here comes the sample code I came up with:

Code: Select all

mustnot(702#,1001#);
mustnot(703#,1002#);
mustnot(704#,1003#);

repeatdel(20,1001#);
repeatdel(40,1002#);
repeatdel(60,1003#);

start#page('Test counting points.',
action:mult(
go(2#)
)
);

2#page('Page 2.  Choose',pic("*.jpg"),
buttons(5#,"plus 10",6#,"plus 20",7#,"minus 10",30#,"results")
); 

5#page(
'Added 10',
action:mult(
repeatadd(10,1001#),
repeatadd(10,1002#),
repeatadd(10,1003#),
go(2#)
)
);

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#)
)
);

30#page('results will come up right away...',
action:mult(
goto(701#)
)
);


701#page('Page 701. Result is ...19',
action:mult(
go(start#),
goto(range(702,702))
));
702#page('Page 702. Result is 20...39',
action:mult(
go(start#),
goto(range(703,703))
));
703#page('Page 703. Result is 40...59',
action:mult(
go(start#),
goto(range(704,704))
));
704#page('Page 704. Result is 60...',action:go(start#));

1001#page('1001 counter',go(start#));
1002#page('1002 counter',go(start#));
1003#page('1003 counter',go(start#));
Remember that if you want to try this example, you need to reload the Nyx Editor after every run. If you don't, you won't get the correct results. This could actually be solved in the code using additional instructions, but I wanted to have this example as simple as possible.

The explanation for this code is in the next post.
Last edited by onlytropics on Sun Oct 21, 2018 6:45 pm, edited 1 time in total.
Reasons to have oranges at home:
1. they're healthy
2. smells nice
3. Milovana
User avatar
onlytropics
Explorer At Heart
Explorer At Heart
Posts: 120
Joined: Tue Apr 10, 2018 6:10 pm
Gender: Male
Sexual Orientation: Straight
Location: Austria

Re: How to count points in a nyx flash tease

Post by onlytropics »

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 :-P ). 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.
Last edited by onlytropics on Tue Jul 24, 2018 6:14 pm, edited 5 times in total.
Reasons to have oranges at home:
1. they're healthy
2. smells nice
3. Milovana
User avatar
onlytropics
Explorer At Heart
Explorer At Heart
Posts: 120
Joined: Tue Apr 10, 2018 6:10 pm
Gender: Male
Sexual Orientation: Straight
Location: Austria

Re: How to count points in a nyx flash tease

Post by onlytropics »

(placeholder)
Reasons to have oranges at home:
1. they're healthy
2. smells nice
3. Milovana
User avatar
Shattered
Experimentor
Experimentor
Posts: 1238
Joined: Fri Jan 11, 2013 6:41 pm
I am a: Switch
Location: United Kingdom

Re: How to count points in a nyx flash tease

Post by Shattered »

I've skimmed this and some of it goes a bit over my head since I'm not a natural programmer... but could this be used for varaibles? I'd learn this for that.

Like, I assume you could have the count be either 0 or 1 and basically have it act as one like that? Would be big if true.
User avatar
onlytropics
Explorer At Heart
Explorer At Heart
Posts: 120
Joined: Tue Apr 10, 2018 6:10 pm
Gender: Male
Sexual Orientation: Straight
Location: Austria

Re: How to count points in a nyx flash tease

Post by onlytropics »

I hope I did break it down for a non-programmer to understand the steps. The work for the tease writer is mostly to replace some numbers and pages with the numbers and pages relevant to your tease. So I'm happy to answer any questions or clarify.

This is mostly about variables, yes. Maybe not exactly, because you can't write the number in text to the user (like "Now you have 69 points.").
It is about counting points though. So let's say the player can get different amounts of points for different choices he makes. That means essentially "when the user clicks button A, he will get 20 points; but when he clicks button B, he will loose 5 points".
Somewhere later in the tease you will then want to evaluate this count, and according to the number of points, go to different "result pages" (or rather "result paths" i guess).
The example above is for keeping track of exactly one such variable. Theoretically multiple can be created, but that makes things a lot more complicated.

So I hope this is useful, I would love to see it get put to action. Took me quite some time to figure it out :-D
Reasons to have oranges at home:
1. they're healthy
2. smells nice
3. Milovana
User avatar
rabbithole
Explorer
Explorer
Posts: 52
Joined: Mon Dec 15, 2014 5:35 am
Gender: Male
Sexual Orientation: Open to new ideas!
I am a: Submissive

Re: How to count points in a nyx flash tease

Post by rabbithole »

Shattered wrote: Wed Aug 01, 2018 2:18 pm I've skimmed this and some of it goes a bit over my head since I'm not a natural programmer... but could this be used for varaibles? I'd learn this for that.

Like, I assume you could have the count be either 0 or 1 and basically have it act as one like that? Would be big if true.
Yes, Shattered, you are correct in supposing this method could be used for such a purpose... for determining whether the player has acquired some item/ability/whatever that they will need to use in order to pass a particular point in the story. I believe it would look something like this:

Code: Select all

mustnot(701#, 1001#);
repeatdel(1#, 1001#);

start#page('Welcome',
action:go(2#)
);

2#page('You see a key. What do you do?',
buttons(3#, 'take it', 4#, 'leave it')
);

3#page('You now have a key.',
action:mult(
repeatadd(1, 1001#),
go(5#)
)
);

4#page('You leave it and move on.',
action:go(5#)
);

5#page('Later on, you see a door. What do you do?',
buttons(700#, 'open it', 2#, 'go back')
);

700#page('The door is locked. You need a key.',
action:mult(
buttons(2#, 'go back'),
goto(range(701, 701))
)
);

701#page('You use the key to unlock the door.'
);

1001#page('key variable', go(start#));
Of course, the problem with this example is that the player can go back and collect the "key" again and again, raising the variable above its intended value of 1. So it's important to avoid problems like the one I have created here, which can result from allowing a player to 'backtrack' through the story. This is especially crucial if you intend to try to take the "key" away at any point, using repeatdel().

I am not experienced with this language, so please let me know if I have made any mistakes above.
Last edited by rabbithole on Mon Oct 22, 2018 9:07 pm, edited 1 time in total.
Four Floors, Four Doors (Normal)
Floor: 1 | Points: 0 | Pool Points: 62 (2600) | Doors Opened: 3 | Gambles: 4
Last Ruin: 11/16 | Last Cum: 11/13 | Edges So Far: 211
User avatar
arthurb
Explorer At Heart
Explorer At Heart
Posts: 631
Joined: Tue Apr 30, 2013 6:53 pm
Gender: Male
Sexual Orientation: Open to new ideas!
I am a: Submissive
Location: England

Re: How to count points in a nyx flash tease

Post by arthurb »

:w00t: :w00t: :?: :?: That Counting Tease is hot! :?: :?: :w00t: :w00t:

Image

Mark Question is on the pull...
Princess Penny's Subject Number 007

On Her Highness's Submissive Service
User avatar
onlytropics
Explorer At Heart
Explorer At Heart
Posts: 120
Joined: Tue Apr 10, 2018 6:10 pm
Gender: Male
Sexual Orientation: Straight
Location: Austria

Re: How to count points in a nyx flash tease

Post by onlytropics »

rabbithole wrote: Sun Oct 21, 2018 8:34 pm Yes, Shattered, you are correct in supposing this method could be used for such a purpose... for determining whether the player has acquired some item/ability/whatever that they will need to use in order to pass a particular point in the story.

Of course, the problem with this example is that the player can go back and collect the "key" again and again, raising the variable above its intended value of 1. So it's important to avoid problems like the one I have created here, which can result from allowing a player to 'backtrack' through the story. This is especially crucial if you intend to try to take the "key" away at any point, using repeatdel().

I am not experienced with this language, so please let me know if I have made any mistakes above.
Yes, you are correct. You can count anything you want, in that way it is like a variable and later in the tease have an outcome depending on that. Counting keys in a fantasy story is a great example.

Afaics, the code looks correct.

Having a value greater than 1 is not a problem in principle, you should be able to remove a 'key' when the user opens a door and continue the tease. Of course you should not allow the player to go back to the start to gather more keys, as in your example. You could give the player 5 keys at the start and at the end (or in between) have 10 doors, so he can only open half of them. Also you could have a really devilish mistress behind one of the doors, which takes away all the keys, so the player can't open any more doors.

I guess this mainly makes it so the player can't cheat on your tease.
Reasons to have oranges at home:
1. they're healthy
2. smells nice
3. Milovana
User avatar
onlytropics
Explorer At Heart
Explorer At Heart
Posts: 120
Joined: Tue Apr 10, 2018 6:10 pm
Gender: Male
Sexual Orientation: Straight
Location: Austria

Re: How to count points in a nyx flash tease

Post by onlytropics »

arthurb wrote: Mon Oct 22, 2018 3:13 pm :w00t: :w00t: :?: :?: That Counting Tease is hot! :?: :?: :w00t: :w00t:
Thanks :lol: The rating is not great but that was expected ;-)
Reasons to have oranges at home:
1. they're healthy
2. smells nice
3. Milovana
User avatar
rabbithole
Explorer
Explorer
Posts: 52
Joined: Mon Dec 15, 2014 5:35 am
Gender: Male
Sexual Orientation: Open to new ideas!
I am a: Submissive

Re: How to count points in a nyx flash tease

Post by rabbithole »

Having a value greater than 1 is not a problem in principle, you should be able to remove a 'key' when the user opens a door and continue the tease. Of course you should not allow the player to go back to the start to gather more keys, as in your example. You could give the player 5 keys at the start and at the end (or in between) have 10 doors, so he can only open half of them. Also you could have a really devilish mistress behind one of the doors, which takes away all the keys, so the player can't open any more doors.

I guess this mainly makes it so the player can't cheat on your tease.
I actually hadn't considered removing the item after it is used. This is suitable for something like a key, which will presumably need to be used only once. Of course, we won't always want to do that. Many items (or abilities), like weapons, could stay with the player for extended use, and might still be taken away later. This is when it becomes a problem. So to be safe in these cases, we want to make sure the user cannot repeat the sections of the story wherein repeatadd() is used. This probably seems trivial at first, but there are many published teases that use a "hub" or "main menu" to allow the player freedom of exploration, which would be incompatible with such an inventory system. We will also run into problems if we ever try to "restart" the tease, since we are unable to reinitialize the variables (without reloading the page).

I've been pondering whether we can insert a command to check whether the player already has the key, before showing it to him or before allowing him to collect it. But it seems that in order to do so, we would need to add another mustnot() statement at the start of the script. And going back to my weapon example, we would need to set up a mustnot() link for every single page where the weapon can be used. Can we even link multiple pages in this way, or is it required to be one-to-one?
Four Floors, Four Doors (Normal)
Floor: 1 | Points: 0 | Pool Points: 62 (2600) | Doors Opened: 3 | Gambles: 4
Last Ruin: 11/16 | Last Cum: 11/13 | Edges So Far: 211
User avatar
onlytropics
Explorer At Heart
Explorer At Heart
Posts: 120
Joined: Tue Apr 10, 2018 6:10 pm
Gender: Male
Sexual Orientation: Straight
Location: Austria

Re: How to count points in a nyx flash tease

Post by onlytropics »

rabbithole wrote: Mon Oct 22, 2018 5:33 pm I've been pondering whether we can insert a command to check whether the player already has the key, before showing it to him or before allowing him to collect it. But it seems that in order to do so, we would need to add another mustnot() statement at the start of the script. And going back to my weapon example, we would need to set up a mustnot() link for every single page where the weapon can be used. Can we even link multiple pages in this way, or is it required to be one-to-one?
You are correct, you'd need another mustnot() statement, but not another 'counter page'. It is not one-to-one, you can use the same counter more than once (as far as I understand the commands). One 'counter page' is needed for every item and possible outcome to count. So if the item is a weapon, and you only need to count 'one ore more than one' - that means one counter page. If the player comes to a page where it would be possible to take the weapon again, you need to skip it as described in step 6 (goto(range())).
I didn't test this case (yet), but it wouldn't be too difficult.

You might also have different weapons, which might do different things to whoever you encounter... That would be an interesting exercise!
Reasons to have oranges at home:
1. they're healthy
2. smells nice
3. Milovana
User avatar
rabbithole
Explorer
Explorer
Posts: 52
Joined: Mon Dec 15, 2014 5:35 am
Gender: Male
Sexual Orientation: Open to new ideas!
I am a: Submissive

Re: How to count points in a nyx flash tease

Post by rabbithole »

All right, so assuming I've understood everything correctly, I've rewritten my previous code such that: (1) the key will not appear if you already possess it, (2) the player can revisit the same page without risk, and (3) the restart button at the end of the tease should reset the variable to zero.

Code: Select all

mustnot(key1#, countkey#);
mustnot(door1#, countkey#);
mustnot(restart1#, countkey#);
repeatdel(1#, countkey#);

start#page('Welcome',
action:go(key0#)
);

key0#page('You see a key. What do you do?',
action:mult(
buttons(3#, 'take it', 4#, 'leave it'),
goto(range(key1, key1))
)
);

key1#page('You see nothing of interest here.',
action:go(5#)
);

3#page('You now have a key.',
action:mult(
repeatadd(1, countkey#),
go(5#)
)
);

4#page('You leave it and move on.',
action:go(5#)
);

5#page('Later on, you see a door. What do you do?',
buttons(door0#, 'open it', key0#, 'go back')
);

door0#page('The door is locked. You need a key.',
action:mult(
buttons(key0#, 'go back'),
goto(range(door1, door1))
)
);

door1#page('You use the key to unlock the door.',
action:go(win#)
);

win#page('Congratulations, you've won',
action:go(restart0#)
);

restart0#page('Reinitializing...',
action:mult(
go(start#),
goto(range(restart1, restart1))
)
);

restart1#page('Reinitializing...',
action:mult(
go(start#),
repeatdel(1, countkey#)
)
);

countkey#page('key variable', go(start#));
Four Floors, Four Doors (Normal)
Floor: 1 | Points: 0 | Pool Points: 62 (2600) | Doors Opened: 3 | Gambles: 4
Last Ruin: 11/16 | Last Cum: 11/13 | Edges So Far: 211
Unnamed_007
Explorer
Explorer
Posts: 50
Joined: Fri Mar 23, 2012 2:14 am
Gender: Male
Sexual Orientation: Straight
I am a: Switch

Re: How to count points in a nyx flash tease

Post by Unnamed_007 »

It seems to not work properly.

I did the following +10 > -10 > +10 > results and the result is 19.
User avatar
rabbithole
Explorer
Explorer
Posts: 52
Joined: Mon Dec 15, 2014 5:35 am
Gender: Male
Sexual Orientation: Open to new ideas!
I am a: Submissive

Re: How to count points in a nyx flash tease

Post by rabbithole »

Unnamed_007 wrote: Tue Oct 23, 2018 5:41 am It seems to not work properly.

I did the following +10 > -10 > +10 > results and the result is 19.
I thought the same thing at first. But this is actually the correct result. When it says "...19," it really means "less than 19." This particular tease (like most existing score-based teases) is not interested in the exact result, but rather which range/stage/tier of points the player has achieved, counting by 20's. So the four possible results here are "less than 19," "20 to 39," "40 to 59," and "60 or more."

In practice, you can have as many of these tiers as you like, but each one needs its own results page and 'counter' page. And if you have 60 tiers, then you'll need 60 lines of code every time points are gained or lost (whereas most scripting languages would only need 1 line). So, while it'd certainly be possible to keep track exactly, imprecision here is a more practical compromise.
Four Floors, Four Doors (Normal)
Floor: 1 | Points: 0 | Pool Points: 62 (2600) | Doors Opened: 3 | Gambles: 4
Last Ruin: 11/16 | Last Cum: 11/13 | Edges So Far: 211
imtoosexy
Explorer At Heart
Explorer At Heart
Posts: 116
Joined: Mon Jun 01, 2015 7:44 pm
Gender: Female
Sexual Orientation: Straight
I am a: Domme (Female)

Re: How to count points in a nyx flash tease

Post by imtoosexy »

Interesting, I would love to be able to use this.

So far I don't understand it at all

I got that you use a few diffrent pages that

You got 3 counter pages that you put before the start page and all go to start.

The start page

Page 2 the button page

the 3 number pages
5 - add 10 - this page has a command i dont know but seems to do multiple actions . 'repeatadd' 10 to all counter pages then go page 2
6 - add 20 - this page has a command i dont know but seems to do multiple actions . 'repeatadd' 20 to all counter pages then go page 2
7 - remove 10 - this page has a command i dont know but seems to do multiple actions . 'repeatdel' 10 from all counter pages then go page 2

and the 3 results pages
the ifset and if-not-set functions are used here, (which is the same as must and mustnot in the editor)
701 range 0.19
702 range 20-39
703 range 40-59
704 range 60+
so pages can be set and unset more than once but i dont see how it applies here


So I guess my questions would be as follows
why do counter pages need a target?, and why not page 2?
What is this repeatadd command and how does it work? same for repeatdel?
Why apply that to all counter pages?
What is this action:mult thing?
lastly, how could you add this to your tease relatively easy?
Post Reply

Who is online

Users browsing this forum: No registered users and 52 guests