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 


Subtraction from value somehow producing even bigger value

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
zxuiji
Advanced Cheater
Reputation: 1

Joined: 26 Sep 2016
Posts: 70

PostPosted: Mon Jan 15, 2018 4:37 am    Post subject: Subtraction from value somehow producing even bigger value Reply with quote

The value I should be getting atm is 76B0041 but Cheat Engine is showing 365243F987. Is anyone able to understand what's going wrong here?
Here's my code with some added notes:
Code:

-- Cheat Engine Shows pFoes to be DE4717F0
-- http://forum.cheatengine.org/viewtopic.php?p=5734498#5734498
function AOBScanRegion( SYMBOL, AOB, START, END)
  -- temporary symbol name to register (should be unique of course)
  local aobscanregionSymbol = 'aobscanregionSymbol'
  local CODE = [[aobscanregion(%s, %s, %s, %s)
  unregisterSymbol(%s)
  registerSymbol(%s)]]

  if type(START) == 'number' then
     START = ('%X'):format(START) end
  if type(END) == 'number' then
     END = ('%X'):format(END) end

  CODE = CODE:format( SYMBOL,
       START, END, AOB, SYMBOL, SYMBOL )

  local result = autoAssemble(CODE)
  if not result then return nil end

  return getAddress( SYMBOL )
end
-- ...
function zAddr( original, addsub, offset )
         return '' .. (original or 0) .. addsub .. offset
end
-- ...
local pFoes = AOBScanRegion(
      'pFoes',
      "A0 A0 00 00 A1 2F", "D0000000", "DFFFFFFF" )
-- ...
local xFoeRdCap = zAddr( pFoes, '-', 'D6DC17AF' )


Note: Gonna go to Subway for breakfast while I wait so don't expect a quick reply

Edit: Found a way to fix it:
Code:

-- Added these lines
local zFormat = string.format
function zNum2Hex( num )
         if type(num) == 'number' then
            num = zFormat( '%X', num ) end
         return num
end
-- And changed zAddr to this:
function zAddr( base, addsub, offset )
         base = zNum2Hex( base or 0 )
         offset = zNum2Hex( offset or 0 )
         return '' .. base .. addsub .. offset
end

_________________
Those who do not trust in christ to save them from their sins will only experience hell when their soul is released from it's earthly vessel.
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