Have i idea not sure how to add a counter


#1

Hi All,
I have an idea I need help with I like to add a counter to this that goes up by 1 every time the script is run then rest at midnight every day
thanks for any help


#2

Just define a “run count” variable and increase it each time the piston runs.

Local variables can have an initial value that is set every time the piston runs. If omitted, any value set to the variable will carry over for use in future executions of the piston.

Rest until when?


#3

@Pantheon Can you show me an example
thanks beau


#4


Not sure what “rest” time frame you want, but I put that in also.


#5

I think “rest” is supposed to be “reset”


#6

Ooops! I bet you are correct… :slight_smile:


#7


#8

@Pantheon I do have one question in the code i posted above where would you put the if for the reset in there ?
Thanks


#9

I have not tested this. But I don’t think that it matters where you put the counter or the reset. Realize that this piston will run every night at midnight and reset the Piston_Count to 0. But then immediately after that the Piston_Count will be set to 1 because it just ran. So each day, your Piston_Count will always be at least 1. Each time one of your IF triggers is triggered will also add 1 to the Piston_Count because the piston will always execute from top to bottom. You can adjust the logic if you do not want to add 1 to the Piston_Count at midnight.


#11

@Pantheon the way that if is worded would it reset the first time the script is run after the time
as the script is not run daily?


#12

The piston that I posted will run at least once a day at midnight and will reset the Piston_Count each night at midnight. Isn’t that what you wanted? Did that answer your question?


#13

@Pantheon it is working good thanks for all the help