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 


Issue with AoB values and If statements.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
MikeNoey
Advanced Cheater
Reputation: 0

Joined: 08 Jun 2018
Posts: 64

PostPosted: Mon Oct 28, 2019 1:09 pm    Post subject: Issue with AoB values and If statements. Reply with quote

Code:
local AoB = AOBScan("14 00 00 13 00 22 00 00 01 41 01 00 00 00 00 00 00")
if (AoB == nil or AoB.Count > 40) then -- Ends function earlier if the AoB was not found, or if multiply aobs were found.
   return
end



if (AoB.count > 0) then
local ArrowRange1 = AoB[0]
end
if (AoB.Count > 1) then
local ArrowRange2 = AoB[1]
end
if (AoB.Count > 2) then
local ArrowRange3 = AoB[2]
end
if (AoB.Count > 3) then
local ArrowRange4 = AoB[3]
end



writeBytes(ArrowRange1,40)
writeBytes(ArrowRange2,40)
writeBytes(ArrowRange3,40)
writeBytes(ArrowRange4,40)




I cannot figure out what I am doing wrong here. When I execute the script the values aren't writing to the first 4 results from the AOB scan. If I try to print "ArrowRange1" inside the IF statement the address prints but if I try to print it outside of the IF statement nothing is printed. Same thing with all 4 of them. I'd love to know what I am doing wrong here. it's annoying me

Also if anyone has a better way of writing this script I'd like to learn it. The reason I had to put these within IF statements is because the script wont run if there are less results than anticipated. For example if the scan only finds 3 addresses then the script wont work because Im trying to assign AoB[3] to ArrowRange4. Thank you Smile))
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4297

PostPosted: Tue Oct 29, 2019 9:52 am    Post subject: Reply with quote

"local" means local to the current scope. You're also not destroying the result.
Code:
local res = AOBScan("14 00 00 13 00 22 00 00 01 41 01 00 00 00 00 00 00")
if not res then return end

if res.Count <= 40 then
  for i = 0, math.min(res.Count-1, 3), 1 do
    writeBytes(res[i], 40)
  end
end

res.destroy()

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
MikeNoey
Advanced Cheater
Reputation: 0

Joined: 08 Jun 2018
Posts: 64

PostPosted: Tue Oct 29, 2019 11:25 am    Post subject: Reply with quote

I see Parkour. Thank you.
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