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 


Invalid class object error

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
omax
Newbie cheater
Reputation: 0

Joined: 29 May 2014
Posts: 14
Location: Jupiter

PostPosted: Wed Sep 10, 2014 5:03 am    Post subject: Invalid class object error Reply with quote

Hi,
I'm trying to make a trainer but every time I try to check the status of my check box using checkbox_getStatus() I get an error in the console stating: Invalid class object.
here's the code:
Code:
function no_railgun_inaccuracyChange(sender)
  local no_railgun_inaccuracy_mr=addresslist_getMemoryRecordByDescription(getAddressList(),"No loss of aiming accuracy after a railgun shot")
  if checkbox_getState(no_railgun_inaccuracy) == 1 then
     memoryrecord_freeze(no_railgun_inaccuracy_mr)
  else
     memoryrecord_unfreeze(no_railgun_inaccuracy_mr)
  end
end

I've also tried using "if checkbox_getState(no_railgun_inaccuracy) == cbChecked then" and "if checkbox_getState(no_railgun_inaccuracy, 1) then"
but I keep on getting the same error every time
is there a problem in the compiler or am I doing something wrong
thanks for the help
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Wed Sep 10, 2014 5:49 am    Post subject: Reply with quote

memoryrecords are no checkbox classes, so don't use checkbox_ methods on them
Instead, check the Active property of the memoryrecord

e,.g something like:
Code:

function no_railgun_inaccuracyChange(sender)
  local no_railgun_inaccuracy_mr=getAddressList().getMemoryRecordByDescription("No loss of aiming accuracy after a railgun shot")
  if no_railgun_inaccuracy_mr.Active then
    no_railgun_inaccuracy_mr.Active=false --freeze
  else
    no_railgun_inaccuracy_mr.Active=true --unfreeze

  --alternatively instead of the if and these 3 other lines do
  --no_railgun_inaccuracy_mr.Active=not no_railgun_inaccuracy_mr.Active
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
omax
Newbie cheater
Reputation: 0

Joined: 29 May 2014
Posts: 14
Location: Jupiter

PostPosted: Wed Sep 10, 2014 7:10 am    Post subject: Reply with quote

thanks for your reply Dark Byte.
i was not trying using my memory record as a check box, i have one in my trainer named "no_railgun_inaccuracy" and the memory record i was trying to freeze/unfreeze was "no_railgun_inaccuracy_mr". your method worked perfectly fine for me, thanks, but i wanted use checkbox_getState(no_railgun_inaccuracy), in my if condition, to check my check box's(which is in my trainer, not the memory recored) status, however i get that Invalid class object error every time i try to use "if checkbox_getState(no_railgun_inaccuracy) == 1 then"", so my question basicly is if this class itself is buggy or am i using it wrongly.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Wed Sep 10, 2014 10:21 am    Post subject: Reply with quote

Instead of no_railgun_inaccuracy give sender and see if that works

Also, it's most likely you haven't defined a global variable named no_railgun_inaccuracy and assigned it the checkbox object, so i suggest getting the checkbox from the form it is on
E.g myformname.no_railgun_inaccuracy

_________________
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
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