I wrote this when Lua was first added to Cheat Engine 6.x as a demonstration of how to create a basic trainer GUI.

This script will create a simple window with two buttons to toggle infinite time and infinite flags.

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();