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 


[Q] Complex Lua question |P to Unicode String to P on Button

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

Joined: 13 Jan 2022
Posts: 0

PostPosted: Thu Jan 13, 2022 10:32 am    Post subject: [Q] Complex Lua question |P to Unicode String to P on Button Reply with quote

Hello everyone,

I wanted to get more into assembler and LUA so I decided to take one of my favorite games apart, so far successfully, learning a lot in the meantime.
However, I have run into a wall that I can't solve yet.

What I have:

    Level 2 pointer to X
    Level 2 pointer to Y
    Level 4 pointer to X2
    Level 4 pointer to Y2


What I want:
At the press of a button, I want to read from X2, Y2 and put the value into the memory of X, Y respectively.

The issue:

    X and Y are floats
    X2 and Y2 are Unicode String[5] and need to be parsed.
    I have no clue how to do all that at the press of a button


Nice to have:
Freezing X and Y via LUA as well instead of over Toggle Freeze.

Any help is appreciated.
Best regards.
Back to top
View user's profile Send private message
Frouk
Expert Cheater
Reputation: 1

Joined: 22 Jun 2021
Posts: 233

PostPosted: Sat Jan 15, 2022 6:24 am    Post subject: Reply with quote

@atom0s move it to lua scripting,this post is in inappropriate section
_________________
void(*Haxing)(int Game)
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater
Reputation: 5

Joined: 02 Sep 2011
Posts: 528
Location: 0x90

PostPosted: Sat Jan 15, 2022 7:18 am    Post subject: Re: [Q] Complex Lua question |P to Unicode String to P on Bu Reply with quote

Gravitary wrote:
Hello everyone,

I wanted to get more into assembler and LUA so I decided to take one of my favorite games apart, so far successfully, learning a lot in the meantime.
However, I have run into a wall that I can't solve yet.

What I have:

    Level 2 pointer to X
    Level 2 pointer to Y
    Level 4 pointer to X2
    Level 4 pointer to Y2


What I want:
At the press of a button, I want to read from X2, Y2 and put the value into the memory of X, Y respectively.

The issue:

    X and Y are floats
    X2 and Y2 are Unicode String[5] and need to be parsed.
    I have no clue how to do all that at the press of a button


Nice to have:
Freezing X and Y via LUA as well instead of over Toggle Freeze.

Any help is appreciated.
Best regards.


You can use a timer to set the value of X and Y via Lua. As for the Unicode String you could use the Lua function tonumber(variable).
Code:

local x = "500.00"

-- print is to show the casting although visibly, they look the same.
print(tonumber(x))


For a timer you can do something like this:
Code:

local mytimer = createTimer(getMainForm())
mytimer.Interval = 1000 -- Interval is in milliseconds
mytimer.OnTimer = function()
                     local al = getAddressList()
                     local X = al.getMemoryRecordByDescription("Entry in table that has X description")
                     local Y = al.getMemoryRecordByDescription("Entry in table that has Y description")

                     local X2 = al.getMemoryRecordByDescription("Entry in table that has X2 description")
                     local Y2 = al.getMemoryRecordByDescription("Entry in table that has Y2 description")

                     -- Double-check that the entries exist
                     if X ~= nil and Y ~= nil and X2 ~= nil and Y2 ~= nil then
                        X.Value = tonumber(X2)
                        Y.Value = tonumber(Y2)
                     else
                        -- If the entries don't exist, we don't want the timer to continue running so we kill it
                        mytimer.destroy()
                        mytimer = nil
                     end
                  end
Back to top
View user's profile Send private message
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