Move my character left or right, but randomly

Ask gaming related questions (AHK v1.1 and older)
Jasminelee123
Posts: 3
Joined: 18 Mar 2018, 11:17

Move my character left or right, but randomly

18 Mar 2018, 11:26

Code: Select all

SendMode Play
s::
Loop, 100
{
Send, {a down}
}
so, I have this right now, and it makes my character move to the left.
BUT, what I want, is for it to move to the left or right, but randomly.
How do I do this;-;
note: just pressing the button quickly won't move the character, so that is why the a is being held down
User avatar
Nwb
Posts: 444
Joined: 29 Nov 2016, 08:56

Re: Move my character left or right, but randomly

18 Mar 2018, 11:53

Does this work as wanted?

Code: Select all

SendMode Play
s::
Loop, 100
{
Random, No, 1, 2
If (No = 1) {
Send, {d up}
Send, {a down}
}
else {
Send, {a up} 
Send, {d down}
}
}
return
I am your average ahk newbie. Just.. a tat more cute. ;)
Jasminelee123
Posts: 3
Joined: 18 Mar 2018, 11:17

Re: Move my character left or right, but randomly

18 Mar 2018, 12:31

its closer, but not exactly what i need
when i press s, (the hotkey), itll just switch directions
and it doesnt always work, so i THINK what you gave me was, it has a chance to switch directions if i press s
User avatar
Nwb
Posts: 444
Joined: 29 Nov 2016, 08:56

Re: Move my character left or right, but randomly

18 Mar 2018, 12:48

Jasminelee123 wrote:its closer, but not exactly what i need
when i press s, (the hotkey), itll just switch directions
and it doesnt always work, so i THINK what you gave me was, it has a chance to switch directions if i press s

Code: Select all

No := 0

SendMode Play
s::
Loop, 100
{
If not No {
Send, {d up}
Send, {a down}
No := !No
}
else {
Send, {a up} 
Send, {d down}
No := !No
}
}
return
I am your average ahk newbie. Just.. a tat more cute. ;)
Jasminelee123
Posts: 3
Joined: 18 Mar 2018, 11:17

Re: Move my character left or right, but randomly

18 Mar 2018, 12:57

now the character is only moving right. ;-;
User avatar
Nwb
Posts: 444
Joined: 29 Nov 2016, 08:56

Re: Move my character left or right, but randomly

19 Mar 2018, 02:44

Jasminelee123 wrote:now the character is only moving right. ;-;

What about now?

Code: Select all

No := 0

SendMode Play
s::
Loop, 100
{
No := !No
If No {
Send, {d up}
Send, {a down}
}
else {
Send, {a up} 
Send, {d down}
}
}
return
I am your average ahk newbie. Just.. a tat more cute. ;)

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: vysmaty and 121 guests