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 


My script don't work

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

Joined: 15 Dec 2019
Posts: 6

PostPosted: Mon Dec 23, 2019 5:19 am    Post subject: My script don't work Reply with quote

Hello.
I am beginner in LUA scripting and I want to write a simple script.
I want to know what is the problem of this script:
Code:
function EN()
    if(readInteger(20538502) == readInteger(204E0368)) then
        writeBytes(20538505, readBytes(20538505)-1)
    end
end

createHotkey(EN, VK_CTRL)

Thanks.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25821
Location: The netherlands

PostPosted: Mon Dec 23, 2019 6:29 am    Post subject: Reply with quote

hexadecimal numbers start with 0x in front. e.g 0x20538502
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
HamidReza555
How do I cheat?
Reputation: 0

Joined: 15 Dec 2019
Posts: 6

PostPosted: Thu Dec 26, 2019 8:38 am    Post subject: Reply with quote

Dark Byte wrote:
hexadecimal numbers start with 0x in front. e.g 0x20538502

Thanks for reply. Now it's working.
But, one more question. Why when I use "VK_CTRL" it doesn't work?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25821
Location: The netherlands

PostPosted: Thu Dec 26, 2019 10:13 am    Post subject: Reply with quote

because VK_CTRL doesn't exist.
You likely mean VK_CONTROL

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
HamidReza555
How do I cheat?
Reputation: 0

Joined: 15 Dec 2019
Posts: 6

PostPosted: Thu Dec 26, 2019 10:21 am    Post subject: Reply with quote

Dark Byte wrote:
because VK_CTRL doesn't exist.
You likely mean VK_CONTROL

Thanks. It works now.
Excuse me, but I have another question. Very Happy
How can I check if a timer is enabled or disabled?
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1532

PostPosted: Thu Dec 26, 2019 1:11 pm    Post subject: Reply with quote

HamidReza555 wrote:

Excuse me, but I have another question. Very Happy
How can I check if a timer is enabled or disabled?


Code:
function TimerCheck()
if UDF1.CETimer1.Enabled == true then --You Timer name?
print("Timer is working")
else
print("Timer not working")
end
end

TimerCheck()

_________________
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
HamidReza555
How do I cheat?
Reputation: 0

Joined: 15 Dec 2019
Posts: 6

PostPosted: Thu Dec 26, 2019 4:05 pm    Post subject: Reply with quote

Aylin wrote:
HamidReza555 wrote:

Excuse me, but I have another question. Very Happy
How can I check if a timer is enabled or disabled?


Code:
function TimerCheck()
if UDF1.CETimer1.Enabled == true then --You Timer name?
print("Timer is working")
else
print("Timer not working")
end
end

TimerCheck()

Thanks. I have another question. How can I check if a value reach a specific number in a timer?
I mean how can I check if a value reach a number in a timer?
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1532

PostPosted: Thu Dec 26, 2019 6:39 pm    Post subject: Reply with quote

Here's an example:
https://forum.cheatengine.org/viewtopic.php?t=610218

or:
Code:
local TimerValue = 0
UDF1.CETimer1.Interval = 1000
UDF1.CETimer1.Enabled = true

function TimerCheck()
if UDF1.CETimer1.Enabled == true then --You Timer name?
TimerValue = TimerValue + 1000
else
print("Timer not working") end
if TimerValue==5000 then
print("Timer is working")
UDF1.CETimer1.Enabled = false
end
end

function UDF1_CETimer1Timer(sender)
TimerCheck()
end


or use this archive. There's more there. Wink
https://forum.cheatengine.org/search.php

_________________
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
HamidReza555
How do I cheat?
Reputation: 0

Joined: 15 Dec 2019
Posts: 6

PostPosted: Wed Jan 01, 2020 12:26 pm    Post subject: Reply with quote

Aylin wrote:
Here's an example:

Code:
local TimerValue = 0
UDF1.CETimer1.Interval = 1000
UDF1.CETimer1.Enabled = true

function TimerCheck()
if UDF1.CETimer1.Enabled == true then --You Timer name?
TimerValue = TimerValue + 1000
else
print("Timer not working") end
if TimerValue==5000 then
print("Timer is working")
UDF1.CETimer1.Enabled = false
end
end

function UDF1_CETimer1Timer(sender)
TimerCheck()
end

Hi again. Thanks for reply. I mean that I want to check if a value of an address reaches a value. The example you wrote wasn't the thing that I wanted to know.
Code:
function CU()
    if(readBytes(0x20538502) == readBytes(0x204E0368)) then
        writeBytes(0x205384FF, readBytes(0x205384FF)+7)
        timer_setEnabled(Timer, false)
    end
end

I want to change it to:
Code:
if(readBytes(0x20538502) reaches readBytes(0x204E0368))
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