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 Tutorial Pack

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials
View previous topic :: View next topic  

Is this thread useful?
Yes
100%
 100%  [ 7 ]
No
0%
 0%  [ 0 ]
Total Votes : 7

Author Message
Frouk
Master Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 489
Location: mov dword ptr [Ukraine]

PostPosted: Sat Aug 07, 2021 1:16 am    Post subject: Lua Tutorial Pack Reply with quote

This code is included this thread
Code:
local timer = createTimer(nil)
timer.Enabled = true
timer.Interval = 200
timer.OnTimer = function()
for i,v in pairs(keyID) do
if isKeyPressed(v) then
print(i)
end
end
end

In this case this code will print current pressed key with 200 ms interval

_________________
void(__cdecl *Haxing)(HWND hGameWindow)


Last edited by Frouk on Sun Aug 29, 2021 7:19 am; edited 3 times in total
Back to top
View user's profile Send private message
Frouk
Master Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 489
Location: mov dword ptr [Ukraine]

PostPosted: Sun Aug 08, 2021 11:47 pm    Post subject: Reply with quote

Code:
local form = createForm(true)

form.OnMouseEnter = function(sender)
local a = 0x000000
local b = 0xFFFFFF
local randColor = math.random(a,b)
form.Color = string.format('0x%X',randColor)
end

This code will create form and if cursor in form, form will have random color

_________________
void(__cdecl *Haxing)(HWND hGameWindow)
Back to top
View user's profile Send private message
Frouk
Master Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 489
Location: mov dword ptr [Ukraine]

PostPosted: Sun Aug 15, 2021 3:54 am    Post subject: Reply with quote

Code:
function numberInRange(value)
if value >= 0 and value <= 100 then
print('yay')
else
print('nay')
end
end

This code will print yay if value in range

_________________
void(__cdecl *Haxing)(HWND hGameWindow)
Back to top
View user's profile Send private message
Frouk
Master Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 489
Location: mov dword ptr [Ukraine]

PostPosted: Sun Aug 29, 2021 7:18 am    Post subject: Reply with quote

Force end function if statement less than or equals 0
Code:
function new()
if health <= 0 then
return;
end
writeFloat(addr,100)
end

_________________
void(__cdecl *Haxing)(HWND hGameWindow)
Back to top
View user's profile Send private message
Frouk
Master Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 489
Location: mov dword ptr [Ukraine]

PostPosted: Tue Aug 31, 2021 7:29 am    Post subject: Reply with quote

Code:
local Player = {
AddHealth = function(health)
local num = 'PlayerPTR + 0x48'
local num2 = readFloat(num)
writeFloat(num,num2+health)
end,
}

Creates table named Player and adds function in it
To call function you need to type like this:
Code:
Player.AddHealth(50)

_________________
void(__cdecl *Haxing)(HWND hGameWindow)
Back to top
View user's profile Send private message
Frouk
Master Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 489
Location: mov dword ptr [Ukraine]

PostPosted: Fri Oct 29, 2021 10:12 am    Post subject: Reply with quote

This function will return true if Cheat Engine attached to game:
Code:
function IsAttached(procName)
return getOpenedProcessID() == getProcessIDFromProcessName(procName)
end

Calling the function: IsAttached("chrome.exe")

_________________
void(__cdecl *Haxing)(HWND hGameWindow)
Back to top
View user's profile Send private message
Frouk
Master Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 489
Location: mov dword ptr [Ukraine]

PostPosted: Sun Jan 02, 2022 4:29 am    Post subject: Reply with quote

Code:
function MakeRangedNop(addr,addrTo)
addr = string.format("0x%X",getAddress(addr))
addrTo = string.format("0x%X",getAddress(addr))
local size
if addr == nil then
return
end
if addrTo == nil then
size = getInstructionSize(addr)+1
end
size = -(addr - addrTo)
MakeNop(addr,size)
end

function MakeNop(addr,size)
addr = string.format("0x%X",getAddress(addr))
size = tonumber(size)
if addr == nil then
return
end
if size == 0 then
return
end
if size == nil then
size = getInstructionSize(addr)+1
end
size = size - 1
for i = 0,size do
writeBytes(addr+i,0x90)
end
end

function PrintRangedBytes(addr,addrTo)
local size
if addrTo == nil then
size = getInstructionSize(addr)+1
end
addr = string.format("0x%X",getAddress(addr))
addrTo = string.format("0x%X",getAddress(addrTo))
local result = {}
if addr == nil then
return
end
size = -(addr - addrTo) - 1
for i = 0,size do
printf("%X",readBytes(addr+i))
end
end

Those functions for memory editing

_________________
void(__cdecl *Haxing)(HWND hGameWindow)
Back to top
View user's profile Send private message
Frouk
Master Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 489
Location: mov dword ptr [Ukraine]

PostPosted: Sat Jan 15, 2022 6:30 am    Post subject: Reply with quote

Code:
regenTimer = createTimer(nil)
regenTimer.Interval = 200
regenTimer.Enabled = true
regenTimer.OnTimer = function()
local healthOffset = 0x540
local maxHealthOffset = 0x544
local addr = "PlayerPointer" --replace this
local currHealth = readFloat(addr+healthOffset)
local maxHealth = readFloat(addr+maxHealthOffset)
if currHealth => maxHealth then
return
end
writeFloat(addr+healthOffset,currHealth+1)
end

Health regeneration code

_________________
void(__cdecl *Haxing)(HWND hGameWindow)
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 Tutorials -> LUA Tutorials 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 cannot download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites