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][SRC] Free Trainer Form with 3D Navigation System

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
AylinCE
Grandmaster Cheater Supreme
Reputation: 39

Joined: 16 Feb 2017
Posts: 1572

PostPosted: Tue Apr 07, 2026 10:08 am    Post subject: [LUA][SRC] Free Trainer Form with 3D Navigation System Reply with quote

A freely customizable Trainer form for those who are still in the development phase and know what they're doing.

You can navigate between pages using the arrow keys.

Note1: Please mention any development ideas in the comments.

Note2: This article is inspired by [this article/source].
https://forum.cheatengine.org/viewtopic.php?t=623634

Code:
-- *********************************************************
-- Module
-- *********************************************************

local cubeScale = 2.0  -- Increase or decrease the cube size.

-- RENK VE DOLDURMA FIX
local function myFillPolygon(canvas, points, color)
    local numPoints = #points
    if numPoints < 3 then return end
    local minY, maxY = points[1].y, points[1].y
    for i = 1, numPoints do
        minY = math.min(minY, points[i].y)
        maxY = math.max(maxY, points[i].y)
    end
    canvas.Pen.Color = 0x000000
    canvas.Brush.Color = color
    for y = math.floor(minY), math.ceil(maxY) do
        local intersections = {}
        for i = 1, numPoints do
            local p1 = points[i]
            local p2 = points[(i % numPoints) + 1]
            if (p1.y <= y and p2.y > y) or (p2.y <= y and p1.y > y) then
                local slope = (p2.x - p1.x) / (p2.y - p1.y)
                table.insert(intersections, p1.x + (y - p1.y) * slope)
            end
        end
        table.sort(intersections)
        for i = 1, #intersections, 2 do
            local x1, x2 = math.floor(intersections[i]), math.ceil(intersections[i+1] or intersections[i])
            if x1 < x2 then canvas.fillRect(x1, y, x2, y + 1) end
        end
    end
end

-- SETTINGS AND COORDINATES (Size is adjusted according to scale)
local size = 70 * cubeScale
local vertices = {
    { -size, -size, -size }, { size, -size, -size }, { size,  size, -size }, { -size,  size, -size },
    { -size, -size,  size }, { size, -size,  size }, { size,  size,  size }, { -size,  size,  size }
}


-- *********************************************************
-- GUI
-- *********************************************************

if cubefrm then cubefrm.Destroy() cubefrm=nil end
DP1=getScreenDPI()/96
cubefrm=createForm()
cubefrm.height=470*DP1 cubefrm.width=400*DP1
cubefrm.PopupMode=0 cubefrm.caption="AylinCE  Trainers  (2026)"
cubefrm.Position="poDesktopCenter" cubefrm.ShowInTaskBar="stAlways"
cubefrm.BorderStyle="bsNone"
cubefrm.setLayeredAttributes(0x000010, 255, LWA_COLORKEY | LWA_ALPHA )
cubefrm.Color=0x000010

