 |
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: 586
|
Posted: Sun Sep 03, 2023 5:10 am Post subject: Display values in text boxes |
|
|
I'm modifying an old game with old code.
Manually I have added 8 text boxes to a panel. Then I added a timer and a function in the code.
Code: |
td = createTimer(nil)
td.Interval = 500
td.onTimer = function(DisplayEnemy)
td.Enabled = true
--print("entered td timer")
end--function(Display)
|
Note the when the print command is not commented, prints so I know the timer works.
Further down in the code I have
Code: |
function DisplayEnemy(sender)
...find values for the text boxes
...Finding the values works as I can enter the code finding the values and printing them in the debug window. However the print command at the end of code never prints so the function is not entered.
control_setCaption(CheatPanel_CEEdit3,enemy1curhp)
control_setCaption(CheatPanel_CEEdit4,enemy2curhp)
control_setCaption(CheatPanel_CEEdit5,enemy3curhp)
control_setCaption(CheatPanel_CEEdit6,enemy4curhp)
control_setCaption(CheatPanel_CEEdit7,enemy5curhp)
control_setCaption(CheatPanel_CEEdit8,enemy6curhp)
control_setCaption(CheatPanel_CEEdit9,enemy7curhp)
control_setCaption(CheatPanel_CEEdit10,enemy8curhp)
print("display edits running")
end--function DisplayEnemy(sender)
|
The timer works but the function DisplayEnemy doesn't work. How may I change the existing code to make the DisplayEnemy function work?
|
|
Back to top |
|
 |
LeFiXER Grandmaster Cheater Supreme
Reputation: 20
Joined: 02 Sep 2011 Posts: 1069 Location: 0x90
|
Posted: Sun Sep 03, 2023 6:25 am Post subject: Re: Display values in text boxes |
|
|
bknight2602 wrote: | I'm modifying an old game with old code.
Manually I have added 8 text boxes to a panel. Then I added a timer and a function in the code.
Code: |
td = createTimer(nil)
td.Interval = 500
td.onTimer = function(DisplayEnemy)
td.Enabled = true
--print("entered td timer")
end--function(Display)
|
Note the when the print command is not commented, prints so I know the timer works.
Further down in the code I have
Code: |
function DisplayEnemy(sender)
...find values for the text boxes
...Finding the values works as I can enter the code finding the values and printing them in the debug window. However the print command at the end of code never prints so the function is not entered.
control_setCaption(CheatPanel_CEEdit3,enemy1curhp)
control_setCaption(CheatPanel_CEEdit4,enemy2curhp)
control_setCaption(CheatPanel_CEEdit5,enemy3curhp)
control_setCaption(CheatPanel_CEEdit6,enemy4curhp)
control_setCaption(CheatPanel_CEEdit7,enemy5curhp)
control_setCaption(CheatPanel_CEEdit8,enemy6curhp)
control_setCaption(CheatPanel_CEEdit9,enemy7curhp)
control_setCaption(CheatPanel_CEEdit10,enemy8curhp)
print("display edits running")
end--function DisplayEnemy(sender)
|
The timer works but the function DisplayEnemy doesn't work. How may I change the existing code to make the DisplayEnemy function work? |
Code: |
function DisplayEnemy() -- No need for sender here, since you're not passing any information back to the function that called this one.
control_setCaption(CheatPanel_CEEdit3, enemy1curhp)
control_setCaption(CheatPanel_CEEdit4, enemy2curhp)
control_setCaption(CheatPanel_CEEdit5, enemy3curhp)
control_setCaption(CheatPanel_CEEdit6, enemy4curhp)
control_setCaption(CheatPanel_CEEdit7, enemy5curhp)
control_setCaption(CheatPanel_CEEdit8, enemy6curhp)
control_setCaption(CheatPanel_CEEdit9, enemy7curhp)
control_setCaption(CheatPanel_CEEdit10, enemy8curhp)
print("display edits running")
end
td = createTimer() -- Also, no need to set the parent to nil
td.Interval = 500
td.onTimer = DisplayEnemy -- function must be declared before it is used. Lua is interpreted in a linear fashion i.e.: line-by-line from top-to-bottom
-- No need to set td.Enabled = true, it's true by default.
|
|
|
Back to top |
|
 |
bknight2602 Grandmaster Cheater
Reputation: 0
Joined: 08 Oct 2012 Posts: 586
|
Posted: Sun Sep 03, 2023 7:33 am Post subject: |
|
|
Man this is one aspect I've told before, but thanks for the refresher. After moving the timer, saving and reopening the table everything works well.
|
|
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
|
|