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 


simple script to disable table memory record check box

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

Joined: 22 Jan 2010
Posts: 7

PostPosted: Mon Feb 07, 2022 6:06 pm    Post subject: simple script to disable table memory record check box Reply with quote

I'm using a basic script, cheat table framework code with just enable and disable, each followed by addresses and db to inject code.

I would like one of the checkboxes to uncheck another checkbox (and vice versa), but I'm either using the wrong type of script, or I'm not getting the syntax correct. I don' t know how to identify a checkbox (the number), but there are only 8, so I can find it by trial and error:

I'm trying to do something like this:

[enable]
abcdef:
db 01 23
CETrainer.CECheckBox3=false

[disable]
abcdef:
db 45 67


Last edited by rcgldr on Tue Feb 08, 2022 5:36 am; edited 1 time in total
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1525

PostPosted: Mon Feb 07, 2022 8:21 pm    Post subject: Reply with quote

Code:
[ENABLE]
abcdef:
db 01 23

{$lua}
CETrainer.CECheckBox3=false
{$asm}

[DISABLE]
abcdef:
db 45 67

{$lua}
CETrainer.CECheckBox3=true

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
rcgldr
How do I cheat?
Reputation: 0

Joined: 22 Jan 2010
Posts: 7

PostPosted: Mon Feb 07, 2022 9:30 pm    Post subject: Reply with quote

AylinCE wrote:

[ENABLE]
{$lua}
CETrainer.CECheckBox3=false
{$asm}


I get an error: "Attempt to index a nill value (global CETrainer)"
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1525

PostPosted: Tue Feb 08, 2022 12:48 am    Post subject: Reply with quote

1) Probably Trainer name is not "CETrainer" but what?
UDF1 ?
Trainer Generator "CETrainer" ?
The second option is;
You must open the trainer in form editing at least once.

1) Click Trainer Genarator >> Click > Go back to generated designer.
2) Close Trainer designer.
3) CE >> Main menu >> Table >> (Click) CETrainer >> Edit
4) Now look over there, if there is no "Checkbox" on the form, put one there.
5) Close the designer and run the following code in the address list.

Code:
[ENABLE]
//abcdef:
//db 01 23
{$lua}
if syntaxcheck then return end
CETrainer.CECheckbox3.checked=false
{$asm}

[DISABLE]
//abcdef:
//db 45 67

{$lua}
CETrainer.CECheckbox3.checked=true


CETrainer.CECheckbox1 ? 3 ?

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
rcgldr
How do I cheat?
Reputation: 0

Joined: 22 Jan 2010
Posts: 7

PostPosted: Tue Feb 08, 2022 5:09 am    Post subject: Reply with quote

AylinCE wrote:
1) Probably Trainer name is not "CETrainer" but what?
UDF1 ?

I'm not creating a trainer, just creating a .CT file with scripts that is loaded and run from the main Cheat Engine table window. What is the syntax | names for the items you add to the main table?

Note - each script does the "other" scripts disable before doing its own enable, so unmarking the "other" check box is just for the visual. What I'm trying to do visually is clear a table memory record check box. I updated the thread title to make this clear. I didn't know it was called memory record when I started this thread.

Sorry for the confusing title. This was the first time I tried this. I got it to work using this change to my scripts:

Code:

enable:
{$lua}
local al = getAddressList()
local mr = al.getMemoryRecordByDescription('other')
mr.Active = False
{$asm}
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1069
Location: 0x90

PostPosted: Tue Feb 08, 2022 6:22 am    Post subject: Reply with quote

rcgldr wrote:

I'm not creating a trainer, just creating a .CT file with scripts that is loaded and run from the main Cheat Engine table window. What is the syntax | names for the items you add to the main table?

Note - each script does the "other" scripts disable before doing its own enable, so unmarking the "other" check box is just for the visual. What I'm trying to do visually is clear a table memory record check box. I updated the thread title to make this clear. I didn't know it was called memory record when I started this thread.

Sorry for the confusing title. This was the first time I tried this. I got it to work using this change to my scripts:

Code:

enable:
{$lua}
local al = getAddressList()
local mr = al.getMemoryRecordByDescription('other')
mr.Active = False
{$asm}


You can also use a function like this to toggle the script within the cheat table:
Code:

function getMemRec(desc)
  local al = getAddressList()
  local mr = al.getMemoryRecordByDescription(desc)
 
  -- Check if the entry exists
  if mr ~= nil then
    return mr
  else
    return nil
end

function toggle(desc)
  local m = getMemRec(desc)
  m.active = not m.active
end

-- Usage:
[ENABLE]
{$LUA}
toggle('description of entry')
{$ASM}

[DISABLE]
{$LUA}
toggle('description of entry')


I realise that you have found the solution, I just thought I would point out another method to how this can be achieved.
Back to top
View user's profile Send private message
rcgldr
How do I cheat?
Reputation: 0

Joined: 22 Jan 2010
Posts: 7

PostPosted: Tue Feb 08, 2022 8:11 am    Post subject: Reply with quote

LeFiXER wrote:
I realise that you have found the solution, I just thought I would point out another method to how this can be achieved.
In this case, I'm trying to emulate a pair of radio buttons. When one is activated, the other is deactivated (no need to check it if was active or not before deactivating it).

I don' t know if deactivating a memory record triggers its disable script, but it doesn't matter. The sequence for each memory record activation is to set the other memory record active state to false (to clear the check box), then in the script, do the other script disable, then do the current script enable.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4704

PostPosted: Tue Feb 08, 2022 11:41 am    Post subject: Reply with quote

The simplest way is pretty much this:
Code:
// script1
[ENABLE]
{$lua}
if syntaxcheck then return end
local mr = AddressList.getMemoryRecordByDescription'script2'
if mr.Active then
  mr.Active = false
end
{$asm}
[DISABLE]
Code:
// script2
[ENABLE]
{$lua}
if syntaxcheck then return end
local mr = AddressList.getMemoryRecordByDescription'script1'
if mr.Active then
  mr.Active = false
end
{$asm}
[DISABLE]
Setting a memory record's Active state to false will run the [DISABLE] section for scripts.
I'm not sure if CE's AA is reentrant in general, but this seems to work in simple cases.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
rcgldr
How do I cheat?
Reputation: 0

Joined: 22 Jan 2010
Posts: 7

PostPosted: Tue Feb 08, 2022 5:19 pm    Post subject: Reply with quote

ParkourPenguin wrote:
Setting a memory record's Active state to false will run the [DISABLE] section for scripts.
I updated my script to include the if then end stuff, which may not be needed now, but it's there as a reference for me if I make another cheat table. Thanks for the 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