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 


Specified lua script

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

Joined: 02 Feb 2020
Posts: 2

PostPosted: Sun Feb 02, 2020 1:13 pm    Post subject: Specified lua script Reply with quote

Hi,
Can somebody help me with lua script that will auto set some values when they will restart or will not be set to the right values?

Here is how it looks in cheat engine:
first photo

Only thing i want to change in last one Value(this one with two queston marks). By default it is 100 I'm setting it to 1000 and after some time it gets back to 100.

Here is how adress looks like:
second photo



pFWXmv8.png
 Description:
 Filesize:  3.23 KB
 Viewed:  2466 Time(s)

pFWXmv8.png



RqNEjSI.png
 Description:
 Filesize:  17.06 KB
 Viewed:  2466 Time(s)

RqNEjSI.png


Back to top
View user's profile Send private message
daspamer
Grandmaster Cheater Supreme
Reputation: 54

Joined: 13 Sep 2011
Posts: 1588

PostPosted: Sun Feb 02, 2020 11:31 pm    Post subject: Reply with quote

so if I got it right you want to set the value to 100 as soon as it has became a valid address? (like not ??).

Code:
healthUpdate = healthUpdate or createTimer();
healthUpdate.interval = 200; --check every 0.2 sec
healthUpdate.tag = 0; -- we use this to tell if the address is '??' or not;

healthRecord = getAddressList().getMemoryRecordByDescription('Health'); -- get the memoryRecord

healthUpdate.onTimer = function(sender)
   if (healthRecord.value == '??') then -- check if we should update it as soon as it is available;
      sender.tag = 1;
   end
   if (sender.tag == 1 and healthRecord.Value ~= '??') then -- if we detected that it was invalid and now its value is valid;
      sender.tag = 0;   -- wait for the next time 'Health' memory record becomes '??'
      healthRecord.Value = 1000;
      print('updated health value..');
   end
end


or do you wish to set the value constantly to 1000?
Code:
healthUpdate = healthUpdate or createTimer();
healthUpdate.interval = 200; --check every 0.2 sec

healthRecord = getAddressList().getMemoryRecordByDescription('Health'); -- get the memoryRecord

healthUpdate.onTimer = function(sender)
   local value = healthRecord.value
   if (tonumber(value) and tonumber(value) ~= 1000)) then -- try to cast it to number and check if it has changed from default value;
      healthRecord.Value = 1000;
      print('updated health value..');
   end
end

_________________
I'm rusty and getting older, help me re-learn lua.
Back to top
View user's profile Send private message Visit poster's website
pawleq
How do I cheat?
Reputation: 0

Joined: 02 Feb 2020
Posts: 2

PostPosted: Mon Feb 03, 2020 10:32 am    Post subject: Reply with quote

Thanks, thats what i were looking for. It is working fine.
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