Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


I need help in Pressing Virtual Joypad Buttons

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
percypierce
How do I cheat?
Reputation: 0

Joined: 15 Jan 2021
Posts: 4

PostPosted: Tue Nov 01, 2022 8:23 pm    Post subject: I need help in Pressing Virtual Joypad Buttons Reply with quote

I am Trying to Automate an existing Fighting Game.

Before The Weekend, I was Using a emulator to Run the game, and I created about a PAGE long lua script.
The Joypad buttons Used an address value that was pointed at by the Exe file, and the LUA script modified its value in order to make the fighters move left and right. The Values that were modified would Stick until the Real (physical) joypad buttons were (pressed and) Released.

Then Windows 10 UPDATES!
This Rendered the Emulator Unstable, and It frequently CRASHED down!

So I had to install an update.

This new version now Constantly Checks the Real controller's button state, and will Change the value of the Joypad's Address, rendering my pointers useless.

Now I need to use Virtual Keys to control the characters.

My two Controllers are:
1 xbox one controller
2 logitech rumblepad2 (released in 2004)

I seen Virtual keys for Keyboard and Mouse inputs, but I need a little help with how to use virtual keys for joypads, which joypad indects I should map, buttons, etc.

I just need to be able to press (and hold) left, right, and sometimes down.

Here's my old cold:


Code:


local yourbuttons1 = '[[[SSF.exe + 1C1B910]+10]+54]+14';// Player 1
local yourfacing1 = 'SSF.exe + A74FF69';
local yourbuttons2 = '[[[SSF.exe + 1C1B910]+f4]+54]+10';  // Player 2
local yourfacing2 = 'SSF.exe + A750371';


local function walkaway()


if readBytes(yourfacing1) == 0 then
writeInteger(yourbuttons1,9000); //replace with Virtual Key for Right
else
writeInteger(yourbuttons1,27000);//replace with Virtual Key for Left
      end 

end


local function walkaway()

if readBytes(yourfacing2) == 0 then
writeInteger(yourbuttons2,9000); //replace with Virtual Key for Right
else
writeInteger(yourbuttons2,27000);//replace with Virtual Key for Left
     end 

end



_________________
Some may call it "CHEAT"Engine, But I call it BEAT Engine! The engine that beats ME in games!


Last edited by percypierce on Thu Nov 03, 2022 5:02 am; edited 2 times in total
Back to top
View user's profile Send private message
percypierce
How do I cheat?
Reputation: 0

Joined: 15 Jan 2021
Posts: 4

PostPosted: Wed Nov 02, 2022 2:29 pm    Post subject: Reply with quote

Sorry for the Double Post.

Ok, So I Remapped the Joypad Directional Keys to
W for 1p Up
Z for 1p Down
A for 1p Left
S for 1p Right

And

I for 2p up
M for 2p Down
J for 2p Left
K for 2p Right

And I am using some doKeypress and keyDown functions
but they are not registering!!!!!


Here's my code for this:

Code:

local function walkaway()


if readBytes(yourfacing) == 0
then keyDown(VK_K);
else keyDown(VK_J);
end 
end


With this code, the character should be able to at least move forward a little bit and stop, since I didn't write keyUp yet.

oh, By the way, when I use the Sleep function, what happens is It shows on my helper window that I made.
normally the alarm timer counts down once a millisecond, but when I use Sleep, it merely slows that timer down to about once a HALF a millisecond. No sleep doesn't affect the virtual key press.

_________________
Some may call it "CHEAT"Engine, But I call it BEAT Engine! The engine that beats ME in games!


Last edited by percypierce on Thu Nov 03, 2022 4:58 am; edited 1 time in total
Back to top
View user's profile Send private message
Frouk
Grandmaster Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 510

PostPosted: Thu Nov 03, 2022 2:38 am    Post subject: Reply with quote

percypierce wrote:
Sorry for the Double Post.

