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 


Lua button for - add/delete new AA Alloc

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

Joined: 02 Nov 2018
Posts: 56

PostPosted: Tue Nov 27, 2018 11:49 am    Post subject: Lua button for - add/delete new AA Alloc Reply with quote

Hi there,

Is any way to add or delete new AA allocs like AA script made

Code:
alloc(New_Alloc_1,100)
registersymbol(New_Alloc_1)


but with using lua button. Everypressing will gave new alloc name, for found itt alloc in memory
For example everypress will change name like

New_Alloc_1
New_Alloc_2
New_Alloc_3
etc
?
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Tue Nov 27, 2018 5:42 pm    Post subject: Reply with quote

Code:
global_alloc_name_num=global_alloc_name_num or 0+1
print('New_Alloc_' .. global_alloc_name_num)
then click execute every time you want a new name... you can go further and print alloc( and register( stuff too and even have it put into an open AA script for you
Code:
global_alloc_name_num=global_alloc_name_num or 0+1
for i=0, getFormCount()-1 do
  local f = getForm(i)
  if f.className == 'TfrmAutoInject' and f.name:find('_') then
    local name = 'New_Alloc_' .. global_alloc_name_num
    global_alloc_name_num=global_alloc_name_num+1
    f.Assemblescreen.Lines.insert(1, ('registersymbol(%s)'):format(name))
    f.Assemblescreen.Lines.insert(1,('alloc(%s,100)'):format(name))
    f.Assemblescreen.Lines.add(('unregistersymbol(%s)'):format(name))
    f.Assemblescreen.Lines.add(('dealloc(%s)'):format(name))
    break
  end
end
fortunately in this case getForm seems to be ordered by last use so even if you have multiple AA scripts open it'll modify the last one you were working with.
Feel free to change the insert(1... to 0 or 2 or even loop over the lines to try and find [ENABLE] rather than assuming it's position, depending on needs.

There's probably a way to create an extension which adds a button but... I'm not certain what it'd be and don't have time to figure it out now.

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
Antoshick
Advanced Cheater
Reputation: 0

Joined: 02 Nov 2018
Posts: 56

PostPosted: Wed Nov 28, 2018 8:04 am    Post subject: Reply with quote

Is this way can be used in exe trainer?
If i want add/remove new AA allocs in finished trainer, and use it allocs for writing there and reading from there values.
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Wed Nov 28, 2018 8:15 am    Post subject: Reply with quote

um... I suppose if you have AA script editor forms open... It doesn't allocate the memory it just prints the name for you to use, or in the second case the text that would allocate it if it was run in an AA script/autoAssemble call, the second also finds an open AA script editor and inserts the lines into it rather than making you copy paste.
_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
Antoshick
Advanced Cheater
Reputation: 0

Joined: 02 Nov 2018
Posts: 56

PostPosted: Wed Nov 28, 2018 9:11 am    Post subject: Reply with quote

Yes, i tryed this your script while AA editor open, it work fine. And thank for it help.
But i searching a way for AA alloc creating in finished exe trainer.
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Wed Nov 28, 2018 1:58 pm    Post subject: Reply with quote

Well you can create AA scripts in lua at run time by creating a memory record on the AddresList and setting it's type to vtAutoAssembler then setting the Script property to the string of code or just calling autoAssemble with the script (though there's no editor to paste the generated name into you can just build it in to the script with format or string concatenation)...

But generally you don't need to. You just create whatever you might need in the table and then use it in the exe because it already exists. Or just use lua and variables to do the work, though lua does have allocateMemory/deAlloc (and registerSymbol) if you really needed it (AA doesn't really have full easy access to lua vars).

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
Antoshick
Advanced Cheater
Reputation: 0

Joined: 02 Nov 2018
Posts: 56

PostPosted: Wed Nov 28, 2018 11:02 pm    Post subject: Reply with quote

I using AA allocs in AA script, for record position. Lua timer (1milisecond) and Lua createthread cant record values so fast like it made AA script.
I can put to CE table 100 AA scripts (so many for possible using differents expositions) for creating AA allocs and it will be fine for me, but using AA creating from exe trainer will be some easy and batter.


Quote:
Well you can create AA scripts in lua at run time by creating a memory record on the AddresList and setting it's type to vtAutoAssembler then setting the Script property to the string of code or just calling autoAssemble with the script (though there's no editor to paste the generated name into you can just build it in to the script with format or string concatenation)..

Have you any example how create AA script in lua and activate it for apply Alloc?
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Thu Nov 29, 2018 8:58 am    Post subject: Reply with quote

Instead of 100 AA scripts why not just make one large variable, the first 4 bytes of which would be the number of values stored in it and can be used as an offset into the array for where to store new values?

I really don't understand why you need to create multiple names at runtime.

but
Code:
code from before to generate name
local scripttemplate = [=[
[ENABLE]
alloc(%s,100)
registersymbol(%s)
[DISABLE]
]=]
autoAssemble(scripttemplate:format(generated_name,generated_name))
or
Code:
local newmr=AddressList.createMemoryRecord()
newmr.type = vtAutoAssembler
newmr.script = code from before except assigned here instead of passed to autoAssemble
newmr.active = true

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
Antoshick
Advanced Cheater
Reputation: 0

Joined: 02 Nov 2018
Posts: 56

PostPosted: Thu Nov 29, 2018 12:04 pm    Post subject: Reply with quote

I saw some times ago how one guy use in his tool button for add new record tracks to some listbox, so this is why my first idea was creating AA allocs from button pressing. Before today i dont have this idea - one big alloc.

Both scripts for creating AA allocs work fine. Thank you a lot.
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