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 


supervision a value and auto change it
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
!BEWARE!
!BEWARE! Deletes post on answer
Reputation: 0

Joined: 26 Jun 2013
Posts: 56
Location: !BEWARE!

PostPosted: Wed Sep 21, 2022 6:07 am    Post subject: supervision a value and auto change it Reply with quote

Hello
I need simple script (if possible not in lua) to supervision value in address.
Every time when value will change to 20, I wanna swap it to 100 automatically.
Address is Float type and value is display in this form -> XX.XXXXXXXX
All digits after dot are useless.
Also necessary there is hotkey to turn on & off script

_________________
!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Wed Sep 21, 2022 7:14 am    Post subject: Reply with quote

Why not lua?
Here is a script:
------------------
Edit the address in the code. (myAddress)
After activating the script, click the "F8" key to run or stop it. (or replace it).
------------------

Code:
[ENABLE]
{$lua}

if cycleTimer then cycleTimer.Destroy() cycleTimer=nil end
cycleTimer=createTimer() cycleTimer.Interval=100 cycleTimer.Enabled=false

myAddress = "0x0DE08BE8" --your address! ?

function checkValue()---
 if readFloat(myAddress)<21 then --"<" = If less than 20.. "==" = if 20..
  writeFloat(myAddress,100)
 --else
 --print(readFloat(myAddress))
 end
end

cycleTimer.OnTimer = checkValue

if ExitKey then ExitKey.Destroy() ExitKey=nil end
-- check open-close key (F8)
ExitKey = createHotkey((function()
                         sleep(200)
                          if cycleTimer.Enabled==false then
                           cycleTimer.Enabled=true
                          else
                           cycleTimer.Enabled=false
                          end
                         end), VK_F8)

{$asm}

[DISABLE]

{$lua}
if ExitKey then ExitKey.Destroy() ExitKey=nil end
if cycleTimer then cycleTimer.Destroy() cycleTimer=nil end

_________________
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
!BEWARE!
!BEWARE! Deletes post on answer
Reputation: 0

Joined: 26 Jun 2013
Posts: 56
Location: !BEWARE!

PostPosted: Wed Sep 21, 2022 8:14 am    Post subject: Reply with quote

because i have already put in another lua script, but ok let there be two.
Actually have problem with execute script, getting this prompt:

_________________
!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Wed Sep 21, 2022 9:20 am    Post subject: Reply with quote

Where are you using the code?
Cheat Table Lua Script?
Address List Script?
The code is set for the address list. Create an asm script, delete the contents and paste the existing code.

If you were to use it in a Lua table it would be:
Code:

if cycleTimer then cycleTimer.Destroy() cycleTimer=nil end
cycleTimer=createTimer() cycleTimer.Interval=100 cycleTimer.Enabled=false

myAddress = "0x0DE08BE8" --your address! ?

function checkValue()---
 if readFloat(myAddress)<21 then --"<" = If less than 20.. "==" = if 20..
  writeFloat(myAddress,100)
 --else
 --print(readFloat(myAddress))
 end
end

cycleTimer.OnTimer = checkValue

if ExitKey then ExitKey.Destroy() ExitKey=nil end
-- check open-close key (F8)
ExitKey = createHotkey((function()
                         sleep(200)
                          if cycleTimer.Enabled==false then
                           cycleTimer.Enabled=true
                          else
                           cycleTimer.Enabled=false
                          end
                         end), VK_F8)

_________________
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
!BEWARE!
!BEWARE! Deletes post on answer
Reputation: 0

Joined: 26 Jun 2013
Posts: 56
Location: !BEWARE!

PostPosted: Wed Sep 21, 2022 9:52 am    Post subject: Reply with quote

sorry, i thought you made first script to lua.
I put it to Auto Assemble but cant make it run.
Your second script in lua working fine.

Edit.
At this moment testing it in lua. I changed "<" to "==" but then script cant catch value. Probably because there are digits after dot.
I never get clean 20 value.
One time its 20.59763
Next time is 20.19385

_________________
!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
cooleko
Grandmaster Cheater
Reputation: 11

Joined: 04 May 2016
Posts: 717

PostPosted: Wed Sep 21, 2022 11:36 am    Post subject: Reply with quote

You could try:

https://wiki.cheatengine.org/index.php?title=Lua:dwordToByteTable
https://forum.cheatengine.org/viewtopic.php?t=619081&sid=344e8a1137276ed15804f578cde602d2

