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 


EditBox syntax

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

Joined: 08 Oct 2012
Posts: 577

PostPosted: Sun Dec 04, 2016 9:52 am    Post subject: EditBox syntax Reply with quote

I have this code in my table.
Code:

   self.set_exp1_value = createButton(self.form);
   self.set_exp1_value.Caption = 'Enter Hero 1 Exp';
   self.set_exp1_value.height = 35;
   self.set_exp1_value.left = 104;
   self.set_exp1_value.top = 7;
   self.set_exp1_value.width = 150;
   self.set_exp1_value.onClick =    function (sender)
                                     local value = self.exp1_value.Text;
                                      if value then
                                        exp1_value = tonumber(value);
                                        print("The experience of the 1st member entered is " .. exp1_value);
                                      if exp1_value and exp2_value then
                                        RecalculateAddresses()
                                      end
                                      end
                                   end

   self.set_exp2_value = createButton(self.form);
   self.set_exp2_value.Caption = 'Enter Hero 2 Exp';
   self.set_exp2_value.height = 35;
   self.set_exp2_value.left = 104;
   self.set_exp2_value.top = 52;
   self.set_exp2_value.width = 150;
   self.set_exp2_value.onClick =    function (sender)
                                     local value = self.exp2_value.Text;
                                      if value then
                                        exp2_value = tonumber(value);
                                        print("The experience of the 2nd member entered is " .. exp2_value);
                                      if exp1_value and exp2_value then
                                        RecalculateAddresses()
                                      end
                                      end
                                   end


And then further down the code in sub RecalculateAddresses()

Code:

   trainer.set_exp1_value.Text = ""
   trainer.set_exp2_value.Text = ""


Now the edit boxes work and the sub is called and executes. The only procedures that aren't executed are the last two lines listed above.
What is the correct syntax for any of the lines?
Back to top
View user's profile Send private message Yahoo Messenger
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sun Dec 04, 2016 10:13 am    Post subject: Reply with quote

After quick reading of your code I see that
set_exp1_value is a button
set_exp2_value is a button
exp1_value is an editbox
exp2_value is an editbox


So you should use
Code:
   trainer.exp1_value.Text = ""
   trainer.exp2_value.Text = ""





I suggest using better names in the future. Something like:
btnSetExp1 for a button
editboxExp1 for an editbox

_________________
Back to top
View user's profile Send private message MSN Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Sun Dec 04, 2016 10:24 am    Post subject: Reply with quote

mgr.inz.Player wrote:
After quick reading of your code I see that
set_exp1_value is a button
set_exp2_value is a button
exp1_value is an editbox
exp2_value is an editbox


Not really The button is beside the edit box and is used to captured the value from the edit box.
Quote:

...

I suggest using better names in the future. Something like:
btnSetExp1 for a button
editboxExp1 for an editbox


Sounds good I'll put that on the bucket list.
Back to top
View user's profile Send private message Yahoo Messenger
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sun Dec 04, 2016 10:29 am    Post subject: Reply with quote

bknight2602 wrote:
Not really The button is beside the edit box and is used to captured the value from the edit box.

Read my post again. Carefully.




Straight from your code:
Code:
self.set_exp1_value = createButton(self.form);

So, set_exp1_value is a button.

Code:
local value = self.exp1_value.Text

So, exp1_value is an editbox.

_________________
Back to top
View user's profile Send private message MSN Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Sun Dec 04, 2016 10:46 am    Post subject: Reply with quote

Maybe the naming is the issue, more towards the beginning.
Code:

   self.exp_value_1st = createEdit(self.value_panel1);
   self.exp_value_1st.top = 6;
   self.exp_value_1st.left = 6;
   self.exp_value_1st.Width = 80;
   self.exp_value_1st.Height = 23;
-- The line below this, allows only numbers or the - number to be entered.
   setMethodProperty(self.exp_value_1st, "OnKeyPress", function (sender, key) local keynr = string.byte(key); if (keynr~=8) and (keynr~=45) and (keynr~=13) and ((keynr<48) or (keynr>57)) then key=nil; end if (keynr==13 and not(sender.Caption == nil or sender.Caption == '')) then key = nil; self.set_exp_value_1st.onClick(); end return key; end)
--
   self.exp_value_2nd = createEdit(self.value_panel2);
   self.exp_value_2nd.top = 6;
   self.exp_value_2nd.left = 6;
   self.exp_value_2nd.Width = 80;
   self.exp_value_2nd.Height = 23;
   -- The line below this, allows only numbers or the - number to be entered.
   setMethodProperty(self.exp_value_2nd, "OnKeyPress", function (sender, key) local keynr = string.byte(key); if (keynr~=8) and (keynr~=45) and (keynr~=13) and ((keynr<48) or (keynr>57)) then key=nil; end if (keynr==13 and not(sender.Caption == nil or sender.Caption == '')) then key = nil; self.set_exp_value_2nd.onClick(); end return key; end)

These were intended to be the names, however IIRC (maybe over two years ago) I had to use local value = self.exp1_value.Text; to allow the recalculation to be executed.
Back to top
View user's profile Send private message Yahoo Messenger
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sun Dec 04, 2016 11:09 am    Post subject: Reply with quote

I recommend starting from the scratch. With proper form controls naming. And proper variable naming.
Also, I recommend using "form designer".

_________________
Back to top
View user's profile Send private message MSN Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Mon Dec 05, 2016 4:13 pm    Post subject: Reply with quote

mgr.inz.Player wrote:
I recommend starting from the scratch. With proper form controls naming. And proper variable naming.
Also, I recommend using "form designer".


That's a tall order. Where do I locate the "form designer"?
Back to top
View user's profile Send private message Yahoo Messenger
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Mon Dec 05, 2016 4:42 pm    Post subject: Reply with quote

http://forum.cheatengine.org/viewtopic.php?t=579440
_________________
Back to top
View user's profile Send private message MSN Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Mon Dec 05, 2016 5:11 pm    Post subject: Reply with quote

Old style coding which you guys have been coaxing me out of. I'm not sure this is the correct forward path for me, but thank for the reply.
Back to top
View user's profile Send private message Yahoo 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