How to add value of variable, everytime loops happen

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
MamboWumbo
Posts: 16
Joined: 15 Jul 2021, 21:08

How to add value of variable, everytime loops happen

26 Jul 2021, 03:25

how to increase Variable "Jump" value, every time loop happened, for example

each loop happened, the jump will increase +1, the loop finished then +1,+1... i have no idea please help :crazy:

Code: Select all

Jump:= 1

loop %Jump% {
controlsend,,{space},ahk_exe Game.exe
}
User avatar
Xeo786
Posts: 760
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: How to add value of variable, everytime loops happen

26 Jul 2021, 03:57

use ++jump inside loop, where ++jump is equal to jump := jump +1
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
MamboWumbo
Posts: 16
Joined: 15 Jul 2021, 21:08

Re: How to add value of variable, everytime loops happen

26 Jul 2021, 04:03

Xeo786 wrote:
26 Jul 2021, 03:57
use ++jump inside loop, where ++jump is equal to jump := jump +1
Hi thanks for the reply, I try your advice but the result did not become jump 1x, jump 2x, jump 3x
the result become powers, the jump becomes 1x, jump 2x, jump 4x, jump 16x,
User avatar
boiler
Posts: 17041
Joined: 21 Dec 2014, 02:44

Re: How to add value of variable, everytime loops happen

26 Jul 2021, 04:10

You’re still going to loop only one time because the number of times to loop is evaluated once, and jump is 1 at that time. If your purpose is to keep looping, then you wouldn’t use a value with the loop anyway:

Code: Select all

loop {
controlsend,,{space},ahk_exe Game.exe
}

If you just need a variable that increases each time through the loop and starts with 1, then you can use the built-in looping variable A_Index, which is described in the loop documentation. It will increment by 1 each time through the loop without you telling it to.
User avatar
Xeo786
Posts: 760
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: How to add value of variable, everytime loops happen

26 Jul 2021, 07:07

MamboWumbo wrote:
26 Jul 2021, 04:03
Xeo786 wrote:
26 Jul 2021, 03:57
use ++jump inside loop, where ++jump is equal to jump := jump +1
Hi thanks for the reply, I try your advice but the result did not become jump 1x, jump 2x, jump 3x
the result become powers, the jump becomes 1x, jump 2x, jump 4x, jump 16x,
i suspect its because of ++jump inside loop, just put it outside, so when your code repeats, it get added by +1 only once,
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: iamasink and 346 guests