Go Down

Topic: HELP NEEDED - HOW TO STOP COUNTDOWN GOING PAST ZERO (Read 193 times) previous topic - next topic

philipedwards

I have attached my code (Quite Large) each weapon has a different countdown on button press (Fire) and sets to reload at Zero, but if you continue to press Fire the Counter goes in to Negative Figures.

How do I get the Counter to Stop at zero until the Reload Button is Pressed.

All Works fine except the counters going to Negative Figures.

I'm no programmer and don't understand all the jargon so please dummy language and examples please..

Many thanks

aarg

With almost 70kb of code to plow through, don't you think you should tell us what "Counter" you are talking about?
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

jremington

#2
Dec 05, 2017, 11:43 pm Last Edit: Dec 05, 2017, 11:44 pm by jremington
What a mess. Whoever wrote that has never heard of arrays.

But to the problem.

Here is where one particular counter is reduced by 5:
Code: [Select]
      buttonPushCounter2-=5;
You can add one line as follows to reset that counter, if it is negative:
Code: [Select]

      buttonPushCounter2-=5;
      if (buttonPushCounter2 < 0) buttonPushCounter2 = 0;

philipedwards

Many thanks for the Help. All sorted and working 100%

Thanks Guys.

PS sorry for the messy code, but as I Said I'm no programmer.

Go Up