Ok, So I Remapped the Joypad Directional Keys to
W for 1p Up
Z for 1p Down
A for 1p Left
S for 1p Right

And

I for 2p up
M for 2p Down
J for 2p Left
K for 2p Right

And I am using some doKeypress and keyDown functions
but they are not registering!!!!!


Here's my code for this:

Code:

local function walkaway()


if readBytes(yourfacing) == 0 then keyDown(VK_K);
                     else keyDown(VK_K);
end 
end


With this code, the character should be able to at least move forward a little bit and stop, since I didn't write keyUp yet.

oh, By the way, when I use the Sleep function, what happens is It shows on my helper window that I made.
normally the alarm timer counts down once a millisecond, but when I use Sleep, it merely slows that timer down to about once a HALF a millisecond. No sleep doesn't affect the virtual key press.

I recommend you to format the code you wrote because someone can't understand what you wrote

EDIT:

instead of overriding function use elseif
Code:
local yourbuttons1 = '[[[SSF.exe + 1C1B910]+10]+54]+14'
local yourfacing1 = 'SSF.exe + A74FF69'
local yourbuttons2 = '[[[SSF.exe + 1C1B910]+f4]+54]+10'
local yourfacing2 = 'SSF.exe + A750371'

-- we don't need to write ; after writing, it's not C++ syntax, so it won't give you an error

local function walkaway()
  if readBytes(yourfacing1) == 0 then
    writeInteger(yourbuttons1, 9000)
  else
    writeInteger(yourbuttons1, 27000)
  end
  if readBytes(yourfacing2) == 0 then
    writeInteger(yourbuttons2, 9000)
  else
    writeInteger(yourbuttons2, 27000)
  end
end
Back to top
View user's profile Send private message
percypierce
How do I cheat?
Reputation: 0

Joined: 15 Jan 2021
Posts: 4

PostPosted: Thu Nov 03, 2022 5:20 am    Post subject: Reply with quote

Frouk wrote:

I recommend you to format the code you wrote because someone can't understand what you wrote


Done!


Also, I still haven't had my Virtual Keyboard key issue resolved.
I tried this:

Code:

z=createTimer(nil) // creates a "STEP" event that monitors the address value changes for every 1000ths of a second
z.Interval=1
z.OnTimer=function(z)

local ontheground = 'SSF.exe + 0xA75016B';

if ontheground == 1 then
   keyDown(VK_A);
else
    keyUp(VK_A); //Move the player left or right
    end

z.enabled = true;// timer begins once the execute script button is clicked
end




on the game, the address value is 1 until I physically press for the a button, then the value at the address becomes 3 or 2. When I release it it becomes One again. keyDown, and keyUp is not firing. I know this because the player (which I have mapped to these keyboard keys) isn't moving.

_________________
Some may call it "CHEAT"Engine, But I call it BEAT Engine! The engine that beats ME in games!
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1531

PostPosted: Sat Nov 05, 2022 3:35 pm    Post subject: Reply with quote

Do not give single letters to the controls, they must be at least double.

Code:
if z1 then z1.Destroy() z1=nil end
z1=createTimer()
z1.Interval=50 -- or 1 sec 1000

z1.OnTimer=function()
local ontheground = 'SSF.exe + 0xA75016B';

 if ontheground == 1 then
   keyDown(VK_A);
 else
   keyUp(VK_A);
 end
end

z1.enabled = true;


max second stop timer ..
Code:
if z1 then z1.Destroy() z1=nil end
z1=createTimer()
z1.Interval=50 -- or 1 sec 1000
local act1 = 0

z1.OnTimer=function()
local ontheground = 'SSF.exe + 0xA75016B';
act1 = tonumber(act1) + 1

 if ontheground == 1 then
   keyDown(VK_A);
 else
   keyUp(VK_A);
 end
 if act1==100 then -- 100 x 50 = 5000 (5 sec)
  keyUp(VK_A);
  z1.enabled = false
 end
end

z1.enabled = true;

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites