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 script usage general questions

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

Joined: 04 May 2024
Posts: 2

PostPosted: Sat May 04, 2024 6:24 am    Post subject: Lua script usage general questions Reply with quote

Hi,
from what i have scoured from site and put together myself i have made:

wantedSpeed=0.3
lastSpeed=1

function checkKeys(timer)
if isKeyPressed(VK_RBUTTON) and (not isKeyPressed(VK_LBUTTON)) then
if lastSpeed~=wantedSpeed then
lastSpeed = math.max(lastSpeed - 0.025, wantedSpeed)
speedhack_setSpeed(lastSpeed)
end
else
if isKeyPressed(VK_LBUTTON) then
lastSpeed = 1
speedhack_setSpeed(lastSpeed)
end
if lastSpeed~=1 then
lastSpeed = math.max(lastSpeed + 0.05, wantedSpeed)
lastSpeed = math.min(lastSpeed, 1)
speedhack_setSpeed(lastSpeed)
end
end
end

if t~=nil then
t.destroy()
t=nil
end

t=createTimer()
t.Interval=50
t.OnTimer=checkKeys
t.Enabled=true

Very cool way to feel like i'm playing good ol' max payne games while playing any other fps.

Script works just fine (unless you can suggest some needed changes), but I need help with launching it - normallny, after attaching, I launch it via Table -> Show Cheat Table Lua Script -> paste & Execute script, which usually works but kinda gets tedious.

I want to ask if is there some way I can:
1. auto attach to some game (or selected group of them)?
2. toggle it on/ off with Active checkbox? I mean like for values i would have found and added using Scanning?

Thanks!
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4710

PostPosted: Sat May 04, 2024 2:08 pm    Post subject: Reply with quote

Go into Edit -> Settings and change "When a table has a lua script, execute it:" to something other than "Never"

1. Lua code: `getAutoAttachList().add'game.exe'
https://wiki.cheatengine.org/index.php?title=Tutorials:Lua:Setup_Auto_Attach

2. Template:
Code:
{$lua}
if syntaxcheck then return end

[ENABLE]
-- code to run when enabled

[DISABLE]
-- code to run when disabled
Note the two script executions are independent of each other. Local variables won't be reused.
Code:
{$lua}
if syntaxcheck then return end

local a = 1

[ENABLE]
local b = 2
a = 3

print(a,b) -- prints 3 2

[DISABLE]
print(a,b)  -- prints 1

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
PtrkPtrk
How do I cheat?
Reputation: 0

Joined: 04 May 2024
Posts: 2

PostPosted: Sun May 05, 2024 6:21 am    Post subject: Reply with quote

hi, i understand how to autoattach now and how template ought to work, but i still have no idea how to add bare lua script to the checkbox
i tried to copy some script from existing cheat table and edit it, but this results with this instruction cannot be compiled error on the very first lane of script after [ENABLED]
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