-------------------------
local acb = {}
----------------------- acb.cbimg ----- 
acb.cbimg=createImage(cubefrm)
acb.cbimg.AutoSize=false
acb.cbimg.height=400*DP1 acb.cbimg.width=400*DP1 acb.cbimg.left=0*DP1 acb.cbimg.top=35*DP1
acb.cbimg.Stretch=false
-----------------------
----------------------- acb.mpnl1 ----- 
acb.mpnl1=createPanel(cubefrm)
acb.mpnl1.AutoSize=false
acb.mpnl1.height=40*DP1 acb.mpnl1.width=390*DP1 acb.mpnl1.left=5*DP1 acb.mpnl1.top=5*DP1
acb.mpnl1.caption="CE Cube - Trainer  Form"
acb.mpnl1.Color=8882055
acb.mpnl1.Font.Style="fsBold" acb.mpnl1.Font.Size=15*DP1
acb.mpnl1.OnMouseDown=function() cubefrm.DragNow() end
-----------------------
----------------------- acb.mbtn5 ----- 
acb.mbtn5=createButton(acb.mpnl1)
acb.mbtn5.AutoSize=false
acb.mbtn5.height=26*DP1 acb.mbtn5.width=26*DP1 acb.mbtn5.left=7*DP1 acb.mbtn5.top=6*DP1
acb.mbtn5.caption="-"
acb.mbtn5.Font.Style="fsBold" acb.mbtn5.Font.Size=14*DP1
-----------------------
----------------------- acb.mbtn6 ----- 
acb.mbtn6=createButton(acb.mpnl1)
acb.mbtn6.AutoSize=false
acb.mbtn6.height=26*DP1 acb.mbtn6.width=26*DP1 acb.mbtn6.left=356*DP1 acb.mbtn6.top=6*DP1
acb.mbtn6.caption="X"
acb.mbtn6.Font.Style="fsBold" acb.mbtn6.Font.Size=14*DP1
-----------------------
----------------------- acb.mpnl3 ----- 
acb.mpnl3=createPanel(cubefrm)
acb.mpnl3.AutoSize=false
acb.mpnl3.height=40*DP1 acb.mpnl3.width=390*DP1 acb.mpnl3.left=5*DP1 acb.mpnl3.top=425*DP1
acb.mpnl3.caption="AylinCE  Trainers  (2026)"
acb.mpnl3.Color=8882055
acb.mpnl3.Font.Style="fsBold" acb.mpnl3.Font.Size=15*DP1
-----------------------
----------------------- acb.hpnl1 ----- 
acb.hpnl1=createPanel(cubefrm)
acb.hpnl1.AutoSize=false
acb.hpnl1.height=338*DP1 acb.hpnl1.width=338*DP1 acb.hpnl1.left=34*DP1 acb.hpnl1.top=64*DP1
acb.hpnl1.caption="CE Cube - Trainer  Form"
acb.hpnl1.Color=14330015
acb.hpnl1.Font.Style="fsBold" acb.hpnl1.Font.Size=0*DP1
-----------------------
----------------------- acb.albl5 ----- 
acb.albl5=createLabel(acb.hpnl1)
acb.albl5.AutoSize=false
acb.albl5.height=30*DP1 acb.albl5.width=266*DP1 acb.albl5.left=10*DP1 acb.albl5.top=10*DP1
acb.albl5.caption="About  Page"
acb.albl5.alignment="taCenter"
acb.albl5.Font.Style="fsBold" acb.albl5.Font.Size=-20*DP1
-----------------------
----------------------- acb.albl1 ----- 
acb.albl1=createLabel(acb.hpnl1)
acb.albl1.AutoSize=false
acb.albl1.height=275*DP1 acb.albl1.width=266*DP1 acb.albl1.left=10*DP1 acb.albl1.top=50*DP1
acb.albl1.caption=""
acb.albl1.alignment="taCenter"
acb.albl1.Font.Style="fsBold" acb.albl1.Font.Size=0*DP1
-----------------------
----------------------- acb.hpnl2 ----- 
acb.hpnl2=createPanel(cubefrm)
acb.hpnl2.AutoSize=false
acb.hpnl2.height=338*DP1 acb.hpnl2.width=338*DP1 acb.hpnl2.left=34*DP1 acb.hpnl2.top=64*DP1
acb.hpnl2.caption=""
acb.hpnl2.Color=14330015
acb.hpnl2.Font.Style="fsBold" acb.hpnl2.Font.Size=0*DP1
-----------------------
----------------------- acb.albl2 ----- 
acb.albl2=createLabel(acb.hpnl2)
acb.albl2.AutoSize=false
acb.albl2.height=30*DP1 acb.albl2.width=266*DP1 acb.albl2.left=10*DP1 acb.albl2.top=10*DP1
acb.albl2.caption="SETTINGS"
acb.albl2.alignment="taCenter"
acb.albl2.Font.Style="fsBold" acb.albl2.Font.Size=-20*DP1
-----------------------
----------------------- acb.hpnl3 ----- 
acb.hpnl3=createPanel(cubefrm)
acb.hpnl3.AutoSize=false
acb.hpnl3.height=338*DP1 acb.hpnl3.width=338*DP1 acb.hpnl3.left=34*DP1 acb.hpnl3.top=64*DP1
acb.hpnl3.caption=""
acb.hpnl3.Color=14330015
acb.hpnl3.Font.Style="fsBold" acb.hpnl3.Font.Size=0*DP1
-----------------------
----------------------- acb.albl3 ----- 
acb.albl3=createLabel(acb.hpnl3)
acb.albl3.AutoSize=false
acb.albl3.height=30*DP1 acb.albl3.width=266*DP1 acb.albl3.left=10*DP1 acb.albl3.top=10*DP1
acb.albl3.caption="Hack  Page  1"
acb.albl3.alignment="taCenter"
acb.albl3.Font.Style="fsBold" acb.albl3.Font.Size=-20*DP1
-----------------------
----------------------- acb.hpnl4 ----- 
acb.hpnl4=createPanel(cubefrm)
acb.hpnl4.AutoSize=false
acb.hpnl4.height=338*DP1 acb.hpnl4.width=338*DP1 acb.hpnl4.left=34*DP1 acb.hpnl4.top=64*DP1
acb.hpnl4.caption=""
acb.hpnl4.Color=14330015
acb.hpnl4.Font.Style="fsBold" acb.hpnl4.Font.Size=0*DP1
-----------------------
----------------------- acb.albl4 ----- 
acb.albl4=createLabel(acb.hpnl4)
acb.albl4.AutoSize=false
acb.albl4.height=30*DP1 acb.albl4.width=266*DP1 acb.albl4.left=10*DP1 acb.albl4.top=10*DP1
acb.albl4.caption="Hack  Page  2"
acb.albl4.alignment="taCenter"
acb.albl4.Font.Style="fsBold" acb.albl4.Font.Size=-20*DP1
-----------------------
----------------------- acb.hpnl5 ----- 
acb.hpnl5=createPanel(cubefrm)
acb.hpnl5.AutoSize=false
acb.hpnl5.height=338*DP1 acb.hpnl5.width=338*DP1 acb.hpnl5.left=34*DP1 acb.hpnl5.top=64*DP1
acb.hpnl5.caption=""
acb.hpnl5.Color=14330015
acb.hpnl5.Font.Style="fsBold" acb.hpnl5.Font.Size=0*DP1
-----------------------
----------------------- acb.albl5 ----- 
acb.albl5=createLabel(acb.hpnl5)
acb.albl5.AutoSize=false
acb.albl5.height=30*DP1 acb.albl5.width=266*DP1 acb.albl5.left=10*DP1 acb.albl5.top=10*DP1
acb.albl5.caption="Hack  Page  3"
acb.albl5.alignment="taCenter"
acb.albl5.Font.Style="fsBold" acb.albl5.Font.Size=-20*DP1
-----------------------
----------------------- acb.hpnl6 ----- 
acb.hpnl6=createPanel(cubefrm)
acb.hpnl6.AutoSize=false
acb.hpnl6.height=338*DP1 acb.hpnl6.width=338*DP1 acb.hpnl6.left=34*DP1 acb.hpnl6.top=64*DP1
acb.hpnl6.caption=""
acb.hpnl6.Color=14330015
acb.hpnl6.Font.Style="fsBold" acb.hpnl6.Font.Size=0*DP1
-----------------------
----------------------- acb.albl6 ----- 
acb.albl6=createLabel(acb.hpnl6)
acb.albl6.AutoSize=false
acb.albl6.height=30*DP1 acb.albl6.width=266*DP1 acb.albl6.left=10*DP1 acb.albl6.top=10*DP1
acb.albl6.caption="Hack  Page  4"
acb.albl6.alignment="taCenter"
acb.albl6.Font.Style="fsBold" acb.albl6.Font.Size=-20*DP1
-----------------------

