| View previous topic :: View next topic |
| Author |
Message |
bknight2602 Grandmaster Cheater
Reputation: 0
Joined: 08 Oct 2012 Posts: 586
|
Posted: Fri Feb 25, 2022 11:08 am Post subject: Button click |
|
|
I have an editbox and button on a table.
I have entered an button on click function, but it is not working.
| Code: |
function CEButton1Click(sender)--exp
if tonumber(CheatPanel_CEEdit1.Text) then
local value = tonumber(CheatPanel_CEEdit1.Text);
end
expvalue = value;
print("The experience entered " .. expvalue);
end--function CEButton1Click(sender)--exp
|
I receive an error "Error:attempt to call a nil value"
Is it not possible to call across different objects?
How would I code so that the text can be used in a calculation?
|
|
| Back to top |
|
 |
TheyCallMeTim13 Wiki Contributor
Reputation: 51
Joined: 24 Feb 2017 Posts: 976 Location: Pluto
|
Posted: Fri Feb 25, 2022 11:16 am Post subject: |
|
|
Does it give a line number, or the name of what you're trying to call? Because the only things you call here are tonumber and print, so unless you have set one of those to nil I don't think the issues is here.
_________________
|
|
| Back to top |
|
 |
bknight2602 Grandmaster Cheater
Reputation: 0
Joined: 08 Oct 2012 Posts: 586
|
Posted: Fri Feb 25, 2022 11:29 am Post subject: |
|
|
No line number given. The only output is precisely what I quoted.
"Error:attempt to call a nil value"
|
|
| Back to top |
|
 |
AylinCE Grandmaster Cheater Supreme
Reputation: 37
Joined: 16 Feb 2017 Posts: 1531
|
Posted: Fri Feb 25, 2022 11:37 am Post subject: |
|
|
"CheatPanel_CEEdit1" ?
Trainer name: "CheatPanel"
Edit name: "CEEdit1"
Object: "CheatPanel.CEEdit1"
| Code: | local expvalue=0 --or string "" --If you want to use the value in a different field, define it outside first.
function CEButton1Click(sender)--exp
if CheatPanel.CEEdit1.Text~="" then
expvalue = tonumber(CheatPanel.CEEdit1.Text);
--expvalue = value;
print("The experience entered " .. expvalue);
else
print("The corresponding box appears empty!");
end
end |
_________________
|
|
| Back to top |
|
 |
bknight2602 Grandmaster Cheater
Reputation: 0
Joined: 08 Oct 2012 Posts: 586
|
Posted: Fri Feb 25, 2022 12:09 pm Post subject: |
|
|
| Code: |
local expvalue=0 --or string "" --If you want to use the value in a different field, define it outside first.
function CEButton1Click(sender)--exp
if CheatPanel.CEEdit1.Text~="" then
expvalue = tonumber(CheatPanel.CEEdit1.Text);
--expvalue = value;
print("The experience entered " .. expvalue);
else
print("The corresponding box appears empty!");
end
end--function CEButton1Click(sender)--exp
|
I don't understand your initial comment "local expvalue=0 --or string "" --If you want to use the value in a different field, define it outside first." The number in the edit box will only be used to determine a value used in a memscan and will then be set to nil. However, this code has the same error listed.
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25812 Location: The netherlands
|
Posted: Fri Feb 25, 2022 1:04 pm Post subject: |
|
|
the error is likely somewhere else
_________________
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 |
|
 |
AylinCE Grandmaster Cheater Supreme
Reputation: 37
Joined: 16 Feb 2017 Posts: 1531
|
Posted: Fri Feb 25, 2022 1:44 pm Post subject: |
|
|
If you're not going to use the "expvalue" outside of Button click, of course, the situation changes.
But if the code I suggested still gives an error, try the code below.
If there is no other code in Button1, delete Button1 and Edit1 and try to create it again.
| Code: | CheatPanel.CEButton1.OnClick=function()
if CheatPanel.CEEdit1.Text~="" then
print("The experience entered " .. tonumber(CheatPanel.CEEdit1.Text));
else
print("The corresponding box appears empty!");
end
end |
_________________
|
|
| Back to top |
|
 |
bknight2602 Grandmaster Cheater
Reputation: 0
Joined: 08 Oct 2012 Posts: 586
|
Posted: Fri Feb 25, 2022 4:24 pm Post subject: |
|
|
it so happens that I do have another pair of them and
| Code: |
CheatPanel.CEButton2.OnClick=function()
if CheatPanel.CEEdit2.Text~="" then
print("The experience entered " .. tonumber(CheatPanel.CEEdit2.Text));
else
print("The corresponding box appears empty!");
end
end
|
Has the same error message.
I am getting frustrated with this table. Here is almost identical code fom an old table and I don't get errors. Is there a maximum number of records?
| Code: |
function CEButton1Click(sender)
expvalue = tonumber(control_getCaption(CheatPanel_CEEdit1))
print('Experience = '..expvalue)
if expvalue ~= nil and goldvalue ~= nil and heroname ~= nil then
RecalculateAddresses()
end
end
function CEButton2Click(sender)
goldvalue = tonumber(control_getCaption(CheatPanel_CEEdit2))
print('Gold = '..goldvalue)
if expvalue ~= nil and goldvalue ~= nil and heroname ~= nil then
RecalculateAddresses()
end
end
|
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25812 Location: The netherlands
|
Posted: Fri Feb 25, 2022 5:32 pm Post subject: |
|
|
unless print or tonumber have been replaced by nil, that code isn't the cause of the error
this error means that something did a name(xxx) and name is nil
_________________
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 |
|
 |
