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 


Negative integer puzzle

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Csimbi
I post too much
Reputation: 97

Joined: 14 Jul 2007
Posts: 3324

PostPosted: Sat Nov 02, 2024 5:53 am    Post subject: Negative integer puzzle Reply with quote

Hello,
I have this code:
Code:
      local i=readInteger(baseAddress+iOffset)
      if i<0 and i>=(0-iTolerance) then e.DisplayMethod = 'dtSignedInteger'
      elseif i>iTolerance then e.DisplayMethod = 'dtHexadecimal'
      end

iTolerance is set to 100.
Negative integers between 0 and negative tolerance are displayed as HEX.
I must be missing something banally simple Very Happy
Any ideas?

Thanks!
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1520

PostPosted: Sat Nov 02, 2024 11:03 am    Post subject: Reply with quote

Here's the point you missed:
Code:
i = -1 --> readInteger(address) = 4294967295

-- use

i = -1 --> readInteger(address, true) = -1



Example:
Code:
iTolerance = 100
addr = "30C11A44" -- ex..
local i=readInteger(addr,true)
print(i)
      if i>=0 and i<=iTolerance then print('dtSignedInteger')
      else print('dtHexadecimal')
      end

-- res <0 ~ 100> = dtSignedInteger /// >0 ~ 100< = dtHexadecimal
-- i = -1 --> dtHexadecimal
-- i = 99 --> dtSignedInteger
-- i = 100 --> dtSignedInteger
-- i = 101 --> dtHexadecimal


-- or
Code:
iTolerance = 100
iTolerance1 = 1-iTolerance
--print(iTolerance1)
addr = "30C11A44"
local i=readInteger(addr,true)
print(i)

      if i >= iTolerance1 and i <= iTolerance then print('dtSignedInteger')
      else print('dtHexadecimal')
      end

-- res <-100 ~ 100> = dtSignedInteger /// >-100 ~ 100< = dtHexadecimal
-- i = -2 --> dtSignedInteger
-- i = -100 --> dtSignedInteger
-- i = -101 --> dtHexadecimal
-- i = 10 --> dtSignedInteger
-- i = 100 --> dtSignedInteger
-- i = 101 --> dtHexadecimal


Good luck .. Smile

_________________
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
Csimbi
I post too much
Reputation: 97

Joined: 14 Jul 2007
Posts: 3324

PostPosted: Sat Nov 02, 2024 5:29 pm    Post subject: Reply with quote

Quote:

readInteger(address) : Reads a 32-bit integer from the specified address

I did not think it had a hidden a parameter; thanks, works now!
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