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 


I'm blind because I can't make this work

 
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: Thu Feb 20, 2014 10:47 pm    Post subject: I'm blind because I can't make this work Reply with quote

Code:
   self.t = createTimer(nil, false)
   self.t.onTimer = MaxHP
   self.t.Interval = 500;
   
   self.gm_cb = createCheckBox(self.form);
   self.gm_cb.Caption = 'God Mode';
   self.gm_cb.Height = 20;
   self.gm_cb.Left = 10;
   self.gm_cb.Width = 90;
   self.gm_cb.Top = 10;
   self.gm_cb.onClick =   function (sender)
                           if sender.Checked then
                              self.t.Enabled = true;
                              print("God mode is enabled")
                           else
                              self.t.Enabled = false;
                              print("God mode is not enabled")
                           end
                          end

This does not work, no print statements when check box is selected and the function MaxHP does not run
Code:

  self.tsw = createTimer(nil, false)
  self.tsw.onTimer = MaxSword
  self.tsw.Interval = 900
  self.sword_cb = createCheckBox(self.form);
  self.sword_cb.Caption = 'Max Sword';
  self.sword_cb.Height = 20;
  self.sword_cb.Left = 10;
  self.sword_cb.Width = 90;
  self.sword_cb.Top = 40;
  self.sword_cb.onClick =   function (sender)
                           if sender.Checked then
                              self.tsw.Enabled = true;
                              print("Sword 4 is enabled")
                              swordflag = 1
                           else
                              self.tsw.Enabled = false;
                              print("Sword 4 is not enabled")
                              swordflag = nil
                              addresslist_sw = getAddressList()
                              memoryrecord_setValue(swordaddress, prevsword)
                           end
                          end

This works and I don't understand why the first does not, as they appear to be very similar.
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Thu Feb 20, 2014 11:28 pm    Post subject: Reply with quote

This works for me. Perhaps the problem is somewhere else?
Code:

   self={}
   self.form=createForm()
   self.t = createTimer(nil, false)
   self.t.onTimer = MaxHP
   self.t.Interval = 500;
   
   self.gm_cb = createCheckBox(self.form);
   self.gm_cb.Caption = 'God Mode';
   self.gm_cb.Height = 20;
   self.gm_cb.Left = 10;
   self.gm_cb.Width = 90;
   self.gm_cb.Top = 10;
   self.gm_cb.onClick =   function (sender)
                           if sender.Checked then
                              self.t.Enabled = true;
                              print("God mode is enabled")
                           else
                              self.t.Enabled = false;
                              print("God mode is not enabled")
                           end
                          end

_________________
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
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Fri Feb 21, 2014 8:01 am    Post subject: Reply with quote

Code:
--
trainer =    {};

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 = 370;
   self.form.Height = 360;
   self.form.Left = 430;
   self.form.Top =10;

   self.t = createTimer(nil, false)
   self.t.onTimer = MaxHP
   self.t.Interval = 500; --checks every 500 milliseconds
--
   self.gm_cb = createCheckBox(self.form);
   self.gm_cb.Caption = 'God Mode';
   self.gm_cb.Height = 20;
   self.gm_cb.Left = 10;
   self.gm_cb.Width = 90;
   self.gm_cb.Top = 10;
   self.gm_cb.onClick =   function (sender)
                           if sender.Checked then
                              self.t.Enabled = true;
                              print("God mode is enabled")
                           else
                              self.t.Enabled = false;
                              print("God mode is not enabled")
                           end
                          end
--
  self.tsw = createTimer(nil, false)
  self.tsw.onTimer = MaxSword
  self.tsw.Interval = 900
--
  self.sword_cb = createCheckBox(self.form);
  self.sword_cb.Caption = 'Max Sword';
  self.sword_cb.Height = 20;
  self.sword_cb.Left = 10;
  self.sword_cb.Width = 90;
  self.sword_cb.Top = 40;
  self.sword_cb.onClick =   function (sender)
                           if sender.Checked then
                              self.tsw.Enabled = true;
                              print("Sword 4 is enabled")
                              swordflag = 1
                           else
                              self.tsw.Enabled = false;
                              print("Sword 4 is not enabled")
                              swordflag = nil
                              addresslist_sw = getAddressList()
                              memoryrecord_setValue(swordaddress, prevsword)
                           end
                          end
--
  self.tsh = createTimer(nil, false)
  self.tsh.onTimer = MaxShield
  self.tsh.Interval = 950

  self.shield_cb = createCheckBox(self.form);
  self.shield_cb.Caption = 'Max Shield';
  self.shield_cb.Height = 20;
  self.shield_cb.Left = 10;
  self.shield_cb.Width = 90;
  self.shield_cb.Top = 70;
  self.shield_cb.onClick =   function (sender)
                             if sender.Checked then
                               self.tsh.Enabled = true;
                               print("Shield 3 is enabled")
                               shieldflag = 1
                             else
                               self.tsh.Enabled = false;
                               print("Shield 3 is not enabled")
                               shieldflag = nil
                               addresslist_sh = getAddressList()
                               memoryrecord_setValue(shield1address, prevshield)
                             end
                             end
