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 


group search lua script

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Discussions
View previous topic :: View next topic  
Author Message
panraven
Grandmaster Cheater
Reputation: 62

Joined: 01 Oct 2008
Posts: 958

PostPosted: Thu May 14, 2020 6:58 am    Post subject: Reply with quote

You may try this helper function
Code:

Struct2Aob = setmetatable({},{
  __index = function(me,Pat)
    local endian,pat
    pat = Pat:gsub('_',function()
      endian = endian~='>' and '>'or '<'
      return endian
    end)
    local ok,n,conv = pcall(string.packsize,pat)
    if ok and n>0 then -- n is fixed, pack pattern usable
      function conv(...)
        local r,s = {},string.pack(pat,...)
        for i=1,#s do r[i]=string.format('%02X',s:byte(i))end
        return table.concat(r,' ')
      end
      rawset(me,Pat,conv)-- memoized
    end
    return conv
  end
})
-- ref: string.pack https://www.lua.org/manual/5.3/manual.html#6.4.2
-- use '_' to toggle endian, with starting little endian

-- test
--1075970048 4:16842752 4:0 4:0 4:0 4:0 4:0
print(Struct2Aob.fi4i4i4i4i4i4(2.53125,16842752,0,0,0,0,0))
--10759700480 4:168427520 4:0 4:0 4:0 4:0 4:-1
print(Struct2Aob.fi4i4i4i4i4I4(25.3125,168427520,0,0,0,0,-1 & 0xffffffff))


Note that you first value should be float, otherwise x10 as integer will be
overflowed even you can convert, the number will not be your expected x10
after truncated to 4byte integer.

The string.pack function has a strict requirement to its input value domain,
for instance, 'i4' signed 4 bytes accept integer from -0x7fffffff to 0x7fffffff,
while 'I4' unsigned 4 bytes accept integer from 0 to 0xffffffff. Outside the
domain (range) will cause error.
In case overflow is acceptable, use the unsigned version and use ( ... & 0xffffffff ) to mask into a proper bytes count integer (like above -1).

More example, for 1st replace:
Code:

...
  searchV = '22 FD 8A 3F 08 AC AC 3F D7 A3 30 3F 52 B8 1E 3F 9A 99 99 3E 9A 99 99 3E'          -- use as it, exact pattern in game
  replaceV = Struct2Aob.f(1.299999952)..' 08 AC AC 3F D7 A3 30 3F 52 B8 1E 3F 9A 99 99 3E 9A 99 99 3E'  -- just modify 1st 4 bytes
  AOBRep(searchV,replaceV)
...

_________________
- Retarded.
Back to top
View user's profile Send private message
kentpachi2
How do I cheat?
Reputation: 0

Joined: 03 Feb 2020
Posts: 8

PostPosted: Thu May 14, 2020 10:20 pm    Post subject: Reply with quote

panraven wrote:
You may try this helper function

TY master popo
+Respect
+Mission passed
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Discussions 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