View previous topic :: View next topic |
Author |
Message |
bknight2602 Grandmaster Cheater Reputation: 0
Joined: 08 Oct 2012 Posts: 577
|
Posted: Mon Apr 25, 2022 11:26 am Post subject: Building new trainer |
|
|
I'm building a new trainer from old trainers.
Code: | trainer = {
};
function trainer:start()
self.form = createForm(false);
setProperty(self.form , "BiDiMode", "bdLeftToRight");
self.form.Caption = 'Cheat Panel';
self.form.Width = 400;
self.form.Height = 470;
self.form.Left = 760;
self.form.Top =5;
end;
trainer:start();
|
But nothing is created? This portion of code works in other codes. No errors just nothing?
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1257
|
Posted: Mon Apr 25, 2022 11:56 am Post subject: |
|
|
Code: | trainer = {
};
function trainer:start()
self.form = createForm(); -- Create - visible ? not false ..
setProperty(self.form , "BiDiMode", "bdLeftToRight");
self.form.Caption = 'Cheat Panel';
self.form.Width = 400;
self.form.Height = 470;
self.form.Left = 760;
self.form.Top =5;
end;
trainer:start(); |
_________________
|
|
Back to top |
|
|
atom0s Moderator Reputation: 198
Joined: 25 Jan 2006 Posts: 8517 Location: 127.0.0.1
|
Posted: Mon Apr 25, 2022 11:59 am Post subject: |
|
|
Be careful with how you're using colon vs. dot calling and function naming. As is that is not the correct format. As for the form not showing, you aren't telling it to. You need to add 'self.form:Show()'.
Code: | trainer = {};
function trainer.start(self)
self.form = createForm(false);
setProperty(self.form, 'BiDiMode', 'bdLeftToRight');
self.form.Caption = 'Cheat Panel';
self.form.Width = 400;
self.form.Height = 470;
self.form.Left = 760;
self.form.Top = 5;
self.form:Show();
end
trainer:start(); |
Notice the period being used for the 'object.funcname' and the 'self' parameter being defined. Also notice the colon being used for the actual call which tells Lua to automatically pass the calling object as the first parameter.
Otherwise, you would call this like:
Code: | trainer.start(trainer); |
For more info, see: https://www.lua.org/pil/16.html
_________________
- Retired. |
|
Back to top |
|
|
bknight2602 Grandmaster Cheater Reputation: 0
Joined: 08 Oct 2012 Posts: 577
|
Posted: Mon Apr 25, 2022 12:20 pm Post subject: |
|
|
atom0s wrote: | Be careful with how you're using colon vs. dot calling and function naming. As is that is not the correct format. As for the form not showing, you aren't telling it to. You need to add 'self.form:Show()'.
Code: | trainer = {};
function trainer.start(self)
self.form = createForm(false);
setProperty(self.form, 'BiDiMode', 'bdLeftToRight');
self.form.Caption = 'Cheat Panel';
self.form.Width = 400;
self.form.Height = 470;
self.form.Left = 760;
self.form.Top = 5;
self.form:Show();
end
trainer:start(); |
Notice the period being used for the 'object.funcname' and the 'self' parameter being defined. Also notice the colon being used for the actual call which tells Lua to automatically pass the calling object as the first parameter.
Otherwise, you would call this like:
Code: | trainer.start(trainer); |
For more info, see: https://www.lua.org/pil/16.html |
duh:
Thanks.
|
|
Back to top |
|
|
|