Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Pointer address value

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Johnden
Newbie cheater
Reputation: 0

Joined: 30 Jan 2018
Posts: 22

PostPosted: Sat Feb 17, 2018 9:30 am    Post subject: Pointer address value Reply with quote

When a pointer address can't find any dynamic address or isn't in use, it displays value=??
Is it possible to detect this value using If Statement?
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater
Reputation: 31

Joined: 09 Aug 2013
Posts: 760

PostPosted: Sat Feb 17, 2018 10:23 am    Post subject: Reply with quote

The Value property is a string so you can just compare with
if ...Value = '??' then ... end

The CurrentAddress property will also be 0 and the AddressString will be 'P->????????' (this will not be true for static addresses that aren't pointers however, their AddressString will be the same as their Address property but with ()s around it).

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
Johnden
Newbie cheater
Reputation: 0

Joined: 30 Jan 2018
Posts: 22

PostPosted: Sat Feb 17, 2018 10:43 am    Post subject: Reply with quote

I tried it in this code but it remained still in false
Code:

function CETimer47Timer(sender)
local memrec=getAddressList().getMemoryRecordByDescription("Achievement12")

if tonumber(memrec.value)>=15 then
   CETrainer_CEImage12.Visible=false
elseif tonumber(memrec.value)=='??' then
       CETrainer_CEImage12.Visible=true
else CETrainer_CEImage12.Visible=true
end
end
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 14

Joined: 24 Feb 2017
Posts: 441
Location: 'Merica

PostPosted: Sat Feb 17, 2018 11:43 am    Post subject: Reply with quote

Johnden wrote:
I tried it in this code but it remained still in false
Code:

function CETimer47Timer(sender)
local memrec=getAddressList().getMemoryRecordByDescription("Achievement12")

if tonumber(memrec.value)>=15 then
   CETrainer_CEImage12.Visible=false
elseif tonumber(memrec.value)=='??' then
       CETrainer_CEImage12.Visible=true
else CETrainer_CEImage12.Visible=true
end
end


You're comparing a string and a number, that's why it's false. Any number will never equal a string value of '??'.

Try "if memrec.value == '??' then"

_________________
Back to top
View user's profile Send private message
Johnden
Newbie cheater
Reputation: 0

Joined: 30 Jan 2018
Posts: 22

PostPosted: Sat Feb 17, 2018 12:04 pm    Post subject: Reply with quote

Weird that this works:
Code:

if memrec.value=="??" then
   CETrainer_CEImage12.Visible=true
elseif tonumber(memrec.value)>=15 then
       CETrainer_CEImage12.Visible=false
else CETrainer_CEImage12.Visible=true
end

But this doesn't:
Code:

if tonumber(memrec.value)>=15 then
   CETrainer_CEImage12.Visible=false
elseif memrec.value=="??" then
       CETrainer_CEImage12.Visible=true
else CETrainer_CEImage12.Visible=true
end

Either way Thank You!
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 14

Joined: 24 Feb 2017
Posts: 441
Location: 'Merica

PostPosted: Sat Feb 17, 2018 12:26 pm    Post subject: Reply with quote

Johnden wrote:
Weird that this works:
Code:

if memrec.value=="??" then
   CETrainer_CEImage12.Visible=true
elseif tonumber(memrec.value)>=15 then
       CETrainer_CEImage12.Visible=false
else CETrainer_CEImage12.Visible=true
end

But this doesn't:
Code:

if tonumber(memrec.value)>=15 then
   CETrainer_CEImage12.Visible=false
elseif memrec.value=="??" then
       CETrainer_CEImage12.Visible=true
else CETrainer_CEImage12.Visible=true
end

Either way Thank You!


No it's not weird, that's what is expected. NIL doesn't equal any number.

Try "print(type(tonumber('??')))" in the Lua engine window to see that it's nil.

EDIT: Sorry, read it better, and yeah that's weird. You should be getting an error message about math with a nil value (on the second one).

_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites