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 


Incorrect syntax for Edit/Panel Caption

 
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 Sep 18, 2016 10:19 am    Post subject: Incorrect syntax for Edit/Panel Caption Reply with quote

I have a piece of code that works on one pc, but not another and I suspect there has been an update to the syntax since these were first coded. I have looked through the linked information, but have been unable to find the appropriate information. Would someone like to correct the syntax, please?
Code:
function trainer:start()
   self.form = createForm(false); -- self = trainer since it's a function inside of a table...
   setProperty(self.form , "BiDiMode", "bdLeftToRight");
   self.form.Caption = 'Cheat Panel';
   self.form.Width = 350;
   self.form.Height = 360;
   self.form.Left = 445;
   self.form.Top =7;
--
   self.value_panel1 = createPanel(self.form);
   self.value_panel1.Caption = '';
   self.value_panel1.left = 5;
   self.value_panel1.top = 7;
   self.value_panel1.Height = 35;
   self.value_panel1.Width = 70;
   self.value_panel2 = createPanel(self.form);
   self.value_panel2.Caption = '';
   self.value_panel2.left = 5;
   self.value_panel2.top = 52;
   self.value_panel2.Height = 35;
   self.value_panel2.Width = 70;
--
   self.exp_value = createEdit(self.value_panel1);
   self.exp_value.top = 6;
   self.exp_value.left = 6;
   self.exp_value.Width = 60;
   self.exp_value.Height = 23;
-- The line below this, allows only numbers or the - number to be entered.
   setMethodProperty(self.exp_value, "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.onClick(); end return key; end)
   self.gold_value = createEdit(self.value_panel2);
   self.gold_value.top = 6;
   self.gold_value.left = 6;
   self.gold_value.Width = 60;
   self.gold_value.Height = 23;
-- The line below this, allows only numbers or the - number to be entered.
   setMethodProperty(self.gold_value, "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.onClick(); end return key; end)
--
   self.set_exp = createButton(self.form);
   self.set_exp.Caption = 'Enter Exp';
   self.set_exp.height = 35;
   self.set_exp.left = 84;
   self.set_exp.top = 7;
   self.set_exp.width = 150;
   self.set_exp.onClick =    function (sender)
                               local value = tonumber(self.exp_value.Caption);
                                 if value then
                                   expvalue = value;
                                   byteoffset = nil;
--                                 print("The experience entered " .. expvalue);
                                   if expvalue and goldvalue and heroname then
                                    RecalculateAddresses()
                                   end--if expvalue and goldvalue and heroname then
                                 end--if value then
                               end--function (sender)
   self.set_gold = createButton(self.form);
   self.set_gold.Caption = 'Enter Gil';
   self.set_gold.height = 35;
   self.set_gold.left = 84;
   self.set_gold.top = 52;
   self.set_gold.width = 150;
   self.set_gold.onClick =    function (sender)
                                local value = tonumber(self.gold_value.Caption);
                                if value then
                                  goldvalue = value;
                                  byteoffset = nil;
--                                  print("The gold entered " .. goldvalue);
                                    if expvalue and goldvalue and heroname then
                                      RecalculateAddresses()
                                    end--if expvalue and goldvalue and heroname then
                                  end--if value then
                              end--function (sender)
--


The variable value never is not set by the code. I attempted to print an error statement and got no print out after the value was input into the
Code:
 local value = tonumber(self.exp_value.Caption);
print(value)
 if value then
Back to top
View user's profile Send private message Yahoo Messenger
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sun Sep 18, 2016 10:28 am    Post subject: Reply with quote

Edit boxes have a Text property, not Caption.
Back to top
View user's profile Send private message
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Sun Sep 18, 2016 10:41 am    Post subject: Reply with quote

Thanks Zanzer, that worked when changed. Do you have a link for the current syntax when creating objects? I looked at https://www.lua.org/pil/contents.html#P2
and didn't find spefics.
Back to top
View user's profile Send private message Yahoo Messenger
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sun Sep 18, 2016 11:27 am    Post subject: Reply with quote

All of that stuff is specific to CE.
Press F1; it's detailed in the help.
Can also view some things inside main.lua in the CE directory.
Or view some incomplete documentation on:
http://wiki.cheatengine.org/index.php?title=Lua
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