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 


"Else"-part does not get injected with setState

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

Joined: 05 Jan 2016
Posts: 61
Location: Germany

PostPosted: Fri Jun 24, 2016 12:05 pm    Post subject: "Else"-part does not get injected with setState Reply with quote

When I deactivate a checkbox by clicking on a button with the function
Code:
UDF1.CECheckbox1.setState(0)

, the disabled-part of the checkbox does not get injected (but the checkbox gets disabled).
This is the function of the checkbox (the event is under OnChange):
Code:
if (checkbox_getState(UDF1.CECheckbox1) == 1) then
  autoAssemble([[
    (...)
    ]])
  else
  autoAssemble([[
    timetillman:
    db D9 5F 58 D9 47 58
    unregistersymbol(timetillman)
    ]])
end

The enable and disable code of the checkbox works fine.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4297

PostPosted: Fri Jun 24, 2016 12:31 pm    Post subject: Reply with quote

Don't use class_method functions unless they're documented in main.lua. The only reason why most exist is for backwards compatibility.

Use the actual name for checkbox states as defined in defines.lua. It makes your code more readable.

It seems like checkbox.setState does not invoke the OnChange event. I'm not sure if this is a bug or a feature, but you can use the Checked property instead.

_________________
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
TPRammus
Advanced Cheater
Reputation: 0

Joined: 05 Jan 2016
Posts: 61
Location: Germany

PostPosted: Fri Jun 24, 2016 4:58 pm    Post subject: Reply with quote

ParkourPenguin wrote:
(...), but you can use the Checked property instead.

I searched for the Checked property now and tried to use it but it doesn't work because of
Code:
:120: attempt to call a boolean value (field 'Checked')

main.lua wrote:
CheckBox Class: (...)
properties
Checked: boolean - True if checked

This is my code (tried all of those):
Code:
UDF1.CECheckbox1.Checked("false")
UDF1.CECheckbox1.Checked("False")
UDF1.CECheckbox1.Checked(false)
UDF1.CECheckbox1.Checked(False)
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4297

PostPosted: Fri Jun 24, 2016 5:02 pm    Post subject: Reply with quote

Checked is a property, not a method.
Code:
UDF1.CECheckbox1.Checked = false

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