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 


Strange behavior of $lua block inside a script's [DISABLE]

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
chase0
How do I cheat?
Reputation: 0

Joined: 06 Oct 2016
Posts: 6

PostPosted: Thu Oct 06, 2016 12:42 pm    Post subject: Strange behavior of $lua block inside a script's [DISABLE] Reply with quote

I'm doing some cleanup in the DISABLE section of a script, restoring original values. The resulting script works as expected, however there's an issue during authoring: when saving the script into the table, CE shows a warning message box ("Not all code is injectable. (Failure determining what L means)").

Here's the simplified script:
Code:

[ENABLE]
alloc(M,1024)
label(L)
registersymbol(L)
L:

[DISABLE]
{$lua}
getAddress("L")
{$asm}
unregistersymbol(L)
dealloc(M,1024)


If I were to change the LUA code to, say:
Code:

if (false) then
  getAddress("L")
end


The script saves fine, with no warnings, so it seems that CE is trying to _execute_ LUA code in the DISABLE section on saving instead of just parsing it. As I said before, the _original_ script works properly once saved, as by the time DISABLE section actually gets control the symbol is registered by the ENABLE section.

I thus have two questions:
1. Why is this happening to me?
2. How can I work around this?

Random thoughts:
* Ignoring the warning doesn't do it for me, as it may complicate finding actual errors in the script.
* getSymbolInfo() apparently returns nil for user-defined symbols, so it doesn't help here.
* I don't like clutter, so I don't want to have symbols permanently registered.
* errorOnLookupFailure() sort of helps, but it seems to be per-process, so I'd rather not, also it still doesn't solve the issue of the code getting executed on save.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Thu Oct 06, 2016 1:13 pm    Post subject: Reply with quote

when you click ok it runs the script to check for errors. (and some scripts generate important code required for the resg of the script)
you can use syntaxcheck to see if it should act or not

add this line as first line of each lua section
Code:
 
if syntaxcheck then return end

_________________
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
chase0
How do I cheat?
Reputation: 0

Joined: 06 Oct 2016
Posts: 6

PostPosted: Thu Oct 06, 2016 1:52 pm    Post subject: Reply with quote

Ah, that explains it, and I was hoping for something like this. Thanks.

As a side note: CE's feature set is superb, feature discoverability — not so much. Sorry, had to say it.
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