-- *********************************************************
-- Functions
-- *********************************************************

-- DPI Scaling Factor (96 is standard DPI)
local DPI_SCALE = getScreenDPI() / 96

-- Form & Asset References
local myForm = cubefrm
local vsblPnl = acb.hpnl1
local img = acb.cbimg

-- State Variables
local curX, tarX = 90, 90  -- Starting at 90 (About Face)
local curY, tarY = 0, 0
local projected1 = {}
local faceName = nil

-- Global Visibility Control: Hides all panels and applies Drag functionality
function pnlVsbl()
    for i=1, 6 do
        local pnl = acb["hpnl"..i]
        local lbl = acb["albl"..i]
        pnl.Visible = false
        -- Enable dragging the form from the panels or labels
        pnl.OnMouseDown = function() myForm.DragNow() end
        lbl.OnMouseDown = function() myForm.DragNow() end
    end
end

-- Initialize UI State
pnlVsbl()
img.Picture.Bitmap = createBitmap(img.Width, img.Height)

-- Face Definitions with IDs and Colors
-- id=1: About, id=2: Settings, id=3-6: Hacks
local faces = {
    {1, 2, 3, 4, 0x0000FF, id=3}, -- FRONT (Blue - Hack 1)
    {5, 6, 7, 8, 0x00FF00, id=5}, -- BACK (Green - Hack 3)
    {1, 5, 8, 4, 0xFFFF00, id=6}, -- LEFT (Yellow - Hack 4)
    {2, 6, 7, 3, 0x00FFFF, id=4}, -- RIGHT (Cyan - Hack 2)
    {4, 8, 7, 3, 0xFF00FF, id=2}, -- TOP (Magenta - Settings)
    {1, 5, 6, 2, 0xFFFFFF, id=1}  -- BOTTOM (White - About)
}

