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 


Minesweeper Lua Trainer Example

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials
View previous topic :: View next topic  
Author Message
atom0s
Moderator
Reputation: 91

Joined: 25 Jan 2006
Posts: 5225
Location: 127.0.0.1

PostPosted: Thu Jan 13, 2011 11:20 pm    Post subject: Minesweeper Lua Trainer Example This post has 1 review(s) Reply with quote

This is a simple +2 options trainer example showing off how to create a small gui using Cheat Engine 6's new Lua engine integration. The trainer is not meant to be advanced, this is mearly a demonstration showing off the new features of Cheat Engine 6 with Lua scripting.

Code:
--[[

    Winmine.exe (Windows XP Minesweeper) Lua Trainer Example
    by atom0s [Wiccaan]
   
    This is a demonstrational Lua script showing off
    what Cheat Engine 6.0 can do with Lua.
   
]]--

--
-- DO NOT EDIT BELOW THIS LINE!!
--

local Trainer_Example = { }

----------------------------------------------------------------------------------
-- func: InitButton( .. )
-- desc: Wraps button creation and setup functions for smaller code.
----------------------------------------------------------------------------------
function InitButton( form, caption, x, y, w, h, func )
    local button = createButton( form );
    if( button == nil ) then
        return nil;
    end

    control_setCaption( button, caption );
    control_setPosition( button, x, y );
    control_setSize( button, w, h );
    control_onClick( button, func );
    return button;
end

----------------------------------------------------------------------------------
-- func: InitLabel( .. )
-- desc: Wraps label creation and setup functions for smaller code.
----------------------------------------------------------------------------------
function InitLabel( form, x, y, text )
    local label = createLabel( form );
    if( label == nil ) then
        return nil;
    end
   
    control_setCaption( label, text );
    control_setPosition( label, x, y );
    return label;
end

----------------------------------------------------------------------------------
-- func: Trainer_Example.Main( .. )
-- desc: Prepares script for overall actions.
----------------------------------------------------------------------------------
function Trainer_Example.Main( )
    -- Main trainer form pointer.
    Trainer_Example.Form = createForm( true );

    -- Create buttons.
    Trainer_Example.btnFlags = InitButton( Trainer_Example.Form, "Toggle Inf. Flags", 1, 1, 150, 30, Trainer_Example.OnFlagsClicked );
    Trainer_Example.btnTimer = InitButton( Trainer_Example.Form, "Toggle Unlimited Time", 155, 1, 150, 30, Trainer_Example.OnTimeClicked );

    -- Create info label.
    Trainer_Example.lblInfo = InitLabel( Trainer_Example.Form, 5, 175,
        "This is an example Lua trainer written using Cheat Engine 6.\n" ..
        "Coded by: atom0s [Wiccaan]"
        );
   
    -- Create option booleans.
    Trainer_Example.bFlagsEnabled = false;
    Trainer_Example.bTimerEnabled = false;
   
    -- Set form caption.
    control_setCaption( Trainer_Example.Form, "Minesweeper Lua Trainer Example" );
    return true;
end

----------------------------------------------------------------------------------
-- func: Trainer_Example.OnFlagsClicked( .. )
-- desc: Toggles infinite flags when flag button is clicked.
----------------------------------------------------------------------------------
function Trainer_Example.OnFlagsClicked()
    Trainer_Example.bFlagsEnabled = not Trainer_Example.bFlagsEnabled;
   
    if( Trainer_Example.bFlagsEnabled == true ) then
        autoAssemble( "winmine.exe+346E:\n" ..
            "db 90 90 90 90 90 90"
            );
    else
        autoAssemble( "winmine.exe+346E:\n" ..
            "db 01 05 94 51 00 01"
            );
    end
end

----------------------------------------------------------------------------------
-- func: Trainer_Example.OnTimeClicked( .. )
-- desc: Toggles unlimited time when time button is clicked.
----------------------------------------------------------------------------------
function Trainer_Example.OnTimeClicked()
    Trainer_Example.bTimerEnabled = not Trainer_Example.bTimerEnabled;
   
    if( Trainer_Example.bTimerEnabled == true ) then
        autoAssemble( "winmine.exe+2FF5:\n" ..
            "db 90 90 90 90 90 90"
            );
    else
        autoAssemble( "winmine.exe+2FF5:\n" ..
            "db FF 05 9C 57 00 01"
            );
    end
