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 


decodeFunction() result can't call other decoded func?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
HenryEx
Expert Cheater
Reputation: 2

Joined: 18 Dec 2011
Posts: 100

PostPosted: Tue Jan 28, 2025 12:04 pm    Post subject: decodeFunction() result can't call other decoded func? Reply with quote

Trying to mess around with encodeFunction and decodeFunction, but i'm not having a lot of luck.

I wrote a lua function to update a mono-derived CE structure with new offsets and fields, without creating a new one and getting rid of all the changes you might have made to the existing one (pointers, local structs etc.).
This is meant to be a versatile all-purpose function.

Then i wrote a second, smaller function to automatically go over all CE structs, check if they correspond to a mono class, update them via the previous function and report on the results.

If i encode these two functions and then run this through lua:

Code:
local func1 = '[ENCODED FUNCTION 1 HERE]'
local updateStructFromMonoClass = decodeFunction(func1)

local func2 = '[ENCODED  FUNCTION 2 HERE]'
local updateAllMonoStructs = decodeFunction(func2)

updateAllMonoStructs()


It results in the following:
Code:
Error:?:-1: attempt to call a nil value (field 'updateStructFromMonoClass')
Script Error


Can a decoded function not call other decoded functions? That would be incredibly restrictive. Or maybe i'm just missing something obvious.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 468

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

PostPosted: Tue Jan 28, 2025 12:13 pm    Post subject: Reply with quote

remove local from updateStructFromMonoClass else the other script which is loaded in a different context can't see it
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
HenryEx
Expert Cheater
Reputation: 2

Joined: 18 Dec 2011
Posts: 100

PostPosted: Tue Jan 28, 2025 12:31 pm    Post subject: Reply with quote

I see. Not too familiar with context windows for LUA, since all i know about it is from CE and googling what i need to make tables.

I'm assuming this would make it a global function for however long that instance of Cheat Engine exists? Not that i would expect a lot of name collisions, but that would override any previously existing functions with the same name? (from autoruns for example)
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 468

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

PostPosted: Tue Jan 28, 2025 12:39 pm    Post subject: Reply with quote

yes.You can of course use a luatable unique to your project and put the functions in there


e.g:
Code:

myuniquelib={}
local func1 = '[ENCODED FUNCTION 1 HERE]'
myuniquelib.updateStructFromMonoClass = decodeFunction(func1)

local func2 = '[ENCODED  FUNCTION 2 HERE]'
myuniquelib.updateAllMonoStructs = decodeFunction(func2)

myuniquelib.updateAllMonoStructs()

of course adjust updateAllMonoStructs to call myuniquelib.updateStructFromMonoClass instead

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
HenryEx
Expert Cheater
Reputation: 2

Joined: 18 Dec 2011
Posts: 100

PostPosted: Wed Jan 29, 2025 2:07 pm    Post subject: Reply with quote

Thank you for the speedy help!
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