Your bytes would be:
0x00;
0x00;
0xA0;
0x41;

Or change your logic to > 20 and < 21

or the 100s of other ways to represent the logic for what you want to accomplish!
Back to top
View user's profile Send private message
!BEWARE!
!BEWARE! Deletes post on answer
Reputation: 0

Joined: 26 Jun 2013
Posts: 56
Location: !BEWARE!

PostPosted: Wed Sep 21, 2022 11:44 am    Post subject: Reply with quote

My address is 701527F8 and i put it as 0x701527F8
In lua its working, in auto assemble not.

_________________
!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!


Last edited by !BEWARE! on Wed Sep 21, 2022 11:53 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
cooleko
Grandmaster Cheater
Reputation: 11

Joined: 04 May 2016
Posts: 717

PostPosted: Wed Sep 21, 2022 11:52 am    Post subject: Reply with quote

That is fine, you still use the address, but you need to update the logic on what to do with it. You can convert it to bytes and compare the bytes or keep it as a float and compare the float twice.

Just store your float in a variable and use two logic checks in your code on the variable. If you don't mind reading twice, you can skip the variable but your value may change in between the two logic checks if you read twice.
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Wed Sep 21, 2022 4:46 pm    Post subject: Reply with quote

Code:
function checkValue()---
 if readFloat(myAddress)<21 then --"<" = If less than 20.. "==" = if 20..
  writeFloat(myAddress,100)
 --else
 --print(readFloat(myAddress))
 end
end


Change:

Code:
function checkValue()
 myValue = math.floor(readFloat(myAddress))
  if myValue == 20 then
  writeFloat(myAddress,100)
 --else
 --print(math.floor(readFloat(myAddress)))
 end
end

_________________
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
!BEWARE!
!BEWARE! Deletes post on answer
Reputation: 0

Joined: 26 Jun 2013
Posts: 56
Location: !BEWARE!

PostPosted: Thu Sep 22, 2022 8:32 am    Post subject: Reply with quote

@AylinCE - Thanks, its solved problem
@cooleko - So bytes from 701527F8 would be this? :
0x70
0x15
0x27
0xF8
I dont get how to put it to "myAddress". Sadly i dont understand programming language Crying or Very sad

_________________
!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
cooleko
Grandmaster Cheater
Reputation: 11

Joined: 04 May 2016
Posts: 717

PostPosted: Thu Sep 22, 2022 10:47 am    Post subject: Reply with quote

!BEWARE! wrote:
@AylinCE - Thanks, its solved problem
@cooleko - So bytes from 701527F8 would be this? :
0x70
0x15
0x27
0xF8
I dont get how to put it to "myAddress". Sadly i dont understand programming language :cry:


You wouldnt break up your address, that was for the floating point value. However, your breakdown from 4 bytes into a sequence of bytes is correct unless you are dealing with big-endian which reverses the order.

In our case, a floating point 20 is represented with the bytes provided above. I like this for getting byte values.

You can see that the value 20 is all values between 0x41A0 and 0x41A7, so you could detect the value 20 by ignoring the last 2 bytes of the mantissa and just comparing the first two.

I googled flooring a float in cheat engine which is how I got the link above telling someone to use bytes. Since CE now allows using math.floor, it is the better way of doing it!
Back to top
View user's profile Send private message
!BEWARE!
!BEWARE! Deletes post on answer
Reputation: 0

Joined: 26 Jun 2013
Posts: 56
Location: !BEWARE!

PostPosted: Sat Dec 17, 2022 5:37 am    Post subject: Reply with quote

Im using script in this form to till day, but need update.
-currently Numpad9 loop timer from 31 to 60
But need two additional keys:
-Numpad 7 to loop timer from 1 to 60
and
-Numpad 8 to disable script
(numpad7 and 9 only to turn on script)

Code:
if cycleTimer then cycleTimer.Destroy() cycleTimer=nil end
cycleTimer=createTimer() cycleTimer.Interval=500 cycleTimer.Enabled=false

myAddress = "0x701527F8" --your address! ?

function checkValue()
 myValue = math.floor(readFloat(myAddress))
  if myValue == 31 then
  writeFloat(myAddress,60)
 --else
 --print(math.floor(readFloat(myAddress)))
 end
end

cycleTimer.OnTimer = checkValue

if ExitKey then ExitKey.Destroy() ExitKey=nil end
-- check open-close key (F8)
ExitKey = createHotkey((function()
                         sleep(500)
                          if cycleTimer.Enabled==false then
                           cycleTimer.Enabled=true
                          else
                           cycleTimer.Enabled=false
                          end
                         end), VK_NUMPAD9)

_________________
!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Sat Dec 17, 2022 12:18 pm    Post subject: Reply with quote

Will 7 and 9 run at the same time?
If yes, you can test 1 and 31 in a single loop (eg 9).
Code:
if myValue == 31 or myValue == 1 then
  writeFloat(myAddress,60)


If no, use the same code (as in numped9.) change 1-31 to 1-60 and use a second timer. In one's working condition; Edit code that, when numped7 is clicked, stops the numped9 code and otherwise stops the numped7 timer.

It; Are the 7 and 9 timers likely to run at the same time?

numpad8 = Stop check (Timer) code:
Code:
if ExitKey8 then ExitKey8.Destroy() ExitKey8=nil end

ExitKey8 = createHotkey((function()
                         sleep(500)
                           cycleTimer.Enabled=false
                         end), VK_NUMPAD8) -- stop check


Example code:

Code:
if cycleTimer then cycleTimer.Destroy() cycleTimer=nil end
cycleTimer=createTimer() cycleTimer.Interval=500 cycleTimer.Enabled=false

function prt7() --value 31-60 code func.
print("Active key: 7")
end


function prt9() -- value 1-60 code func.
print("Active key: 9")
end


if ExitKey7 then ExitKey7.Destroy() ExitKey7=nil end
if ExitKey8 then ExitKey8.Destroy() ExitKey8=nil end
if ExitKey9 then ExitKey9.Destroy() ExitKey9=nil end

ExitKey7 = createHotkey((function()
                         sleep(500)
                          cycleTimer.Enabled=false
                          cycleTimer.OnTimer = prt7
                           cycleTimer.Enabled=true
                          end),VK_F7)

ExitKey9 = createHotkey((function()
                         sleep(500)
                          cycleTimer.Enabled=false
                          cycleTimer.OnTimer = prt9
                           cycleTimer.Enabled=true
                          end),VK_F9)

ExitKey8 = createHotkey((function()
                         sleep(500)
                          cycleTimer.Enabled=false
                          print("Active keys: Stop!")
                          end),VK_F8)

_________________
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
!BEWARE!
!BEWARE! Deletes post on answer
Reputation: 0

Joined: 26 Jun 2013
Posts: 56
Location: !BEWARE!

PostPosted: Sat Dec 17, 2022 4:52 pm    Post subject: Reply with quote

7 and 9 will not run at the same time.
If 7 is activated, pushing 9 cause disable 7 and turning on 9.
To turn off 7 or 9, have to be used 8
Not like before when 9 worked as ON>OFF>ON>OFF....

_________________
!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Sat Dec 17, 2022 5:22 pm    Post subject: This post has 1 review(s) Reply with quote

Code:
if cycleTimer then cycleTimer.Destroy() cycleTimer=nil end
cycleTimer=createTimer() cycleTimer.Interval=500 cycleTimer.Enabled=false

myAddress = "0x701527F8" --your address! ?

function checkValue9()
 myValue = math.floor(readFloat(myAddress))
  if myValue == 31 then
  writeFloat(myAddress,60)
 --else
 --print(math.floor(readFloat(myAddress)))
 end
end

function checkValue7()
 myValue = math.floor(readFloat(myAddress))
  if myValue == 1 then
  writeFloat(myAddress,60)
 --else
 --print(math.floor(readFloat(myAddress)))
 end
end

if ExitKey7 then ExitKey7.Destroy() ExitKey7=nil end
if ExitKey8 then ExitKey8.Destroy() ExitKey8=nil end
if ExitKey9 then ExitKey9.Destroy() ExitKey9=nil end

ExitKey7 = createHotkey((function()
                         sleep(500)
                          cycleTimer.Enabled=false
                          cycleTimer.OnTimer = checkValue7
                           cycleTimer.Enabled=true
                          end),VK_NUMPAD7)

ExitKey9 = createHotkey((function()
                         sleep(500)
                          cycleTimer.Enabled=false
                          cycleTimer.OnTimer = checkValue9
                           cycleTimer.Enabled=true
                          end),VK_NUMPAD9)

ExitKey8 = createHotkey((function()
                         sleep(500)
                          cycleTimer.Enabled=false
                          print("Active keys: Stop!")
                          end),VK_NUMPAD8)

_________________
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
Goto page 1, 2  Next
Page 1 of 2

 
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