end

-- Execute our script.
Trainer_Example.Main();

_________________
- Retired.
Back to top
View user's profile Send private message
Recifense
I post too much
Reputation: 106

Joined: 17 Mar 2008
Posts: 2325
Location: Recife - Pernambuco - Brazil

PostPosted: Fri Jan 14, 2011 7:02 pm    Post subject: Reply with quote

Congratulations.

It is a very nice script. I am gonna use part of it in my next table.

Cheers!
Back to top
View user's profile Send private message Send e-mail
Popinman32
Cheater
Reputation: 0

Joined: 23 Jul 2010
Posts: 29

PostPosted: Tue Mar 15, 2011 3:19 pm    Post subject: Re: Minesweeper Lua Trainer Example Reply with quote

Nice code. Very Happy

Mind if I steal some functions? (InitButton, InitLabel, etc.)

_________________
I had a life? O.o
I thought my job was to collect information and help, then one day hope to use it. :S
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 91

Joined: 25 Jan 2006
Posts: 5225
Location: 127.0.0.1

PostPosted: Tue Mar 15, 2011 7:00 pm    Post subject: Re: Minesweeper Lua Trainer Example Reply with quote

Popinman32 wrote:
Nice code. Very Happy

Mind if I steal some functions? (InitButton, InitLabel, etc.)


Sure, I'm working on some beta wrappers at the moment though so stuff like this will be a lot easier. If you join the beta group you can find the wrappers posted in the beta forum.

_________________
- Retired.
Back to top
View user's profile Send private message
kingjordy3
How do I cheat?
Reputation: 0

Joined: 21 Jul 2011
Posts: 1

PostPosted: Thu Jul 21, 2011 1:08 am    Post subject: Reply with quote

damn u people are really talented i dont understand anything bout this script lol.. and i dont understand most tuts eighter =/ the only things i know how to do is like change values for like hp or infinit ammo or stuff like that . Razz
Back to top
View user's profile Send private message
DrWeazle
How do I cheat?
Reputation: -1

Joined: 15 Feb 2012
Posts: 7

PostPosted: Wed Feb 15, 2012 5:03 pm    Post subject: Reply with quote

What's the "db 90 90 90 90 90 90", is that the value your writing? and if i wanted to write the value of radioGroup's current index what would be the code for that?
Back to top
View user's profile Send private message
booingthetroll
Advanced Cheater
Reputation: 0

Joined: 30 Aug 2011
Posts: 79
Location: ::1

PostPosted: Sun Apr 22, 2012 3:50 pm    Post subject: Reply with quote

@Dr
db 90 90 90 90 90 90 writes NOP 6 at where you're injecting.
@Wiccaan
Nice script. My one inquiry is, why did you add form as a parameter? Why can you not make it default, creating the form before those functions?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 211

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

PostPosted: Sun Apr 22, 2012 5:59 pm    Post subject: Reply with quote

It doesn't really matter if the functions are declared before form is defined, if form becomes a global variable, once the function is executed it know what form is.

But the main point here is that it's object oriented and supports multiple forms without having to write separate functions for each form

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Back to top
View user's profile Send private message MSN Messenger
majmun
Newbie cheater
Reputation: 1

Joined: 22 Dec 2012
Posts: 15

PostPosted: Wed Dec 05, 2012 3:30 pm    Post subject: Re: Minesweeper Lua Trainer Example Reply with quote

What to say...Briliant! You're da man Laughing Laughing Laughing Laughing Laughing Laughing Laughing Laughing Laughing Laughing Laughing Laughing Laughing Laughing Laughing Laughing Laughing Laughing Laughing Laughing Laughing Wiccaan
Back to top
View user's profile Send private message
Forsaken™
Newbie cheater
Reputation: 0

Joined: 02 Feb 2014
Posts: 11
Location: Malaysia

PostPosted: Mon Feb 03, 2014 1:33 pm    Post subject: Reply with quote

Useful post. Very Happy But how to centre the form? it's align to the top left every time i open it.

I tried changing some part of your code using my AA script but it's not working. any idea? here's the code.
Code:

--Devil May Cry 4 Trainer

