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 


CheckBox syntax

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
bknight2602
Master Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 366

PostPosted: Mon Mar 27, 2017 4:01 pm    Post subject: CheckBox syntax Reply with quote

I'm getting an invalid Class object using an old syntax.
Code:
tSave = createTimer(nil, true)
timer_onTimer(tSave, SaveAnywhere)
timer_setInterval(tSave, 500)
timer_setEnabled(tSave, false)

So what is the new current syntax?
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 345

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

PostPosted: Mon Mar 27, 2017 4:07 pm    Post subject: Reply with quote

That code works just fine, I recommend checking SaveAnywhere

Anyhow, the current syntax would be:
Code:

tSave = createTimer(nil, true)
tSave.OnTimer=SaveAnywhere
tSave.Interval=500
tSave.Enabled=false

_________________
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
bknight2602
Master Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 366

PostPosted: Mon Mar 27, 2017 4:11 pm    Post subject: Reply with quote

Will a function result in an invalid Class object?
Thanks

EDIT: Can a function result in an invalid class object?
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 345

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

PostPosted: Mon Mar 27, 2017 5:58 pm    Post subject: Reply with quote

If the function does something with the deprecated function call method and gives the wrong kind of object, then yes, it's possible that it will trigger such a message
_________________
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
bknight2602
Master Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 366

PostPosted: Mon Mar 27, 2017 9:42 pm    Post subject: Reply with quote

What in the world is a deprecated function call method?
I had a print statement as the first line and it never printed just the error message, that is why I thought it was the timer syntax.
Well I re-did a checkbox function and eliminated the timer altogether, works without errors now.
Back to top
View user's profile Send private message Yahoo Messenger
Zanzer
I post too much
Reputation: 121

Joined: 09 Jun 2013
Posts: 3279

PostPosted: Tue Mar 28, 2017 5:39 pm    Post subject: Reply with quote

Code:
timer_setInterval({}, 1)
Back to top
View user's profile Send private message
bknight2602
Master Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 366

PostPosted: Tue Mar 28, 2017 8:00 pm    Post subject: Reply with quote

Zanzer wrote:
Code:
timer_setInterval({}, 1)


OK, but it was set to 500, not 1
Back to top
View user's profile Send private message Yahoo Messenger
Zanzer
I post too much
Reputation: 121

Joined: 09 Jun 2013
Posts: 3279

PostPosted: Tue Mar 28, 2017 8:57 pm    Post subject: Reply with quote

Doesn't matter what the number is. When you pass in the wrong object, like the table {}, it throws that error.
Back to top
View user's profile Send private message
bknight2602
Master Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 366

PostPosted: Tue Mar 28, 2017 9:12 pm    Post subject: Reply with quote

Ok, Now I understand what you meant, thanks.
Back to top
View user's profile Send private message Yahoo Messenger
bknight2602
Master Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 366

PostPosted: Mon Apr 03, 2017 6:00 pm    Post subject: Reply with quote

I thought I had this working but...
Code:
   self.tp = createTimer(nil, false)
   self.tp.onTimer = ConstProtection
   self.tp.Interval = 1000;
   self.cp_cb = createCheckBox(self.form);
   self.cp_cb.Caption = 'Const Protection';
   self.cp_cb.Height = 20;
   self.cp_cb.Left = 260;
   self.cp_cb.Width = 75;
   self.cp_cb.Top = 245;
   self.cp_cb.onClick = function(sender)
                        al = getAddressList();
                           if sender.Checked then
                              self.tp.Enabled = true;
                              print("Constant Protection is enabled");
                              al = getAddressList();
                                 constantarmorplate = readBytes(memoryrecord_getAddress(addresslist_getMemoryRecordByDescription(al, "Armorplate")), 2);
                                 constantchamelon = readBytes(memoryrecord_getAddress(addresslist_getMemoryRecordByDescription(al, "Chameleon")), 2);
                                 constantdetect = readBytes(memoryrecord_getAddress(addresslist_getMemoryRecordByDescription(al, "Detect Secret")), 2);
                                 constantblade = readBytes(memoryrecord_getAddress(addresslist_getMemoryRecordByDescription(al, "Enchanted Blade")), 2);
                                 constantlight = readBytes(memoryrecord_getAddress(addresslist_getMemoryRecordByDescription(al, "Light")), 2);
                                 constantscreen = readBytes(memoryrecord_getAddress(addresslist_getMemoryRecordByDescription(al, "Magic Screen")), 2);
                                 constantshield = readBytes(memoryrecord_getAddress(addresslist_getMemoryRecordByDescription(al, "Missle Shield")), 2);
                                 constanthound = readBytes(memoryrecord_getAddress(addresslist_getMemoryRecordByDescription(al, "Shadow Hound")), 2);
                                 constantxray = readBytes(memoryrecord_getAddress(addresslist_getMemoryRecordByDescription(al, "X-Ray")), 2);
                              print("Constant Protection is enabled");
                           else
                              self.tp.Enabled = false;
                              print("Constant Protection is not enabled");
                           end;
                        end;

function ConstProtection(sender)
   al = getAddressList();
   print("writing")
   writeBytes(memoryrecord_getAddress(addresslist_getMemoryRecordByDescription(al, "Armorplate")), constantarmorplate);
   writeBytes(memoryrecord_getAddress(addresslist_getMemoryRecordByDescription(al, "Chameleon")), constantchamelon);
   writeBytes(memoryrecord_getAddress(addresslist_getMemoryRecordByDescription(al, "Detect Secret")), constantdetect);
   writeBytes(memoryrecord_getAddress(addresslist_getMemoryRecordByDescription(al, "Enchanted Blade")), constantblade);
   writeBytes(memoryrecord_getAddress(addresslist_getMemoryRecordByDescription(al, "Light")), constantlight);
   writeBytes(memoryrecord_getAddress(addresslist_getMemoryRecordByDescription(al, "Magic Screen")), constantscreen);
   writeBytes(memoryrecord_getAddress(addresslist_getMemoryRecordByDescription(al, "Missle Shield")), constantshield);
   writeBytes(memoryrecord_getAddress(addresslist_getMemoryRecordByDescription(al, "Shadow Hound")), constanthound);
   writeBytes(memoryrecord_getAddress(addresslist_getMemoryRecordByDescription(al, "X-Ray")), constantxray);
end;

What is wrong with the code as it isn't working?
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 345

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

PostPosted: Mon Apr 03, 2017 6:14 pm    Post subject: Reply with quote

at the time self.tp.onTimer = ConstProtection is executed, ConstProtection is nil

to fix this, move the function declaration of function ConstProtection to before that code

Also, unrelated, and assuming the value type is 2 bytes, you can do: al.getMemoryRecordByDescription('Armorplate').Value=constantarmorplate

_________________
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
bknight2602
Master Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 366

PostPosted: Tue Apr 04, 2017 9:54 am    Post subject: Reply with quote

Ok, moved them, but it seems to me that I had that similar issues and had built the code in the sequence I had i.e.
timer
function
And that seemed to work until the previous thread post, but thanks I'll try to remember what you posted.
Yes those bytes are 2 byte numbers and I'll retype the value setting.
Back to top
View user's profile Send private message Yahoo Messenger
Zanzer
I post too much
Reputation: 121

Joined: 09 Jun 2013
Posts: 3279

PostPosted: Tue Apr 04, 2017 7:51 pm    Post subject: Reply with quote

While developing the script, you're constantly hitting the execute script button.
So the previously defined function was being loaded into the timer on the second execution.
It just gave the appearance that it was actually working correctly.
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