|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
bknight2602 Grandmaster Cheater Reputation: 0
Joined: 08 Oct 2012 Posts: 577
|
Posted: Fri Jan 10, 2020 1:53 pm Post subject: Using an edit box value to set an address value |
|
|
Code: |
trainer
self.extra_exp_value = createEdit(self.value_panel3);
self.extra_exp_value.top = 4;
self.extra_exp_value.left = 2;
self.extra_exp_value.Width = 86;
self.extra_exp_value.Height = 31;
--
self.extra_ap_value = createEdit(self.value_panel4);
self.extra_ap_value.top = 4;
self.extra_ap_value.left = 2;
self.extra_ap_value.Width = 86;
self.extra_ap_value.Height = 31;
--
function ExtraExp(sender)
local AL = getAddressList();
if not valueE then
valueE = tonumber(self.extra_exp_value.Text);
end;
if not valueA then
valueA = tonumber(self.extra_ap_value.Text);
end;
if tonumber(addresslist_getMemoryRecordByDescription(AL, "Battle Byte").Value) == 32 then
addresslist_getMemoryRecordByDescription(AL, "After Battle Non Kill XP").Value = valueE
--addresslist_getMemoryRecordByDescription(AL, "After Battle Non Kill XP").Value = 1000
addresslist_getMemoryRecordByDescription(AL, "After Battle AP").Value = valueA
--addresslist_getMemoryRecordByDescription(AL, "After Battle AP").Value = 100
end
end--function ExtraExp(sender)
--
self.Exp = createTimer(nil, false)
self.Exp.onTimer = ExtraExp
self.Exp.Interval = 1000; --checks every 1000 milliseconds
--
self.form.show();
self.ea_cb = createCheckBox(self.form);
self.ea_cb.Caption = "Ent Exp and AP below";
self.ea_cb.Height = 20;
self.ea_cb.Left = 240;
self.ea_cb.Width = 75;
self.ea_cb.Top = 110;
self.ea_cb.onClick = function (sender)
if sender.Checked then
self.Exp.Enabled = true;
--valueA = 10;
--valueE = 100;
print("Extra Exp is enabled")
else
self.Exp.Enabled = false;
print("Extra Exp is not enabled")
self.extra_exp_value.Text = nil
self.extra_ap_value.Text = nil
valueE = nil;
valueE = nil;
end--if sender.Checked then
end--function (sender
--
end--trainer
--
trainer:start();
|
This is a code snippet that I have.
What I'm attempting is to check the check box and then enter a value in the edit box. But As soon as I enter a value I get an invalid integer error message. What needs to be changed to the procedure?
|
|
Back to top |
|
|
DaSpamer Grandmaster Cheater Supreme Reputation: 52
Joined: 13 Sep 2011 Posts: 1578
|
Posted: Sat Jan 11, 2020 9:37 am Post subject: |
|
|
I assume you're the editbox holds hexadecimal address.
While tonumber without additional parameter specifying what type of number you're supplying it treats it as decimal
So you have to do either of these 2 ways;
Code: | local address = 'FFFFFFFF';
print(tonumber('0x'..address));
|
or
Code: | local address = 'FFFFFFFF';
print(tonumber(address,16));
|
_________________
|
|
Back to top |
|
|
bknight2602 Grandmaster Cheater Reputation: 0
Joined: 08 Oct 2012 Posts: 577
|
Posted: Sat Jan 11, 2020 11:23 am Post subject: |
|
|
DaSpamer wrote: | I assume you're the editbox holds hexadecimal address.
While tonumber without additional parameter specifying what type of number you're supplying it treats it as decimal
So you have to do either of these 2 ways;
Code: | local address = 'FFFFFFFF';
print(tonumber('0x'..address));
|
or
Code: | local address = 'FFFFFFFF';
print(tonumber(address,16));
|
|
Umm no the edit box is blank at startup and I only input integers 10, 100, 1000 etc.
I wish to take the input number and insert that number into a table address:
addresslist_getMemoryRecordByDescription(AL, "After Battle Non Kill XP").Value = valueE
and/or
addresslist_getMemoryRecordByDescription(AL, "After Battle AP").Value = valueA
I will attempt your thoughts and report in an edit to this post.
ETA: No the change in the tonumber command to
Code: |
function ExtraExp(sender)
local AL = getAddressList();
if not valueE then
valueE = tonumber(self.extra_exp_value.Text,16);
end;
if not valueA then
valueA = tonumber(self.extra_ap_value.Text,16);
end;
if tonumber(addresslist_getMemoryRecordByDescription(AL, "Battle Byte").Value) == 32 then
addresslist_getMemoryRecordByDescription(AL, "After Battle Non Kill XP").Value = valueE
--addresslist_getMemoryRecordByDescription(AL, "After Battle Non Kill XP").Value = 1000
addresslist_getMemoryRecordByDescription(AL, "After Battle AP").Value = valueA
--addresslist_getMemoryRecordByDescription(AL, "After Battle AP").Value = 100
end |
Resulted in the same error: Invalid integer
Now if I set either/both valueA valueE ton an interger see the original code with the commented lines for integers the code works exactly as desired.
|
|
Back to top |
|
|
DaSpamer Grandmaster Cheater Supreme Reputation: 52
Joined: 13 Sep 2011 Posts: 1578
|
Posted: Sat Jan 11, 2020 5:17 pm Post subject: |
|
|
I've misread your post earlier, thought you're trying to set an address from edit box.
tonumber second parameter specifies the base to interpret the number, and it range from base 2 to 36.
by specifying base 16, its interpreting the number as hexadecimal.
Anyway I suspect that you either set some letters inside your editbox or valueE or valueA are not integers.
Code: | local keyPressNumeric = function(sender,key)
return((tonumber(key)or key=='\08')and key or nil); -- any number key or backspace key
end;
local onChangeNumeric = function(sender)
sender.Text = tonumber(sender.Text) or 0; -- prevent from text being anything other than a number, default zero
end;
self.extra_exp_value.onChange = onChangeNumeric; -- force editbox to contain a number or default value any change;
self.extra_exp_value.OnKeyPress = keyPressNumeric; -- assign keyPressNumeric to any editbox you wish to force only numbers key presses;
self.extra_ap_value.onChange = onChangeNumeric;
self.extra_ap_value.OnKeyPress = keyPressNumeric;
function ExtraExp(sender)
local al = getAddressList();
valueE = tonumber(valueE) or tonumber(self.extra_exp_value.Text); -- im casting valueE to a number in case you haven't assign anything to it, or it is not a number..
valueA = tonumber(valueA) or tonumber(self.extra_ap_value.Text);
if (tonumber(al.getMemoryRecordByDescription('Battle Byte').Value) == 32) then
al.getMemoryRecordByDescription('After Battle Non Kill XP').Value = valueE;
al.getMemoryRecordByDescription('After Battle AP').Value = valueA;
end
-- rest of your code...
end |
_________________
|
|
Back to top |
|
|
bknight2602 Grandmaster Cheater Reputation: 0
Joined: 08 Oct 2012 Posts: 577
|
Posted: Sun Jan 12, 2020 4:39 pm Post subject: |
|
|
There were a couple of errors further back in the code that fixed the issue. Your suggestion that a alpha was in the code wasn't right, but you handed me some code years ago, that prevented alphas and I had an incorrect name associated with it, fixed those and the issues went away.
Thanks
|
|
Back to top |
|
|
bknight2602 Grandmaster Cheater Reputation: 0
Joined: 08 Oct 2012 Posts: 577
|
Posted: Sun Jan 19, 2020 10:47 am Post subject: |
|
|
I've been trying to rewrite the code eliminating errors: Corrected code
Code: |
self.value_panel3 = createPanel(self.form);
self.value_panel3.Text = '';
self.value_panel3.left = 240;
self.value_panel3.top = 130;
self.value_panel3.Height = 35;
self.value_panel3.Width = 90;--Extra AP
--
self.value_panel4 = createPanel(self.form);
self.value_panel4.Text = '';
self.value_panel4.left = 240;
self.value_panel4.top = 170;
self.value_panel4.Height = 35;
self.value_panel4.Width = 90;--Extra Exp
--
self.extra_exp_value = createEdit(self.value_panel3);
self.extra_exp_value.top = 4;
self.extra_exp_value.left = 2;
self.extra_exp_value.Width = 86;
self.extra_exp_value.Height = 31;
setMethodProperty(self.extra_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.Text == nil or sender.Text == '')) then key = nil; self.set_extra_exp.onClick(); end return key; end)
--
self.extra_ap_value = createEdit(self.value_panel4);
self.extra_ap_value.top = 4;
self.extra_ap_value.left = 2;
self.extra_ap_value.Width = 86;
self.extra_ap_value.Height = 31;
setMethodProperty(self.extra_ap_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.Text == nil or sender.Text == '')) then key = nil; self.set_extra_ap.onClick(); end return key; end)
--
function ExtraExp(sender)
local AL = getAddressList();
if tonumber(addresslist_getMemoryRecordByDescription(AL, "Battle Byte").Value) == 32 then
if trainer.extra_exp_value.Text then
valueE = tonumber(trainer.extra_exp_value.Text);
end;
if trainer.extra_ap_value.Text then
valueA = tonumber(trainer.extra_ap_value.Text);
end;
if valueE then
addresslist_getMemoryRecordByDescription(AL, "After Battle Non Kill XP").Value = valueE
end;
--addresslist_getMemoryRecordByDescription(AL, "After Battle Non Kill XP").Value = 1000
if valueA then
addresslist_getMemoryRecordByDescription(AL, "After Battle AP").Value = valueA
end;
--addresslist_getMemoryRecordByDescription(AL, "After Battle AP").Value = 100
end
end--function ExtraExp(sender)
self.Exp = createTimer(nil, false)
self.Exp.onTimer = ExtraExp
self.Exp.Interval = 1000;
|
When not in a battle no errors with checkbox unchecked.
As I type this trainer.extra_ap_value.Text should be 100(using print the result is 100 good so far.), and trainer.extra_exp_value.Text should be nil(nothing in edit box and print shows nothing)
Entering a battle the first if statement is true, and I still get the invalid integer and after 200 notations(I guess) I start getting stack overflows).
ETA I just figured out the error, removing the not removes the error.
|
|
Back to top |
|
|
|
|
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
|
|