Two Stop Watches. Stop Watch That Runs Longer Wins?

Cheesy

New member
Hey there, I am trying to expand on a current macro I have. I have two buttons, each run separate macros that both have a stopwatch. Currently, it is setup so that at the end of a timer, whichever button was pressed last, will "win" and a "Blue button wins" macro will run (vice versa for the red button winning).

I was curious if anyone knew a way of having whichever button had the longest timer by the end, wins, and that buttons macro will play as the winner? Hopefully, that makes sense.

------------------------------------------

So for example the whole macro runs for 5 minutes.

If:
  • Blue button gets pressed four times, for a total of 1 minute.

  • Red button gets pressed one time, for a total of 4 minutes.

Ideally, the Red button would win because even tho it was pressed less, it ultimately had more "active time".
 

420

Active member
Yeah it's possible, as far as i know you cannot compare 2 stopwatches with eachother directly, so you have to create a integer variable and set it to the stopwatch time, then you can use an if clause to check if that variable is less then the other stopwatch. (You could also create another integer to write the other stopwatch to if you want, but it's not needed) here is example;
 

Attachments

  • Screenshot_20210423-122959.png
    Screenshot_20210423-122959.png
    136.1 KB · Views: 9

Cheesy

New member
Yeah it's possible, as far as i know you cannot compare 2 stopwatches with eachother directly, so you have to create a integer variable and set it to the stopwatch time, then you can use an if clause to check if that variable is less then the other stopwatch. (You could also create another integer to write the other stopwatch to if you want, but it's not needed) here is example;
Oh wow, awesome Thank you! I've been trying to recreate this on my end but I'm having some trouble (I'm fairly new to setting up/using variables).

Would I be able to ask if you could share the file for that example macro with me, by chance? I could take that and dissect it, and better understand how it's setup.
 

420

Active member
Oh wow, awesome Thank you! I've been trying to recreate this on my end but I'm having some trouble (I'm fairly new to setting up/using variables).

Would I be able to ask if you could share the file for that example macro with me, by chance? I could take that and dissect it, and better understand how it's setup.
i gues im fairly new to, because i don't know how to share a macro file lol. if you (or anyone else) can tell me how to do that i will.

i will try to explain it better, so maybe you won't need the file:

first you need to create an INTEGER variable, you can just create an action, "set variable" and the default variable will be [new variable], so you can just press ok. (you can also create it through the variables tab on macrodroid homescreen, but this way it also creates the action so i prefer this way)

now you can choose if you want a local variable or a global one. (local means it only work/exists in that macro, global means you can also use it in other macro's)

you can give it whatever name you want, and then press the arrow next to "boolean" and pick integer instead, press ok, then it will ask you what you want it to set it to, pick expression, click the 3 dots to the right of the enter value field, pick the stopwatch you want to set it to, press ok and ok again, the action + variable are now created.

now on to the if clause: add an action "if clause" click the + to add a condition, macrodroid specific - macrodroid variable, pick the variable you just created, instead of the = on top pick < to check if the variable value is less then the stopwatch, now you select expression again (instead of a set value) click the 3 dots again and pick the other stopwatch (so not the one that you set the variable to) press ok to save, i assume you know how to add the "else" to the if clause.

this has gotten a bit long but i hope you understand it now.
 

420

Active member
i just realized theres another way to do this, since it is max 5 minutes, you could use an if clause: if (stopwatch: red) > 2 min 30 sec, else if (stopwatch: blue) > 2 min 30 sec, that should also work (unless they could both be under 2 min 30 sec, i don't know) and you won't even need the variable.
 

420

Active member
If you do it like this you can also add different actions for when it's a draw (i know it's a small chance that both are exactly the same amount of seconds but if it happens you will be prepared)
 

Attachments

  • Screenshot_20210423-154511.png
    Screenshot_20210423-154511.png
    149.8 KB · Views: 3

420

Active member
I had another Idea (don't know if you'll like it, i thought it was pretty cool) now it will subtract the losing time from the winning time, so it can tell you by howmany seconds blue or red won.
 

Attachments

  • Screenshot_20210423-161325.png
    Screenshot_20210423-161325.png
    174.1 KB · Views: 5

Cheesy

New member
i gues im fairly new to, because i don't know how to share a macro file lol. if you (or anyone else) can tell me how to do that i will.

i will try to explain it better, so maybe you won't need the file:

first you need to create an INTEGER variable, you can just create an action, "set variable" and the default variable will be [new variable], so you can just press ok. (you can also create it through the variables tab on macrodroid homescreen, but this way it also creates the action so i prefer this way)

now you can choose if you want a local variable or a global one. (local means it only work/exists in that macro, global means you can also use it in other macro's)

you can give it whatever name you want, and then press the arrow next to "boolean" and pick integer instead, press ok, then it will ask you what you want it to set it to, pick expression, click the 3 dots to the right of the enter value field, pick the stopwatch you want to set it to, press ok and ok again, the action + variable are now created.

now on to the if clause: add an action "if clause" click the + to add a condition, macrodroid specific - macrodroid variable, pick the variable you just created, instead of the = on top pick < to check if the variable value is less then the stopwatch, now you select expression again (instead of a set value) click the 3 dots again and pick the other stopwatch (so not the one that you set the variable to) press ok to save, i assume you know how to add the "else" to the if clause.

this has gotten a bit long but i hope you understand it now.
So just a follow-up on this, thank you very much for the help! This worked beautifully! I am going to definitely work on adding that setup you mention so it tells you by how much time which team won by, that's super cool!
 
  • Like
Reactions: 420

Cheesy

New member
I had another Idea (don't know if you'll like it, i thought it was pretty cool) now it will subtract the losing time from the winning time, so it can tell you by howmany seconds blue or red won.
So I was able to give the whole setup a good run this weekend. And it worked wonderfully! One request from everyone was for the automation to tell us by exactly how much time one team beat the other. Luckily for me, you're awesome enough to have already figured that out! I've just implemented your setup, and that worked great! It's setup now to not only have a message for if there is a draw, but also it will read off the difference in time one team beat the other by. Thank you again for the help here!
 
  • Like
Reactions: 420
Top