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 


"global" define for all scripts in CE table

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
FauDrei
Advanced Cheater
Reputation: 4

Joined: 20 Nov 2013
Posts: 63
Location: rajvoSa

PostPosted: Wed Sep 13, 2017 4:48 am    Post subject: "global" define for all scripts in CE table Reply with quote

Regards.

Is there a way to create within CE table a script/file with defines/code that will be available to all the scripts within the same CE table?

AA's include(defines_file.CEA) line in all the scripts method works, but it requires additional CEA file to be present in the same directory as the main CT file, and I would like to avoid having two or more separate files per one CE table.

Thanks.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 341

Joined: 09 May 2003
Posts: 19984
Location: The netherlands

PostPosted: Wed Sep 13, 2017 5:33 am    Post subject: Reply with quote

easiest is just put the defines_file in the first entry of your table which once checked shows all other cheats

else try a lua block and a lua script in the main code of your table

main table lua code:
Code:

definesloaded=false
function registerDefines()
  if definesloaded==false then
   definesloaded=autoAssemble([[
 //your code
]])
  end
end


and in your cheat entries with aa script then have as first code:
Code:

{$lua}
registerDefines()
{$asm}

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Back to top
View user's profile Send private message MSN Messenger
FauDrei
Advanced Cheater
Reputation: 4

Joined: 20 Nov 2013
Posts: 63
Location: rajvoSa

PostPosted: Wed Sep 13, 2017 7:32 am    Post subject: Reply with quote

Dark Byte wrote:
easiest is just put the defines_file in the first entry of your table which once checked shows all other cheats...

Thanks Dark Byte, but I am not sure I understand this...

I do have 1st "main" script that allows activation of other scripts, but if I put defines there and activate this "main" script - other scripts still do not "see" those defines and would not activate.

Is there something I am missing? I have also tried adding defines.CEA file to my CE table (Table > Add file) and using include(defines.CEA) in table scripts, but include does not see defines.CEA attached to the table.
Back to top
View user's profile Send private message
FreeER
Master Cheater
Reputation: 10

Joined: 09 Aug 2013
Posts: 306

PostPosted: Wed Sep 13, 2017 6:35 pm    Post subject: Reply with quote

make sure you use registersymbol for anything you want accessible to other scripts, the autoAssemble will make sure it exists but it's not much different from just adding it to the table and manually enabling it before anything else.

If it's just a bunch of defines, for idk offsets because you haven't setup a structure, not aobscans/allocs/code then you might want something like
Code:
-- have defines in 1 place
function getDefines()
  return [[
   //your code
  ]]
end


Code:
{$lua}
return registerDefines() -- returned string used as AA code in this location
{$asm}
Back to top
View user's profile Send private message
FauDrei
Advanced Cheater
Reputation: 4

Joined: 20 Nov 2013
Posts: 63
Location: rajvoSa

PostPosted: Thu Sep 14, 2017 2:19 am    Post subject: Reply with quote

So, if I understood correctly, beside lua or registersymbol for each define, there is no elegant AA way to have global defines in each (sub)script.

OK.

FreeER wrote:
...because you haven't setup a structure...

How do you setup/register a structure?

...or even better (more useful): is there a way and how do you use in AA structures defined in Structure dissect window?

For example... If I have structure like this:



...and have the Unit structure address in RCX... How do I access Unit.state.hp?

Thanks for help.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 341

Joined: 09 May 2003
Posts: 19984
Location: The netherlands

PostPosted: Thu Sep 14, 2017 2:57 am    Post subject: This post has 1 review(s) Reply with quote

registersymbol IS a global

also, if you have setup a structure, you can reference offsets in it using structurename.elementname

so in your case, assuming you also have defined state as a separate structure
Code:

push rax
mov rax,[rcx+Unit.state]
mov [rax+State.hp],(float)1
pop rax

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Back to top
View user's profile Send private message MSN Messenger
FauDrei
Advanced Cheater
Reputation: 4

Joined: 20 Nov 2013
Posts: 63
Location: rajvoSa

PostPosted: Thu Sep 14, 2017 3:02 am    Post subject: Reply with quote

This is great. Very Happy

Thanks.
Back to top
View user's profile Send private message
panraven
Grandmaster Cheater
Reputation: 26

Joined: 01 Oct 2008
Posts: 659

PostPosted: Thu Sep 14, 2017 5:16 am    Post subject: Reply with quote

If it is for field usage of mono class, may try this script, need ce 6.7.
The chain of fields should only work for class not structure.
There is unknown bug which somehow disappeared when I comment out some extra script, not sure it is bug free.

Code:

local function findClass(class)
  if type(class)=='string' then
    local n,c = '',class
    if class:find":" then n,c = class:match"^(.-):(.*)"end
    class =  mono_findClass(n,c)
  end
  return class
end

local function field2class(f)
  if f.monotype == MONO_TYPE_CLASS then
    return mono_type_getClass(f.field)
  end
end
local function class2field(class)
  local fs,field = mono_class_enumFields(findClass(class)),{}
  for i=1,#fs do
    local fi = fs[i]
    field[fi.name] = fi
  end
  return field
end

local autofield
autofield= {
  __len = function(me)return rawget(me,me).offset end,
  __bnot = function(me)return rawget(me,me).offset end,
  __index = function(self,k)
    me = rawget(self,self)
    if me.class and not me.field then
      me.class = findClass(me.class)
      me.field = class2field(me.class)
    end
    local f = me.field[k]
    if not f then return end
    local out = {offset = f.offset, class = field2class(f) }
    if out.class then
      out.field = class2field(out.class)
    end
    local this = {}
    this[this] = out
    return setmetatable(this,autofield)
end}

function monoAutoField(class)
  if LaunchMonoDataCollector()==0 then return end
  local self = {}
  self[self] = {class=class}
  return setmetatable(self,autofield)
end


usage:
make a global lua variable for the target class like:
Code:

--sample game, Practical Flee
UM = monoAutoField"UnitManager"

then in AA, it can be use as:
Code:

mov  esi,[edi+$#UM.latheWeapon]   //  edi is base of class UnitManager
mov  ebx,[esi+$#UM.latheWeapon.ammo] // esi is base of field latheWeapon, which is of class LatheWeapon

In memory record, it can be set as pointer address
offset 0: #UM.latheWeapon.ammo
offset 1: #UM.latheWeapon
base: some_base
(ie, no $)

'#'(length) can be replace with '~' (bitwise not), they are necessary to duel behavior of the field chain both as meta table and number.

bye~

_________________
- Retarded.
dropbox
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 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