local Dmc_Trainer = { }

function InitButton(form, caption, x, y, w, h, func)
local button = createButton(form);
if (button == nil) then
return nil;
end

control_setCaption(button, caption);
control_setPosition(button, x, y);
control_setSize(button, w, h);
control_onClick(button, func);
return button;
end

function InitLabel(form, x, y, text)
local label = createLabel(form);
if(label == nil) then
return nil;
end

control_setCaption(label, text);
control_setPosition(label, x, y);
return label;
end

function Dmc_Trainer.Main()
Dmc_Trainer.Form = createForm( true );


--List of cheat buttons.

Dmc_Trainer.btnHealth = InitButton(Dmc_Trainer.Form, "Infinite Health", 3, 10, 150, 30, Dmc_Trainer.OnHealthClicked);
Dmc_Trainer.btnRedOrbs = InitButton(Dmc_Trainer.Form, "Infinite Red Orbs", 3, 60, 150, 30, Dmc_Trainer.OnRedOrbsClicked);
Dmc_Trainer.btnProudSouls = InitButton(Dmc_Trainer.Form, "Infinite Proud Souls", 1, 110, 150, 30, Dmc_Trainer.OnProudSoulsClicked);
Dmc_Trainer.btnOneHitKill = InitButton(Dmc_Trainer.Form, "One Hit Kill", 3, 157, 150, 30, Dmc_Trainer.OnOneHitKillClicked);
Dmc_Trainer.btnFastCharge = InitButton(Dmc_Trainer.Form, "Fast Charge", 3, 200, 150, 30, Dmc_Trainer.OnFastChargeClicked);

--Create info label.

Dmc_Trainer.lblInfo = InitLabel(Dmc_Trainer.Form, 255, 220, "Forsaken™");

--Create option boolean.
Dmc_Trainer.bHealthEnabled = false;
Dmc_Trainer.bRedOrbsEnabled = false;
Dmc_Trainer.bProudSoulsEnabled = false;
Dmc_Trainer.bOneHitKillEnabled = false;
Dmc_Trainer.bFastChargeEnabled = false;

--Set form caption.

control_setCaption(Dmc_Trainer.Form, "DMC Trainer Plus 5");
return true;
end

--Cheats

function Dmc_Trainer.OnHealthClicked()
Dmc_Trainer.bHealthEnabled = not Dmc_Trainer.bHealthEnabled;

if(Dmc_Trainer.bHealthEnabled == true) then
script = [[
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)

newmem:

cmp [esi+C8],0
jne originalcode
mov eax,[esi+1C]
mov [esi+18],eax
jmp exit

originalcode:
movss [esi+18],xmm0

exit:
jmp returnhere

"DevilMayCry4_DX10.exe"+11BAF5:
jmp newmem
returnhere: ]]
autoAssemble(script);

else
script = [[
dealloc(newmem)
"DevilMayCry4_DX10.exe"+11BAF5:
movss [esi+18],xmm0 ]]
autoAssemble(script);
end

end

function Dmc_Trainer.OnRedOrbsClicked()
Dmc_Trainer.bRedOrbsEnabled = not Dmc_Trainer.bRedOrbsEnabled;

if(Dmc_Trainer.bRedOrbsEnabled == true) then
script = [[
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)

newmem:

mov eax,9999999
mov [esi+114],eax
jmp exit

originalcode:
add [esi+00000114],ecx

exit:
jmp returnhere

"DevilMayCry4_DX10.exe"+94110:
jmp newmem
nop
returnhere: ]]
autoAssemble(script);

else
script = [[
dealloc(newmem)
"DevilMayCry4_DX10.exe"+94110:
add [esi+00000114],ecx ]]
autoAssemble(script);
end

end

function Dmc_Trainer.OnProudSoulsClicked()
Dmc_Trainer.bProudSoulsEnabled = not Dmc_Trainer.bProudSoulsEnabled;

if(Dmc_Trainer.bProudSoulsEnabled == true) then
script = [[
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)

newmem:

mov eax,9999999
mov [esi+1EC],eax
jmp exit

originalcode:
add [esi+000001EC],edi

exit:
jmp returnhere

"DevilMayCry4_DX10.exe"+14A1582:
jmp newmem
nop
returnhere: ]]
autoAssemble(script);

