Hello. How can you make a block in which the player starts whenever the value of a variable changes (without using a database (tiny, etc.))?Only when the variable is changed, the player should be started, if the variable is fixed, the player should not be started. Thank you.
Keep a backup for the variable, and watch them both in a clock timer.
When they differ, start the player and update the backup.
Hi, how do I have a backup of the variable(without using a database (tiny, etc). Thanks
What, who triggers the changes in the variables?
Show your blocks (what you have tried so far).
Hello and thanks, there are many ways to change a variable (moving an object, clicking on that object, etc.), but regardless of the reasons for changing the variable, the question is how to have a backup from variable (without using the database(tiny and etc)then compate with before change and noticed are changed variable?. Thank you
It can definitely play a role what triggers the change in the variable, because some methods trigger AfterChanged events so that the player could then be started within the event.
What's the problem with revealing your relevant blocks and the exact reason for your actions?
Hello, I want to hear a short sound when the label changes a value.
AbacusPlayer.aia (209.4 KB)
(What's the problem with revealing your relevant blocks and the exact reason for your actions?)!!!!
I don't see any Player component (block). When and where should the player be started?
How about you explain your approach in detail and not just give us an AIA and leave us guessing?
I want to make an abacus.When we move the beads up or down, a number is added or subtracted, and the Lable 1 shows that number. We want a sound effect to be heard when the numbers of Lable 1 are added or subtracted(changed).
abacus
(How about you explain your approach in detail and not just give us an AIA and leave us guessing?)!!!
Hi-thanks a lot I have shown Anke solution here.
Isn't this the solution I gave you?
Hi, yes. This is your solution, which I have copied. Thanks
init global variableIwantToWatch = 0
init global mirrorOfVariableIwantToWatch = 0
(some code that might change variableIwantToWatch )
ClockThatWatchesMyVariables.Timer
- if variableIwantToWatch not= mirrorOfVariableIwantToWatch then
- play a sound
- set mirrorOfVariableIwantToWatch to variableIwantToWatch
This type of approach is called cross-cutting, a Deus Ex Machina approach that can catch coders unaware if they haven't checked for pesky snooping, meddling Clock Timers.
An alternative approach would be to code a procedure called UpdateVariableIwantToWatch , given the responsibility of updating variableIwantToWatch with its input parameter value, and hook in the Player sound call there. Then you would have to go back and look through all your blocks to where you try to update variableIwantToWatch directly, and replace those blocks with calls to your new procedure. That's sometimes called Information Hiding, and best done before you start a lot of coding. It can have extra benefits too, like if you are hiding your variable in a TinyDB tag/value for the permanence benefits and you code (and use) a getter procedure to match your new setter procedure.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.