bknight2602 Grandmaster Cheater
Reputation: 0
Joined: 08 Oct 2012 Posts: 586
|
Posted: Fri Feb 25, 2022 8:04 pm Post subject: |
|
|
expvalue = tonumber(CheatPanel.CEEdit1.Text)
expvalue = tonumber(control_getCaption(CheatPanel_CEEdit1))
Neither of these code line sets expvalue but both result in Error:attempt to call a nil value
What should the line be?
| Description: |
|
| Filesize: |
44.95 KB |
| Viewed: |
4753 Time(s) |

|
|
|
| Back to top |
|
 |
TheyCallMeTim13 Wiki Contributor
Reputation: 51
Joined: 24 Feb 2017 Posts: 976 Location: Pluto
|
Posted: Fri Feb 25, 2022 9:33 pm Post subject: |
|
|
If this is true, then somewhere in your code you have set tonumber to nil; i.e. "tonumber = <something that is nil>". You'll have to find where you're doing that and fix the code.
_________________
|
|
| Back to top |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Fri Feb 25, 2022 10:52 pm Post subject: |
|
|
I agree with @TheyCallMeTim13. ...somewhere in your code you have set tonumber to nil; i.e. "tonumber = <something that is nil>" or objects name not identified or defined.
Tried by code not Form Designer, it's work fine
| Code: | if f then f.destroy() end
f = createForm()
edt = createEdit(f)
edt.Text = 10
btn = createButton(f)
btn.Top = edt.top + edt.height + 5
btn.left = edt.left
btn.caption = 'click me'
function btnclick()
local val1 = edt.Text
local val2 = 10
if tonumber(val1) == nil then print("ERROR...!!") else print(val1 + val2) end
end
f.show()
btn.onClick = btnclick |
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
| Back to top |
|
 |
bknight2602 Grandmaster Cheater
Reputation: 0
Joined: 08 Oct 2012 Posts: 586
|
Posted: Sat Feb 26, 2022 9:51 am Post subject: |
|
|
| TheyCallMeTim13 wrote: | | If this is true, then somewhere in your code you have set tonumber to nil; i.e. "tonumber = <something that is nil>". You'll have to find where you're doing that and fix the code. |
I would love to find something tonumber<something that is nil>
However in this instance there are exactly four occurrences of tonumber. I won't show the whole code of ~2k lines, but I will list the tonumbers and copy them here not i a code block.
1724:memrec2 = tonumber(memrec1, 16);
1728:memrec4 = tonumber(memrec3, 16);
1797:expvalue = tonumber(control_getCaption(CheatPanel_CEEdit1))-- This is within the CEButtonClick1 currently under discussion.
1805:goldvalue = tonumber(control_getCaption(CheatPanel_CEEdit2)) This is with CEButtonClick2 which has a similar code as 1, but different var. These are the current saved lines but I have varied 1797 to tonumber(CheatPanel.CEEdit1.Text) which has given the same error message.
There are many instances of nil. These are code Ines 1-22
| Code: |
function FormShow(sender)
form_show(CheatPanel);
t = createTimer(nil, true);
timer_onTimer(t, MaxHP)
timer_setInterval(t, 500)--checks every 500 milliseconds
timer_setEnabled(t, false)
print("God Mode is not enabled")
--
tde = createTimer(nil, true)
timer_onTimer(tde, DisplayEdits)
timer_setInterval(tde, 1000)
timer_setEnabled(tde, false)
--
tstop = createTimer(nil)
tstop.Interval = 1000
tstop.onTimer = function(tstop)
if(getOpenedProcessID() ~= 0)
and (readInteger("kernel32.dll") == nil) then
closeCE()
end
end
tstop.Enabled = true
|
There are many more, most of which check to see if a var is nil, and a few setting var to nil at the end of several functions.
|
|
| Back to top |
|
 |
TheyCallMeTim13 Wiki Contributor
Reputation: 51
Joined: 24 Feb 2017 Posts: 976 Location: Pluto
|
Posted: Sat Feb 26, 2022 10:11 am Post subject: |
|
|
Paste this code in the lua engine window, hit execute and see if you get an error.
| Code: | | expvalue = tonumber(CheatPanel.CEEdit1.Text) |
_________________
|
|
| Back to top |
|
 |
bknight2602 Grandmaster Cheater
Reputation: 0
Joined: 08 Oct 2012 Posts: 586
|
Posted: Sat Feb 26, 2022 10:47 am Post subject: |
|
|
As the output shows nothing but doesn't give an error. The output has an error in the first instance to show the window the other two are hitting the execute button.
Now I show the edit window to display that both edits were created with nothing in the seText box. The image displays 278 in the edit box and 278 in the edit portion of the edit box.
ETA: I added twelve exp addresses to the blank table half moved to a group header the other 6 were stand alone, then I searched for and displayed an address for 1st gold. I saved the table and re-opened.
| Code: |
function FormShow(sender)
form_show(CheatPanel);
t = createTimer(nil, true);
timer_onTimer(t, MaxHP)
timer_setInterval(t, 500)--checks every 500 milliseconds
timer_setEnabled(t, false)
print("God Mode is not enabled")
|
ChealPanel was displayed but the print statement wasn't executed. Perhaps the one o the timers does have an error.
| Description: |
|
| Filesize: |
380.66 KB |
| Viewed: |
4680 Time(s) |

|
|
|
| Back to top |
|
 |
|