| View previous topic :: View next topic |
| Author |
Message |
Bit Byte Advanced Cheater
Reputation: 0
Joined: 28 Nov 2022 Posts: 62
|
Posted: Tue Aug 01, 2023 11:40 am Post subject: Help with error handling when address is not available |
|
|
I have script in cheat engine lua that gives error.
let me explain:
This address in the game is created only when my cursor is on an entity body, probably created on the fly and the address gets deleted when I move my cursor away from the entity body.
| Code: | | local EntityAtCursorBody= getAddress('[[[[[[[[game.exe+1CBBA78]+308]+8]+160]+0]+78]+0]+38]+40') |
Now in my lua script while my cursor is on the entity body and I have my right mouse button down some code is executed which works because since the cursor is on the entity the address given above is present
But when my cursor is not on the entity body and I click or have my right mouse button down it gives me error:
| Code: | Error:Failure determining what [[[[[[[[game.exe+1CBBA78]+308]+8]+160]+0]+78]+0]+38]+40 means
|
This is because as I have said before the address is deleted when I move my cursor away from the entity body.
How do I skip or rectify this error?
|
|
| Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4724
|
Posted: Tue Aug 01, 2023 12:09 pm Post subject: |
|
|
Use `getAddressSafe`, check for nil
| Code: | local addr = getAddressSafe(...)
if not addr then
-- pointer path is not valid: do something, e.g. exit early
return
end
... |
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
| Back to top |
|
 |
gibberishh Cheater
Reputation: 1
Joined: 30 Aug 2021 Posts: 45
|
Posted: Thu Aug 03, 2023 10:03 pm Post subject: |
|
|
I've done this for one of my tables. It checks whether an address exists (the game generates dynamic code), handles errors, displays a helpful message to the user on error, and prevents loading of the rest of the script. If no error, it continues executing the code.
The checking/error handling is done in Lua, the rest of the script is ASM.
Get the table from https://fearlessrevolution.com/viewtopic.php?p=294663#p294663
Will help if you have the game but you should be able to work it out by just reading the code too.
_________________
It's not cheating. It's playing by my rules. |
|
| Back to top |
|
 |
Bit Byte Advanced Cheater
Reputation: 0
Joined: 28 Nov 2022 Posts: 62
|
Posted: Mon Aug 07, 2023 1:47 pm Post subject: |
|
|
Sorry for the late Reply
So for each address or pointer not found in my script I would have to do that for each?
Isn't there any simpler one liner code to completely turnoff error checking & logging, just ignore if not found and move on to execute the next line
Its simple - I dont want errors checked or logged, Ignore/Skip and continue executing the next code even if it comes across any errors.
There are a lot of pointers to addresses that are dynamically created in the game.
|
|
| Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4724
|
Posted: Mon Aug 07, 2023 2:29 pm Post subject: |
|
|
You're just going to move the error elsewhere...
| Code: | -- no error checking
local address = getAddressSafe'...'
-- error now happens here: attempt to perform arithmetic on nil
print(address + 8) |
Perhaps there's a better way you could structure your code.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
| Back to top |
|
 |
Bit Byte Advanced Cheater
Reputation: 0
Joined: 28 Nov 2022 Posts: 62
|
Posted: Sat Aug 12, 2023 4:19 am Post subject: |
|
|
Thank you for the help
I think i now got past the errors. I used your info like this:
| Code: | local Address = getAddressSafe(...)
if Address ~= nil then
-- execute code
end |
|
|
| Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4724
|
Posted: Sat Aug 12, 2023 11:23 am Post subject: |
|
|
`~= nil` is superfluous. Normally you'd just do this:
| Code: | local Address = getAddressSafe(...)
if Address then
...
end |
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
| Back to top |
|
 |
|