-- 3D Rendering Core (DPI Aware)
local function drawCube()
    local canvas = img.Picture.Bitmap.Canvas
    canvas.Brush.Color = myForm.Color
    canvas.fillRect(0, 0, img.Width, img.Height)

    local projected = {}
    local faceData = {}

    local centerX = img.Width / 2
    local centerY = img.Height / 2
    local perspective = (img.Width * DPI_SCALE) * cubeScale

    for i, v in ipairs(vertices) do
        local x, y, z = v[1], v[2], v[3]

        -- Rotation Matrices
        local radY = math.rad(curY)
        local rx = x * math.cos(radY) - z * math.sin(radY)
        local rz = x * math.sin(radY) + z * math.cos(radY)

        local radX = math.rad(curX)
        local ry = y * math.cos(radX) - rz * math.sin(radX)
        local finalZ = y * math.sin(radX) + rz * math.cos(radX)

        -- Projection Calculation with Scale
        local factor = perspective / (finalZ + (img.Width * cubeScale))
        projected[i] = {
            x = rx * factor + centerX,
            y = ry * factor + centerY,
            z = finalZ
        }
    end
    projected1 = projected -- Export for global access

    -- Z-Sorting for correct face layering
    for i, f in ipairs(faces) do
        local avgZ = (projected[f[1]].z + projected[f[2]].z + projected[f[3]].z + projected[f[4]].z) / 4
        table.insert(faceData, {indices = f, z = avgZ, color = f[5]})
    end
    table.sort(faceData, function(a, b) return a.z > b.z end)

    -- Draw polygons to Canvas
    for _, f in ipairs(faceData) do
        local p = f.indices
        myFillPolygon(canvas, {
            {x=projected[p[1]].x, y=projected[p[1]].y}, {x=projected[p[2]].x, y=projected[p[2]].y},
            {x=projected[p[3]].x, y=projected[p[3]].y}, {x=projected[p[4]].x, y=projected[p[4]].y}
        }, f.color)
    end
    img.repaint()
end

-- Identify the face closest to the camera (Z-Depth Based)
local function getVisibleFaceID()
    local bestZ = 999999
    local visibleID = 1

    for i, f in ipairs(faces) do
        local avgZ = (projected1[f[1]].z + projected1[f[2]].z + projected1[f[3]].z + projected1[f[4]].z) / 4
        if avgZ < bestZ then
            bestZ = avgZ
            visibleID = f.id
        end
    end
    return visibleID
end

-- Animation Engine Timer
if animTimer then animTimer.Destroy() animTimer=nil end
animTimer = createTimer()
animTimer.Enabled, animTimer.Interval = false, 20

