|
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: Sun Aug 07, 2016 7:48 am Post subject: Check Box Code |
|
|
I'm trying to code a check box, but it isn't working. The original code is old, but works.
Here is the additions this morning:
Code: | function FormShow(sender)
...
tChocoRace = createTimer(nil, true)
timer_onTimer(tChocoRace, CECheckbox6Click)
timer_setInterval(tChocoRace, 500)
timer_setEnabled(tChocoRace, false)
...
end--form_show
--
function CECheckbox6Click(sender)
boxstate = checkbox_getState(CheatPanel_CECheckbox6)
if boxstate == cbChecked then
timer_setEnabled(tChocoRace, true)
local AL = getAddressList()
cNo1curspeedaddress = addresslist_getMemoryRecordByDescription(AL, "Choco 1 In Race Cur Speed")
cNo1maxspeedaddress = addresslist_getMemoryRecordByDescription(AL, "Choco 1 In Race Max Speed")
cNo1maxsprintaddress = addresslist_getMemoryRecordByDescription(AL, "Choco 1 In Race Max Sprint")
cNo1curstamaddress = addresslist_getMemoryRecordByDescription(AL, "Choco 1 In Race Cur Stamina")
cNo1maxstamaddress = addresslist_getMemoryRecordByDescription(AL, "Choco 1 In Race Max Stamina")
cNo2curspeedaddress = addresslist_getMemoryRecordByDescription(AL, "Choco 2 In Race Cur Speed")
cNo2maxspeedaddress = addresslist_getMemoryRecordByDescription(AL, "Choco 2 In Race Max Speed")
cNo2maxsprintaddress = addresslist_getMemoryRecordByDescription(AL, "Choco 2 In Race Max Sprint")
cNo2curstamaddress = addresslist_getMemoryRecordByDescription(AL, "Choco 2 In Race Cur Stamina")
cNo2maxstamaddress = addresslist_getMemoryRecordByDescription(AL, "Choco 2 In Race Max Stamina")
cNo1maxsprint = memoryrecord_GetValue(cNo1maxsprintaddress)
cNo1curspeed = memoryrecord_SetValue(cNo1curspeedaddress,cNo1maxsprint)
cNo1maxstam = memoryrecordGetValue(AL, cNo1maxstamaddress)
cNo1curstam = memoryrecordSetValue(cNo1curstamaddress, cNo1maxstam)
cNo2curspeed = memoryrecord_GetValue(cNo2curspeedaddress)
cNo2curspeed = memoryrecord_SetValue(cNo2curspeedaddress,cNo1curspeed*.25)
cNo2maxstam = memoryrecordGetValue(AL, cNo1maxstam*.25)
print("Choco 1 winner is enabled")
else
timer_setEnabled(tChocoRace, false)
print("Choco 1 winner is not enabled")
end
end |
The game is Final Fantasy VII and I know the function isn't working as the print statement is never executed when the check box is checked(the state is 1 when checked)
What am I missing?
|
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sun Aug 07, 2016 8:16 am Post subject: |
|
|
Make sure CECheckbox6Click is assigned to your checkbox OnClick event.
Make sure CheatPanel_CECheckbox6 is an accessible object to your checkbox.
Make sure you click Execute script on the Cheat Table Lua Script.
|
|
Back to top |
|
|
bknight2602 Grandmaster Cheater Reputation: 0
Joined: 08 Oct 2012 Posts: 577
|
Posted: Sun Aug 07, 2016 9:19 am Post subject: |
|
|
"Make sure CECheckbox6Click is assigned to your checkbox OnClick event."
No, I hadn't included the event on the object.
"Make sure CheatPanel_CECheckbox6 is an accessible object to your checkbox. "
I'm not sure what you mean?
"Make sure you click Execute script on the Cheat Table Lua Script."
The rest of the code all worked(s) in the code table.
Code: |
function CECheckbox6Click(sender)
boxstate = checkbox_getState(CheatPanel_CECheckbox6)
if boxstate == cbChecked then
timer_setEnabled(tChocoRace, true)
local AL = getAddressList()
cNo1curspeedaddress = addresslist_getMemoryRecordByDescription(AL, "Choco 1 In Race Cur Speed")
cNo1maxspeedaddress = addresslist_getMemoryRecordByDescription(AL, "Choco 1 In Race Max Speed")
cNo1maxsprintaddress = addresslist_getMemoryRecordByDescription(AL, "Choco 1 In Race Max Sprint")
cNo1curstamaddress = addresslist_getMemoryRecordByDescription(AL, "Choco 1 In Race Cur Stamina")
cNo1maxstamaddress = addresslist_getMemoryRecordByDescription(AL, "Choco 1 In Race Max Stamina")
cNo2curspeedaddress = addresslist_getMemoryRecordByDescription(AL, "Choco 2 In Race Cur Speed")
cNo2maxspeedaddress = addresslist_getMemoryRecordByDescription(AL, "Choco 2 In Race Max Speed")
cNo2maxsprintaddress = addresslist_getMemoryRecordByDescription(AL, "Choco 2 In Race Max Sprint")
cNo2curstamaddress = addresslist_getMemoryRecordByDescription(AL, "Choco 2 In Race Cur Stamina")
cNo2maxstamaddress = addresslist_getMemoryRecordByDescription(AL, "Choco 2 In Race Max Stamina")
cNo1maxsprint = memoryrecord_getValue(AL, cNo1maxsprintaddress)
print(cNo1maxsprintaddress)
print(cNo1maxsprint)
cNo1curspeed = memoryrecord_setValue(cNo1curspeedaddress,cNo1maxsprint)
cNo1maxstam = memoryrecord_getValue(AL, cNo1maxstamaddress)
cNo1curstam = memoryrecord_setValue(cNo1curstamaddress, cNo1maxstam)
cNo2curspeed = memoryrecord_getValue(cNo2curspeedaddress)
cNo2curspeed = memoryrecord_setValue(cNo2curspeedaddress,cNo1curspeed*.25)
cNo2maxstam = memoryrecord_getValue(AL, cNo1maxstam*.25)
print("Choco 1 winner is enabled")
else
timer_setEnabled(tChocoRace, false)
print("Choco 1 winner is not enabled")
end
end |
I had errors in the code that have been corrected and added a couple of print statements.
The first print statement works 16515BB0
The second print statement prints a blank line(assume this means nil)
So then what am I still missing?
|
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sun Aug 07, 2016 11:09 am Post subject: |
|
|
@DarkByte: Screw backwards compatibility, remove these functions from the library!
memoryrecord_getValue only accepts a single parameter: the memory record. Remove the "AL" parameters.
Code: | memoryrecord_getValue(AL, cNo1maxsprintaddress)
...
memoryrecord_getValue(cNo1maxsprintaddress) |
You should just be using:
Code: | cNo1maxsprintaddress = AL.getMemoryRecordByDescription("Choco 1 In Race Max Sprint")
print(cNo1maxsprintaddress.Value) |
|
|
Back to top |
|
|
bknight2602 Grandmaster Cheater Reputation: 0
Joined: 08 Oct 2012 Posts: 577
|
Posted: Sun Aug 07, 2016 11:22 am Post subject: |
|
|
Zanzer wrote: | @DarkByte: Screw backwards compatibility, remove these functions from the library!
memoryrecord_getValue only accepts a single parameter: the memory record. Remove the "AL" parameters.
Code: | memoryrecord_getValue(AL, cNo1maxsprintaddress)
...
memoryrecord_getValue(cNo1maxsprintaddress) |
|
If this is true then other statements in the whole code would not work, and that is not the case i.e.
Code: | maxhp1address = addresslist_getMemoryRecordByDescription(addresslist, "Hero Max Hit Pts (+h37)")
maxhp1 = memoryrecord_getValue(maxhp1address) |
these and many more like it do work and don't give errors. I'm not arguing with you just stating what does/n't work in my example.
Quote: |
You should just be using:
Code: | cNo1maxsprintaddress = AL.getMemoryRecordByDescription("Choco 1 In Race Max Sprint")
print(cNo1maxsprintaddress.Value) |
|
I can accept your suggestion, but that would entail editing about 2800 lines of code, that mostly works, not the ones I'm asking, but the remainder.
Also it would include me trying to decipher what was to what is, to prevent any other errors. You were correct in the "backwards compatibility". All this code was worked out in 6.2 and running 6.3
|
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sun Aug 07, 2016 11:55 am Post subject: |
|
|
bknight2602 wrote: | If this is true then other statements in the whole code would not work, and that is not the case i.e.
Code: | maxhp1address = addresslist_getMemoryRecordByDescription(addresslist, "Hero Max Hit Pts (+h37)")
maxhp1 = memoryrecord_getValue(maxhp1address) |
|
This is coded correctly. Notice how memoryrecord_getValue only contains one argument?
|
|
Back to top |
|
|
bknight2602 Grandmaster Cheater Reputation: 0
Joined: 08 Oct 2012 Posts: 577
|
Posted: Sun Aug 07, 2016 12:06 pm Post subject: |
|
|
Zanzer wrote: | bknight2602 wrote: | If this is true then other statements in the whole code would not work, and that is not the case i.e.
Code: | maxhp1address = addresslist_getMemoryRecordByDescription(addresslist, "Hero Max Hit Pts (+h37)")
maxhp1 = memoryrecord_getValue(maxhp1address) |
|
This is coded correctly. Notice how memoryrecord_getValue only contains one argument? |
No coded exactly identical, but addresslist was used instead of AL
Code: | local adresslist = getAddressList() |
Note the comma after addresslist.
Code: | maxhp1address = addresslist_getMemoryRecordByDescription(addresslist, "Hero Max Hit Pts (+h37)") |
Currently changing my code to what you had suggested, I'll post an edit after I finish.
EDIT:
Code: |
function CECheckbox6Click(sender)
boxstate = checkbox_getState(CheatPanel_CECheckbox6)
if boxstate == cbChecked then
timer_setEnabled(tChocoRace, true)
local AL = getAddressList()
cNo1curspeedaddress = AL.getMemoryRecordByDescription("Choco 1 In Race Cur Speed")
cNo1maxsprintaddress = AL.getMemoryRecordByDescription("Choco 1 In Race Max Sprint")
cNo1curstamaddress = AL.getMemoryRecordByDescription("Choco 1 In Race Cur Stamina")
cNo1maxstamaddress = AL.getMemoryRecordByDescription("Choco 1 In Race Max Stamina")
cNo2curspeedaddress = AL.getMemoryRecordByDescription("Choco 2 In Race Cur Speed")
cNo2maxspeedaddress = AL.getMemoryRecordByDescription("Choco 2 In Race Max Speed")
cNo2maxsprintaddress = AL.getMemoryRecordByDescription("Choco 2 In Race Max Sprint")
cNo2curstamaddress = AL.getMemoryRecordByDescription("Choco 2 In Race Cur Stamina")
cNo2maxstamaddress = AL.getMemoryRecordByDescription("Choco 2 In Race Max Stamina")
cNo1maxsprint = memoryrecord_getValue(cNo1maxsprintaddress)
cNo1curspeed = memoryrecord_setValue(cNo1curspeedaddress, tonumber(cNo1maxsprint))
cNo1maxstam = memoryrecord_getValue(cNo2maxstamaddress)
cNo1curstam = memoryrecord_setValue(cNo1curstamaddress, tonumber(cNo1maxstam))
cNo2curspeed = memoryrecord_setValue(cNo2curspeedaddress,tonumber(cNo1curspeed)*.25)
cNo2maxstam = memoryrecord_getValue(tonumber(cNo1maxstam)*.25)
print("Choco 1 winner is enabled")
else
timer_setEnabled(tChocoRace, false)
print("Choco 1 winner is not enabled")
end
end
|
When the check box is check I get an error message:
999: attempt to perform arithmetic on a nil value
This is line 999
cNo2curspeed = memoryrecord_setValue(cNo2curspeedaddress,tonumber(cNo1curspeed)*.25)
Last edited by bknight2602 on Sun Aug 07, 2016 12:26 pm; edited 1 time in total |
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sun Aug 07, 2016 12:15 pm Post subject: |
|
|
You're comparing the wrong function. I said memoryrecord_getValue.
Yours vs Theirs: Code: | cNo1maxsprint = memoryrecord_getValue(AL , cNo1maxsprintaddress) -- yours
maxhp1 = memoryrecord_getValue(maxhp1address ) -- theirs |
Wrong vs Right: Code: | cNo1maxsprint = memoryrecord_getValue(AL, cNo1maxsprintaddress) -- wrong
cNo1maxsprint = memoryrecord_getValue(cNo1maxsprintaddress) -- right |
|
|
Back to top |
|
|
bknight2602 Grandmaster Cheater Reputation: 0
Joined: 08 Oct 2012 Posts: 577
|
Posted: Sun Aug 07, 2016 12:38 pm Post subject: |
|
|
See my edited code and results above.
|
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sun Aug 07, 2016 8:26 pm Post subject: |
|
|
memoryrecord_SetValue doesn't return anything, of course it's nil. Code: | cNo1curspeed = memoryrecord_SetValue(cNo1curspeedaddress,cNo1maxsprint) |
|
|
Back to top |
|
|
bknight2602 Grandmaster Cheater Reputation: 0
Joined: 08 Oct 2012 Posts: 577
|
Posted: Sun Aug 07, 2016 10:35 pm Post subject: |
|
|
Zanzer wrote: | memoryrecord_SetValue doesn't return anything, of course it's nil. Code: | cNo1curspeed = memoryrecord_SetValue(cNo1curspeedaddress,cNo1maxsprint) |
|
Thanks, but that is not the error line
This line is where the error is occurring.
Code: | cNo2curspeed = memoryrecord_setValue(cNo2curspeedaddress,tonumber(cNo1curspeed)*.25) |
Here is the error:
999: attempt to perform arithmetic on a nil value
The one you posted seems to work, as there are no errors noted on that line.
|
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sun Aug 07, 2016 10:57 pm Post subject: |
|
|
Maybe someone else can take a crack at explaining this to him. I'm out.
|
|
Back to top |
|
|
cooleko Grandmaster Cheater Reputation: 11
Joined: 04 May 2016 Posts: 717
|
Posted: Mon Aug 08, 2016 12:56 am Post subject: |
|
|
bknight2602 wrote: | Zanzer wrote: | memoryrecord_SetValue doesn't return anything, of course it's nil. Code: | cNo1curspeed = memoryrecord_SetValue(cNo1curspeedaddress,cNo1maxsprint) |
|
Thanks, but that is not the error line
This line is where the error is occurring.
cNo2curspeed = memoryrecord_setValue(cNo2curspeedaddress,tonumber(cNo1curspeed)*.25)
Here is the error:
999: attempt to perform arithmetic on a nil value
The one you posted seems to work, as there are no errors noted on that line. |
Stop ignoring the advice. Your error is because of it. Fix your think.
Quote: | memoryrecord_SetValue doesn't return anything, of course it's nil. |
One more time, because your think has a kink:
memoryrecord_setValue() DOESNT RETURN VALUES
You set cNo1curspeed EQUAL to memoryrecord_setValue() which DOESNT RETURN VALUES
You then attempt to perform math on cNo1curspeed, which doesnt exist (aka nil), because memoryrecord_setValue() DOESNT RETURN VALUES.
|
|
Back to top |
|
|
bknight2602 Grandmaster Cheater Reputation: 0
Joined: 08 Oct 2012 Posts: 577
|
Posted: Mon Aug 08, 2016 6:45 am Post subject: |
|
|
This statement sets a value for a variable cNo1curspeed
Code: | cNo1curspeed = memoryrecord_setValue(cNo1curspeedaddress, tonumber(cNo1maxsprint)) |
Does it not?
I'm not understanding what both of you seem to understand so easily.
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 138
Joined: 06 Jul 2014 Posts: 4275
|
|
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
|
|