--
  self.tunic = createTimer(nil, false)
  self.tunic.onTimer = MaxTunic
  self.tunic.Interval = 1000
--
  self.tunic_cb = createCheckBox(self.form);
  self.tunic_cb.Caption = 'Max Tunic';
  self.tunic_cb.Height = 20;
  self.tunic_cb.Left = 10;
  self.tunic_cb.Width = 90;
  self.tunic_cb.Top = 100;
  self.tunic_cb.onClick =   function (sender)
                           if sender.Checked then
                              self.tunic.Enabled = true;
                              print("Tunic 2 is enabled")
                              tunicflag = 1
                           else
                              self.tunic.Enabled = false;
                              print("Tunic 2 is not enabled")
                              tunicflag = nil
                              addresslist_tunic = getAddressList()
                              memoryrecord_setValue(tunicaddress, prevtunic)
                           end
                          end
--
   self.mg_cb = createCheckBox(self.form);
   self.mg_cb.Caption = 'Max Gems';
   self.mg_cb.Height = 20;
   self.mg_cb.Left = 10;
   self.mg_cb.Width = 90;
   self.mg_cb.Top = 130;
   self.gm_cb.onClick =   function (sender)
                           if sender.Checked then
                              addresslist_mg = getAddressList()
                              gemsaddress = addresslist_getMemoryRecordByDescription(addresslist_mg, "Gems")
                              gems = memoryrecord_getValue(gemsaddress)
                              memoryrecord_setValue(gemsaddress, 999)
                           else
                           end
                          end
--
self.form.show();
print("God mode is not enabled");
end;--trainer:start()
--
function MaxSword(sender)
addresslist_sw = getAddressList()
swordaddress = addresslist_getMemoryRecordByDescription(addresslist_sw, "Sword 1, 2, 3, 4")
sword = memoryrecord_getValue(swordaddress)
if swordflag then
  prevsword = sword
  swordflag = nil
else
end--if swordflag then
  memoryrecord_setValue(swordaddress, 4)
end--function MaxSword(sender)
--
function MaxShield(sender)
addresslist_sh = getAddressList()
shield1address = addresslist_getMemoryRecordByDescription(addresslist_sh, "Shield 1, 2, 3")
shield1 = memoryrecord_getValue(shield1address)
if shieldflag then
  prevshield = shield1
  shieldflag = nil
else
end--if shieldflag then
  memoryrecord_setValue(shield1address, 3)
end--function MaxShield(sender)
--
function MaxTunic(sender)
addresslist_tunic = getAddressList()
tunicaddress = addresslist_getMemoryRecordByDescription(addresslist_tunic, "Tunic 1, 2")
tunic = memoryrecord_getValue(tunicaddress)
if tunicflag then
  prevtunic = tunic
  tunicflag = nil
else
end--if shieldflag then
  memoryrecord_setValue(tunicaddress, 2)
end--function MaxTunic(sender)
--
function MaxHP(sender)
addresslist = getAddressList()
maxhpaddress = addresslist_getMemoryRecordByDescription(addresslist, "Max Hearts")
maxhp = memoryrecord_getValue(maxhpaddress)
curhpaddress = addresslist_getMemoryRecordByDescription(addresslist, "Cur Hearts")
curhp = memoryrecord_getValue(curhpaddress)
curmpaddress = addresslist_getMemoryRecordByDescription(addresslist, "Magic Bottle")
curmp = memoryrecord_getValue(curmpaddress)
bombaddress = addresslist_getMemoryRecordByDescription(addresslist, "Bomb")
bomb = memoryrecord_getValue(bombaddress)
memoryrecord_setValue(bombaddress, 99)
arrowaddress = addresslist_getMemoryRecordByDescription(addresslist, "Arrows")
arrow = memoryrecord_getValue(arrowaddress)
memoryrecord_setValue(arrowaddress, 99)
memoryrecord_setValue(curhpaddress, maxhp)
memoryrecord_setValue(curmpaddress, 128)
end--function MaxHP

trainer:start();


Here is the whole code and the same error exists, perhaps you may be able to spot where I have erred. Everything works except that particular check box.

EDIT: The check box is created, but when checked the print statement is not executed and the timer does not run.
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Fri Feb 21, 2014 9:16 am    Post subject: Reply with quote

you are overwriting self.gm_cb.onClick
Code:

   self.mg_cb = createCheckBox(self.form);
   self.mg_cb.Caption = 'Max Gems';
   self.mg_cb.Height = 20;
   self.mg_cb.Left = 10;
   self.mg_cb.Width = 90;
   self.mg_cb.Top = 130;
   self.gm_cb.onClick =   function (sender)
                           if sender.Checked then
                              addresslist_mg = getAddressList()
                              gemsaddress = addresslist_getMemoryRecordByDescription(addresslist_mg, "Gems")
                              gems = memoryrecord_getValue(gemsaddress)
                              memoryrecord_setValue(gemsaddress, 999)
                           else
                           end
                          end


you probably want to change gm_cb to mg_cb

_________________
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
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Fri Feb 21, 2014 10:12 am    Post subject: Reply with quote

I told you I was blind, thanks
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