animTimer.OnTimer = function()
    local diffX = tarX - curX
    local diffY = tarY - curY

    -- Smooth Easing Animation (20% approach per frame)
    if math.abs(diffX) > 0.5 then curX = curX + (diffX * 0.2) else curX = tarX end
    if math.abs(diffY) > 0.5 then curY = curY + (diffY * 0.2) else curY = tarY end

    -- On Animation End
    if curX == tarX and curY == tarY then
        animTimer.Enabled = false

        -- Prevent number overflow
        curX, tarX = curX % 360, tarX % 360
        curY, tarY = curY % 360, tarY % 360

        local finalID = getVisibleFaceID()
        if acb["hpnl"..finalID] then
            pnlVsbl()
            acb["hpnl"..finalID].Visible = true
            faceName = acb["hpnl"..finalID]
        end
    end
    drawCube()
end

-- Dynamic Face Position Calculator (DPI and Scale Aware)
local function getFrontFaceRect(targetImg)
    if not targetImg or not targetImg.Width then return nil end

    local centerX = targetImg.Width / 2
    local centerY = targetImg.Height / 2
    local perspectiveBase = targetImg.Width * 1.125
    local distanceBase = targetImg.Width * 1.0

    local perspective = perspectiveBase * cubeScale
    local distance = distanceBase * cubeScale
    local dynamicFactor = perspective / ((-size) + distance)

    -- Applying DPI scaling to offsets (18 and 19 converted to scaled values)
    local padding = 18 * DPI_SCALE
    local offset = 19 * DPI_SCALE
    local displaySize = math.floor((size * 2) * dynamicFactor) - padding

    return {
        left   = math.floor(centerX - (displaySize / 2) + targetImg.Left + offset - 20),
        top    = math.floor(centerY - (displaySize / 2) + targetImg.Top + offset - 20),
        width  = displaySize - (padding * 2) + 40,
        height = displaySize - (padding * 2) + 40
    }
end

-- Setup initial panel positions
local r = getFrontFaceRect(img)
if r then
   for i=1, 6 do
     acb["hpnl"..i].setSize(r.width, r.height)
     acb["hpnl"..i].setPosition(r.left, r.top)
   end
end

-- Initial render
drawCube()
vsblPnl.Visible = true

-- Keyboard Input Timer (Global Key Listener)
if kyTimer then kyTimer.Destroy() kyTimer=nil end
kyTimer = createTimer()
kyTimer.Enabled, kyTimer.Interval = true, 100

local function isFormActive()
    return getForegroundWindow() == myForm.Handle
end

kyTimer.OnTimer = function()
    if animTimer.Enabled or not isFormActive() then return end

    -- Navigation via Arrow Keys
    local move = false
    if isKeyPressed(VK_LEFT) then tarY = tarY + 90 move = true
    elseif isKeyPressed(VK_RIGHT) then tarY = tarY - 90 move = true
    elseif isKeyPressed(VK_UP) then tarX = tarX - 90 move = true
    elseif isKeyPressed(VK_DOWN) then tarX = tarX + 90 move = true end

    if move then
        pnlVsbl()
        animTimer.Enabled = true
    end
end

acb.mbtn5.OnClick=function() myForm.WindowState="wsMinimized" end

acb.mbtn6.OnClick=function()
  myForm.close()
  --closeCE()
  --return caFree
end



Enjoy using them.


Technical Specifications & Keywords

  • Project Name: AylinCE 3D Engine Core
  • Programming Language: Lua (Cheat Engine Environment)
  • Rendering Type: Software-based 3D Wireframe & Polygon Filling
  • Compatibility: DPI-Aware, Scalable UI Systems
  • Features: Z-Depth Depth Sorting, Smooth Easing Animation, Multi-Panel Navigation
  • Search Terms: Cheat Engine 3D UI, Lua Cube Rotation, CE Trainer Interface Design



cbf.PNG
 Description:
 Filesize:  9.54 KB
 Viewed:  743 Time(s)

cbf.PNG



_________________
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
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