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 


lua timer (AutoWrite value)

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

Joined: 21 Feb 2019
Posts: 21

PostPosted: Sat Aug 03, 2019 2:36 am    Post subject: lua timer (AutoWrite value) Reply with quote

Hi
i find This script made by Tim(thx) and i want to do some modifications on it
Code:

{$lua}
------------------------------ ENABLE ------------------------------
[ENABLE]
DoneState = false
local addr = 0x12345678
local val = 1
local function timer_tick(timer)
local v = readInterer(addr) -- read value
   if v < 100 then -- check value
      writeInteger(addr, val + v) -- write value
   else
      DoneState = true -- this stops the timer, if value if > 100
   end
   if DoneState == true then
      timer.destroy()
   end
end

if syntaxcheck then return end
local someTimer = createTimer(MainForm)
someTimer.Interval = 3000
someTimer.OnTimer = timer_tick
------------------------------ DISABLE ------------------------------
[DISABLE]
if syntaxcheck then return end
DoneState = true -- this stops the timer, when the script is disabled


i don't want the timer to stop at 100 , I want when it reach 100 to set the value to 0 then start again Increasing

i want it loop like this with no stop until i disabled the script

Thanks for your help


Last edited by SS 4K on Sun Aug 04, 2019 6:02 am; edited 2 times in total
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Sat Aug 03, 2019 7:56 am    Post subject: Reply with quote

Then change where it sets the DoneState from eg.
Code:
else
DoneState = true -- this stops the timer, if value if > 100
to
Code:
else
writeInteger(addr, 0) -- write 0

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

Joined: 21 Feb 2019
Posts: 21

PostPosted: Sun Aug 04, 2019 5:21 am    Post subject: Reply with quote

FreeER wrote:
Then change where it sets the DoneState from eg.
Code:
else
DoneState = true -- this stops the timer, if value if > 100
to
Code:
else
writeInteger(addr, 0) -- write 0


Ty FreeER

work perfect

One last thing , if only want to check the address value without increasing

I change this

Code:
local val = 1


to

Code:
local val = 0


is this The proper way ?
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Sun Aug 04, 2019 9:24 am    Post subject: Reply with quote

well you'd be better off changing it to not call the writeInteger function if you don't want to change it, since lua isn't running as part of the game it is possible for the value to be changed between the time lua reads the value and writes it, which would change it back to the value that was read. This can happen with +1 as well but there's not really a good way around it if you do want to write, but if you don't want to change it then you just don't call anything that could change it.

But yeah, changing val to 0 would basically cause it to add 0 which is a no op and write the same value back to memory.

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

Joined: 21 Feb 2019
Posts: 21

PostPosted: Sun Aug 04, 2019 4:36 pm    Post subject: Reply with quote

FreeER wrote:
well you'd be better off changing it to not call the writeInteger function if you don't want to change it, since lua isn't running as part of the game it is possible for the value to be changed between the time lua reads the value and writes it, which would change it back to the value that was read. This can happen with +1 as well but there's not really a good way around it if you do want to write, but if you don't want to change it then you just don't call anything that could change it.

But yeah, changing val to 0 would basically cause it to add 0 which is a no op and write the same value back to memory.


Ty FreeER

that helpful info
Back to top
View user's profile Send private message
SS 4K
Newbie cheater
Reputation: 0

Joined: 21 Feb 2019
Posts: 21

PostPosted: Mon Aug 05, 2019 7:06 am    Post subject: Reply with quote

FreeER wrote:
well you'd be better off changing it to not call the writeInteger function if you don't want to change it, since lua isn't running as part of the game it is possible for the value to be changed between the time lua reads the value and writes it, which would change it back to the value that was read. This can happen with +1 as well but there's not really a good way around it if you do want to write, but if you don't want to change it then you just don't call anything that could change it.

But yeah, changing val to 0 would basically cause it to add 0 which is a no op and write the same value back to memory.


i know the address required to be in lua format 0x1324567 , but can i use something like this

Code:
local addr = [myplayer]+12


if not then please modify it or add another script that can do like this
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Mon Aug 05, 2019 8:15 am    Post subject: Reply with quote

you can use local addr = '[myplayer]+12', lua itself doesn't know anything about reading memory from other programs so can't use pointers but nearly all the functions CE provides works with strings and will accept anything you can put into the address list as an address.

If you want to do math with the address (perhaps an array) then you can use getAddress('[myplayer]+12') to get CE to return the address as a number or getAddressSafe if you're worried about a pointer in the chain being 0 and don't want getAddress to raise an error (but instead return... 0 iirc)

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

Joined: 21 Feb 2019
Posts: 21

PostPosted: Tue Aug 06, 2019 8:55 am    Post subject: Reply with quote

FreeER wrote:
you can use local addr = '[myplayer]+12', lua itself doesn't know anything about reading memory from other programs so can't use pointers but nearly all the functions CE provides works with strings and will accept anything you can put into the address list as an address.

If you want to do math with the address (perhaps an array) then you can use getAddress('[myplayer]+12') to get CE to return the address as a number or getAddressSafe if you're worried about a pointer in the chain being 0 and don't want getAddress to raise an error (but instead return... 0 iirc)


Ty FreeER

I Tested

Code:
local addr = '[myplayer]+12'

Code:
getAddress('[myplayer]+12')

Code:
getAddressSafe('[myplayer]+12')


all them work perfect


also is the < mean Less than ? i see its doing the opposite
Code:
if v < 100 then
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Tue Aug 06, 2019 9:42 am    Post subject: Reply with quote

yeah < means less than, so the code in the if statement would only run if the value of the v variable is less than 100
_________________
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