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 


Changing Value by +1 every second

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

Joined: 24 Jul 2020
Posts: 13

PostPosted: Fri Jul 24, 2020 1:55 am    Post subject: Changing Value by +1 every second Reply with quote

So how would I be able to change a vlaue by +1 every second or +2 every second in aa script

[enable]
{$LUA}
memrec = getAddressList().getMemoryRecordByDescription
memrec('ItemType').Value = "555"
memrec('ItemType').Active = true
{$ASM}

So the value 555 is added by 2 every second or added by 1

_________________
Something is off about me..
Back to top
View user's profile Send private message
Csimbi
I post too much
Reputation: 97

Joined: 14 Jul 2007
Posts: 3326

PostPosted: Fri Jul 24, 2020 2:53 am    Post subject: Reply with quote

Add a Timer with 1000ms delay that does the +1 increment.
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1532

PostPosted: Fri Jul 24, 2020 6:21 am    Post subject: Reply with quote

Here is an example you can develop;
https://forum.cheatengine.org/viewtopic.php?p=5744760#5744760

Name1 = Hack Decription name
sec = Timer seconds. For 1 second = 1000

Code:
--You can add the code below to your hack.
[enable]
{$LUA}
function ExpHack(Name1, sec)
local oldv1 = AddressList.getMemoryRecordByDescription(Name1).Value
oldv1 = tonumber(oldv1)

local t = createTimer() t.Enabled=true
t.Interval = tonumber(sec)
t.OnTimer = function(t)
local mr = AddressList.getMemoryRecordByDescription(Name1)
  if not oldv1 then t.destroy(); return end
local v1 = tonumber(mr.Value)
    oldv1 = oldv1 + 2
    mr.Value = tostring(oldv1)
 --print(oldv1)
-- Set a limit if you want to kill the timer.
-- if oldv1 == 600 then t.destroy(); end
end
end

memrec = getAddressList().getMemoryRecordByDescription
memrec('ItemType').Value = "555"
memrec('ItemType').Active = true
if memrec('ItemType').Value == "555" then

ExpHack("My Experience", "1000") end
{$ASM}


And these encodings are open to editing.
Can be used with Lua Script.

EDIT ;

You can make the following changes to determine the increase independently;

Code:
function ExpHack(Name1, sec, plus)

plus = tonumber(plus)

    oldv1 = oldv1 + plus


ExpHack("My Experience", "1000", "1")

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
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