else
script = [[
dealloc(newmem)
"DevilMayCry4_DX10.exe"+14A1582:
add [esi+000001EC],edi ]]
autoAssemble(script);
end

end

function Dmc_Trainer.OnOneHitKillClicked()
Dmc_Trainer.bOneHitKillEnabled = not Dmc_Trainer.bOneHitKillEnabled;

if(Dmc_Trainer.bOneHitKillEnabled == true) then
script = [[
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)

newmem:

cmp [esi+C8],0
jne originalcode
movss [esi+18],xmm0

jmp exit

originalcode:
mov [esi+18],0

exit:
jmp returnhere

"DevilMayCry4_DX10.exe"+11BAF5:
jmp newmem
returnhere: ]]
autoAssemble(script);

else
script = [[
dealloc(newmem)
"DevilMayCry4_DX10.exe"+11BAF5:
movss [esi+18],xmm0 ]]
autoAssemble(script);
end

end

function Dmc_Trainer.OnFastChargeClicked()
Dmc_Trainer.bFastChargeEnabled = not Dmc_Trainer.bFastChargeEnabled;

if(Dmc_Trainer.bFastChargeEnabled == true) then
script = [[
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)

newmem:

mov [ebx+10],(float)1000
jmp exit

originalcode:
movss [ebx+10],xmm0

exit:
jmp returnhere

"DevilMayCry4_DX10.exe"+3E9BEA:
jmp newmem
returnhere: ]]
autoAssemble(script);

else
script = [[
dealloc(newmem)
"DevilMayCry4_DX10.exe"+3E9BEA:
movss [ebx+10],xmm0 ]]
autoAssemble(script);
end

end

--Execute script

Dmc_Trainer.Main();

_________________
From that day forth... my arm changed... and a voice echoed "Power! Give me more power!" and if I become a demon, so be it... I'll endure the exile... anything... to protect her!
Back to top
View user's profile Send private message
Legendary_Phoenix
How do I cheat?
Reputation: 0

Joined: 10 Mar 2014
Posts: 1

PostPosted: Mon Mar 10, 2014 6:09 am    Post subject: Devil May Cry 4 Trainer Reply with quote

Hey Buddy!
You can try this script that almost worked.........

--Devil May Cry 4 Trainer

local Dmc_Trainer = { }

function InitButton(form, caption, x, y, w, h, func)
local button = createButton(form);
if (button == nil) then
return nil;
end

control_setCaption(button, caption);
control_setPosition(button, x, y);
control_setSize(button, w, h);
control_onClick(button, func);
return button;
end

function InitLabel(form, x, y, text)
local label = createLabel(form);
if(label == nil) then
return nil;
end

control_setCaption(label, text);
control_setPosition(label, x, y);
return label;
end

function Dmc_Trainer.Main()
Dmc_Trainer.Form = createForm( true );

aalist=getAutoAttachList()
stringlist_add(aalist,"DevilMayCry4_DX10.exe");

--List of cheat buttons.

Dmc_Trainer.btnHealth = InitButton(Dmc_Trainer.Form, "Infinite Health", 3, 10, 150, 30, Dmc_Trainer.OnHealthClicked);
Dmc_Trainer.btnRedOrbs = InitButton(Dmc_Trainer.Form, "Infinite Red Orbs", 3, 60, 150, 30, Dmc_Trainer.OnRedOrbsClicked);
Dmc_Trainer.btnProudSouls = InitButton(Dmc_Trainer.Form, "Infinite Proud Souls", 1, 110, 150, 30, Dmc_Trainer.OnProudSoulsClicked);
Dmc_Trainer.btnOneHitKill = InitButton(Dmc_Trainer.Form, "One Hit Kill", 3, 157, 150, 30, Dmc_Trainer.OnOneHitKillClicked);
Dmc_Trainer.btnFastCharge = InitButton(Dmc_Trainer.Form, "Fast Charge", 3, 200, 150, 30, Dmc_Trainer.OnFastChargeClicked);

--Create info label.

Dmc_Trainer.lblInfo = InitLabel(Dmc_Trainer.Form, 255, 220, "Forsaken™");

