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 


Creating Label with code

 
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: 586

PostPosted: Sat Jul 26, 2025 8:27 am    Post subject: Creating Label with code Reply with quote

I have so far created a label on a form but I am having trouble with the Caption.
Code:

   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 = 800;
   self.form.Top =10;
   --
   self.Instructions = createLabel(self.form);
   self.Instructions.Width = 70;
   self.Instructions.Height = 50;
   self.Instructions.Left = 240;
   self.Instructions.Top = 7;
   self.Instructions.Caption = "Select Exp, Gold, and Hero to recalculate"
   --

The caption if too wide to fit in the space provided.
So how may I insert a carriage return in one or more places in the caption?
Back to top
View user's profile Send private message Yahoo Messenger
AylinCE
Grandmaster Cheater Supreme
Reputation: 36

Joined: 16 Feb 2017
Posts: 1511

PostPosted: Sat Jul 26, 2025 10:26 am    Post subject: Reply with quote

Try it in a separate lua tab.
Code:
self = {}

   self.form = createForm(); -- 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 = 800;
   self.form.Top =10;
   --
   self.Instructions = createLabel(self.form);
   self.Instructions.AutoSize=false
   self.Instructions.Width = 70;
   self.Instructions.Height = 50;
   self.Instructions.Left = 240;
   self.Instructions.Top = 7;
   self.Instructions.Caption = "Select Exp, Gold, and Hero to recalculate"
   -- self.Instructions.Tag = 100 -- > or 70
   self.Instructions.OptimalFill=true
   self.Instructions.WordWrap=true


result:
Select Exp, Gold,
and Hero to
recalculate

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 586

PostPosted: Sat Jul 26, 2025 10:34 am    Post subject: Reply with quote

Thanks works great.
Back to top
View user's profile Send private message Yahoo Messenger
Labyrnth
Moderator
Reputation: 10

Joined: 28 Nov 2006
Posts: 6301

PostPosted: Sat Jul 26, 2025 11:55 am    Post subject: Reply with quote

few things could cause some issues, just make some adjusments.
Like above you can play with these to make adjustments.
------------------------------------------------------------------------

self.Instructions = createLabel(self.form);
self.Instructions.Left = 20;
self.Instructions.Top = 20;
self.Instructions.Width = 300; --Be sure caption isnt too short.
self.Instructions.Height = 50;
self.Instructions.Caption = "Select Exp, Gold, and Hero to recalculate";
self.Instructions.WordWrap = true;
self.Instructions.AutoSize = false;
self.Instructions.Font.Color = clBlack;
self.Instructions.Transparent = false;
self.Instructions.Color = clWhite;
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 36

Joined: 16 Feb 2017
Posts: 1511

PostPosted: Sat Jul 26, 2025 12:13 pm    Post subject: Reply with quote

Labyrnth wrote:
few things could cause some issues, just make some adjusments.
Like above you can play with these to make adjustments.
------------------------------------------------------------------------

self.Instructions = createLabel(self.form);
self.Instructions.Left = 20;
self.Instructions.Top = 20;
self.Instructions.Width = 300; --Be sure caption isnt too short.
self.Instructions.Height = 50;
self.Instructions.Caption = "Select Exp, Gold, and Hero to recalculate";
self.Instructions.WordWrap = true;
self.Instructions.AutoSize = false;
self.Instructions.Font.Color = clBlack;
self.Instructions.Transparent = false;
self.Instructions.Color = clWhite;


It's likely a label with a small amount of space allocated to the right side of the form.


This allows long expressions to scroll down without spilling over the form.
Code:
self.Instructions = createLabel(self.form);
self.Instructions.AutoSize = false; -- For proper rendering, "AutoSize" should be used at the top of the sequence.
self.Instructions.Left = 20;
self.Instructions.Top = 20;
self.Instructions.Width = 70; -- 300 will go beyond the form.
self.Instructions.Height = 50;
self.Instructions.Caption = "Select Exp, Gold, and Hero to recalculate";
self.Instructions.WordWrap = true; -- Preventing side overflow.
self.Instructions.OptimalFill=true -- Keep within specified width and height limits.

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Sat Jul 26, 2025 1:07 pm    Post subject: Reply with quote

you can also use [[string literals
that go to another line]]

_________________
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