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 


help with reading values

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
bakewell66
How do I cheat?
Reputation: 0

Joined: 16 May 2018
Posts: 1

PostPosted: Wed May 16, 2018 8:42 am    Post subject: help with reading values Reply with quote

Hi there,
I have been trying to write a simple script that reads values from addresses and run code from that

This is my code:

Code:

PlayerZ = readFloat("[\"PROGRAM.exe\" + 005CA8AC] + 11C");
PlayerX = readFloat("[\"PROGRAM.exe\" + 005CA8AC] + 114");
MenuNum = readInteger("[\"PROGRAM.exe\" + 007A0B68] + 31C");


  if (MenuNum == 0) then
     --bla
  end

  if (PlayerZ == 400) then
     --bla
  end


This works but I want it to constantly check, and run if the if statement is true, instead of only running once. Any help would be appreciated.
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Wed May 16, 2018 8:55 pm    Post subject: Reply with quote

copy paste with minor tweaks from https://forum.cheatengine.org/viewtopic.php?p=5738881#5738881 cause I'm tired right now Smile

Code:
function CheckHealth(t)
  local al=getAddressList()
  local memrec=al.getMemoryRecordByDescription("health")
   if memrec~=nil then
    if tonumber(memrec.Value) ~= 0 then
      -- do whatever
    end
  end
end

-- ActivateTimer
  local t=createTimer(nil)
  t.OnTimer=CheckHealth
  t.Interval=1000 --every 1 second
  t.Enabled=true

_________________
https://github.com/FreeER/ has a few CE related repos
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