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 


[help] If value under X, set to Y

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

Joined: 25 Oct 2024
Posts: 5

PostPosted: Fri Oct 25, 2024 5:27 am    Post subject: [help] If value under X, set to Y Reply with quote

Hello, I'm a complete noob at scripting on CE, but I need help about scripting this action:

Info:
I have the pointer(s) for the adress.
The value is in float.

Script:
"If the value of the adress in float that this POINTER points to is less than X(x is 2.0) then set the value to Y (y is 10)

Additional Info:
I did the find out what writes to this adress thing but when I changed it to NOP then the game froze, Id rather just use the pointer and a script.
The minimum of X is 0 automatically.
I do this because freezing the adress crashes the game during cutscenes.

Help would be appreciated thank you!
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

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

PostPosted: Fri Oct 25, 2024 6:47 am    Post subject: Reply with quote

Say you have X and Y pointers within the Cheat Table with the description X pointer and Y pointer respectively, then you can do this:
Code:

[ENABLE]
{$LUA}
if syntaxcheck then return end
local x = AddressList['X Pointer']
local y = AddressList['Y Pointer']
if x == nil or y == nil then error('Unable to find X/Y Pointer entries in the address list') end
if x.Value < 2.0 then
   y.setValue(10)
end
{$ASM}
[DISABLE]


It should be noted that comparing float values can be inaccurate.
Back to top
View user's profile Send private message
MDon
How do I cheat?
Reputation: 0

Joined: 20 Dec 2024
Posts: 4

PostPosted: Fri Dec 20, 2024 8:10 am    Post subject: Re: [help] If value under X, set to Y Reply with quote

x = math.max(0,x)
Back to top
View user's profile Send private message Send e-mail
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