How to create dynamic Timers so they don't interrupt each other

Hi there,

In my Castle Builder, I am building a dynamic Resource increase Logic, and the problem now I have is that Buttons interrupt each other as they share the same timer

I am using Structure Variables and Object Variables / Instances and managed to get it all work apart from Timers… it works for one building but then obviously there needs to be different timers for different buildings and I don’t know how to create that dynamic “timer name” so it doesn’t get reset and interrupt whenever the button is pressed, so the other Resource production processes don’t get interrupted. Hope my explanation makes sense!

Any ideas?

I think you need for each instance event here

If the timerName is a string variable then you don’t need ToString() if it is a string then using ToString() with a string will actually return zero because ToString() is expecting a number.

Like ZeroX4 said, you might need a for each object on the 2nd event because I think if there are multiple objects then it might only be checking the timer name for the oldest object.

Usually timer names are fixed, something like “LevelingUp” or “Building”, each button could have a timer or if the button is referencing another object then that object timer could be used. I’m not clear on your method.

If producing of button is true
If “LevelingUp” of button > 2

If you’re using the button variable as a timer name then

If producing of button is true
… For each button
… … If timer(button.timerName)

Again, I personally would use a fixed name. Unless there are more timers than objects.

Thanks guys!

I think you need for each instance event here

You were 100% right @ZeroX4 !! thanks for the hint!

@Keith_1357

If the timerName is a string variable then you don’t need ToString() if it is a string then using ToString() with a string will actually return zero because ToString() is expecting a number.

Thanks a lot for this explanation, I wasn’t sure how to use them. I’ve removed it now.

I now managed to create the logic!! I am so happy!!! I feel this was “the last” main missing link in my entire logic to automate everything :DD I hope I’ll be able to build it all dynamically.

In case anyone else might benefit from it, here it (also with a basic resource increase multiplier)

1 Like