Page 1 of 1

Some slightly advanced EOS questions

Posted: Sat Feb 19, 2022 12:18 pm
by arandommark
Hey, I've been playing around with EOS a bit, and between some basic programming knowledge and what's already on the forums I've been capable of figuring out most of what I wanted to do.

However, there's a few things I can't seem to find an answer to, and was wondering if someone of the more experienced creators could help me with:

1 is there a way to make infinitely repeating notifications?

For example: I want to make an 'edging' button that gives you a ten-second timeout, ads +1 to an invisible variable, and then lets you continue on where you left off(skipping the current timer in my testing, but I'm fine with that).
However, I can't/don't know how to make the button then recreate itself/never go away in the first place.
(or, I can make it recreate itself, but that would only work as many times as I can be bothered to nest it, which is really annoying and unclean besides)

2 is there a way to make a 'Disable' command automatically refer to the page it's on.

I want to make a tease with quite a few pages, which should appear in a random order - but only once each.
My plan is for this to happen with the page* -command, and simply disabling the pages which are done. However, if I do this individually, I'm almost sure to mess at least one up and it's annoying either way.

If someone has answers to these questions, they'd be much appreciated.

(and, in fact, if someone has some questions about eos I might be capable of answering, feel free to post them here.)
(in that case, be sure to read the 'Here are EOS tutorials' sticky thread first, though.)

Re: Some slightly advanced EOS questions

Posted: Sat Feb 19, 2022 1:04 pm
by Domi-nation
Question 1:
There is no real supported way of achieving this but there are two "hacks" you can use:

The first is the one you mentioned (nesting notifications).
The quickest to achieve that is nesting by copying the notification. For example you can create your notification template than copy paste it on the button pressed action. And each time you copy paste you copy the root notification.
That way the nesting increases exponentially (2, 4, 8, 16, 32, 64, ...)

EDIT: Don't go too hard on the nesting, I wanted to make one you could use as a template and went a bit high, maybe 128 and now my editor crashes as soon as I click on the tease containing that nested notification :rolleyes:

The second is adding those in a pages that redirect to itself when the notification is pressed. If you have a dialog, you can create a step variable that will bring you back on the active dialog line. You need to initialize the step variable outside the page.
Then each say action would be in an if statement. That if statement would be structure like this:
  • If step === 0
  • Say: Your dialog
  • Eval: step ++
Question 2:
You can add this function in the init script and call it in an eval where you need it:

Code: Select all

function disableCurrentPage(){
	var id = pages.getCurrentPageId()
	pages.disable(id)
}

Re: Some slightly advanced EOS questions

Posted: Sat Feb 19, 2022 2:43 pm
by arandommark
Domi-nation wrote: Sat Feb 19, 2022 1:04 pm Question 1:
There is no real supported way of achieving this but there are two "hacks" you can use:

The first is the one you mentioned (nesting notifications).
The quickest to achieve that is nesting by copying the notification. For example you can create your notification template than copy paste it on the button pressed action. And each time you copy paste you copy the root notification.
That way the nesting increases exponentially (2, 4, 8, 16, 32, 64, ...)

EDIT: Don't go too hard on the nesting, I wanted to make one you could use as a template and went a bit high, maybe 128 and now my editor crashes as soon as I click on the tease containing that nested notification :rolleyes:
Okay, that's annoying. Though if I semi-frequently refresh it I can get away with having only 8 or so nested.
Domi-nation wrote: Sat Feb 19, 2022 1:04 pm The second is adding those in a pages that redirect to itself when the notification is pressed. If you have a dialog, you can create a step variable that will bring you back on the active dialog line. You need to initialize the step variable outside the page.
Then each say action would be in an if statement. That if statement would be structure like this:
  • If step === 0
  • Say: Your dialog
  • Eval: step ++
And, sorry about my lack of knowledge, but would you mind explaining why the if function has three '='s instead of two, or is that just a typo?
Domi-nation wrote: Sat Feb 19, 2022 1:04 pm Question 2:
You can add this function in the init script and call it in an eval where you need it:

Code: Select all

function disableCurrentPage(){
	var id = pages.getCurrentPageId()
	pages.disable(id)
}
Thanks, that's exactly what I was looking for!

Re: Some slightly advanced EOS questions

Posted: Sat Feb 19, 2022 3:57 pm
by Domi-nation
arandommark wrote: Sat Feb 19, 2022 2:43 pm And, sorry about my lack of knowledge, but would you mind explaining why the if function has three '='s instead of two, or is that just a typo?
In javascript the '==' is the equality operator and the '===' is the strict equality operator.

The strict equality operator '===' will compare the values and their types. For example '10' === 10 will return false. That's because one is a string and the other is a number.
  • '10' === 10 (returns false)
  • 10 === 10 (returns true)
  • 10 === 7 (returns false)
  • 0 === false (returns false)
The equality operator will try to convert the values to the same type before check for equality.
  • '10' === 10 (returns true)
  • 10 === 10 (returns true)
  • 10 === 7 (returns false)
  • 0 === false (returns true)
In javascript the best practice is to use '===' instead of '==' because it will help you detect bugs faster.
For example imagine your tease becomes very long and you forget you're using step in a page and somewhere else you have :

Code: Select all

step = step + ''
This code will turn your number into a string.
And after that if you increment the number like this:

Code: Select all

step = step + 1
You will concatenate one with your string instead of incrementing the step by one.
And you will go from '10' to '101' for example.

If you used '==' instead of '===' the tease would go from line 10 to line 101 and you might not even notice it.

Re: Some slightly advanced EOS questions

Posted: Tue Feb 22, 2022 9:59 pm
by arandommark
Domi-nation wrote: Sat Feb 19, 2022 3:57 pm
arandommark wrote: Sat Feb 19, 2022 2:43 pm And, sorry about my lack of knowledge, but would you mind explaining why the if function has three '='s instead of two, or is that just a typo?
In javascript the '==' is the equality operator and the '===' is the strict equality operator.

The strict equality operator '===' will compare the values and their types. For example '10' === 10 will return false. That's because one is a string and the other is a number.
...
Good to know. Thanks for the explanation!