--Create option boolean.
Dmc_Trainer.bHealthEnabled = false;
Dmc_Trainer.bRedOrbsEnabled = false;
Dmc_Trainer.bProudSoulsEnabled = false;
Dmc_Trainer.bOneHitKillEnabled = false;
Dmc_Trainer.bFastChargeEnabled = false;

--Set form caption.

control_setCaption(Dmc_Trainer.Form, "DMC Trainer Plus 5");
return true;
end

--Cheats

function Dmc_Trainer.OnHealthClicked()
Dmc_Trainer.bHealthEnabled = not Dmc_Trainer.bHealthEnabled;

if(Dmc_Trainer.bHealthEnabled == true) then
script = [[
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)

newmem:

cmp [esi+C8],0
jne originalcode
mov eax,[esi+1C]
mov [esi+18],eax
jmp exit

originalcode:
movss [esi+18],xmm0

exit:
jmp returnhere

"DevilMayCry4_DX10.exe"+11BAF5:
jmp newmem
returnhere: ]]
autoAssemble(script);

else
script = [[
dealloc(newmem)
"DevilMayCry4_DX10.exe"+11BAF5:
movss [esi+18],xmm0 ]]
autoAssemble(script);
end

end

function Dmc_Trainer.OnRedOrbsClicked()
Dmc_Trainer.bRedOrbsEnabled = not Dmc_Trainer.bRedOrbsEnabled;

if(Dmc_Trainer.bRedOrbsEnabled == true) then
script = [[
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)

newmem:

mov eax,9999999
mov [esi+114],eax
jmp exit

originalcode:
add [esi+00000114],ecx

exit:
jmp returnhere

"DevilMayCry4_DX10.exe"+94110:
jmp newmem
nop
returnhere: ]]
autoAssemble(script);

else
script = [[
dealloc(newmem)
"DevilMayCry4_DX10.exe"+94110:
add [esi+00000114],ecx ]]
autoAssemble(script);
end

end

function Dmc_Trainer.OnProudSoulsClicked()
Dmc_Trainer.bProudSoulsEnabled = not Dmc_Trainer.bProudSoulsEnabled;

if(Dmc_Trainer.bProudSoulsEnabled == true) then
script = [[
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)

newmem:

mov eax,9999999
mov [esi+1EC],eax
jmp exit

originalcode:
add [esi+000001EC],edi

exit:
jmp returnhere

"DevilMayCry4_DX10.exe"+14A1582:
jmp newmem
nop
returnhere: ]]
autoAssemble(script);

else
script = [[
dealloc(newmem)
"DevilMayCry4_DX10.exe"+14A1582:
add [esi+000001EC],edi ]]
autoAssemble(script);
end

end

function Dmc_Trainer.OnOneHitKillClicked()
Dmc_Trainer.bOneHitKillEnabled = not Dmc_Trainer.bOneHitKillEnabled;

if(Dmc_Trainer.bOneHitKillEnabled == true) then
script = [[
alloc(newmem,2048)
label(returnhere)
label(god)
label(exit)

newmem:

cmp [esi+C8],0
jne god
mov eax,[esi+1c]
mov [esi+18],eax
jmp exit

god:
mov [esi+18],0

exit:
jmp returnhere

"DevilMayCry4_DX10.exe"+11BAF5:
jmp newmem
returnhere: ]]
autoAssemble(script);

else
script = [[
dealloc(newmem)
"DevilMayCry4_DX10.exe"+11BAF5:
movss [esi+18],xmm0 ]]
autoAssemble(script);
end

end

function Dmc_Trainer.OnFastChargeClicked()
Dmc_Trainer.bFastChargeEnabled = not Dmc_Trainer.bFastChargeEnabled;

if(Dmc_Trainer.bFastChargeEnabled == true) then
script = [[
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)

newmem:

mov [ebx+10],(float)1000
jmp exit

originalcode:
movss [ebx+10],xmm0

exit:
jmp returnhere

"DevilMayCry4_DX10.exe"+3E9BEA:
jmp newmem
returnhere: ]]
autoAssemble(script);

else
script = [[
dealloc(newmem)
"DevilMayCry4_DX10.exe"+3E9BEA:
movss [ebx+10],xmm0 ]]
autoAssemble(script);
end

end

--Execute script

Dmc_Trainer.Main();
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)