LUA Simple Cheat Form

TheyCallMeTim13

Wiki Monster
Talents
Fearless Donors
Mar 3, 2017
418
46
28
#1
Simple Cheat Form


https://wiki.cheatengine.org/index.php?title=Lua#Classes
Lua:
local AboutText = [[Author: Joe's Mom]]
local Hooks = {
    {
        Caption = 'Test 1',
        Function = function(frm, hook, ...)
            print(hook.Name)
            print(hook.Caption)
        end,
    },
    {
        Caption = 'Test 2',
        Function = function(frm, hook, ...)
            if frm[hook.Name].Checked then
                speak('I have the Power!')
            else
                speak('It\'s gone.')
            end
        end,
    },
    {
        Caption = 'Try this one!',
        Function = function(frm, hook, ...)
            print(hook.SomeCustomData)
        end,
        SomeCustomData = 'Hay, Hay, Hay!',
    },
}

local formCaption = 'Some Cool Stuff'
local addIndexToName = true
local addButtons = true
local fW = 200 -- Form width
local sX = fW - 10 -- Size X
local sY = 23 -- Size Y
local pX = 3 -- Position X
local pY = 3 -- Position Y
local bW = 75 -- Button Width
local bH = 24 -- Button Hight
local padF = 5 -- Form Padding
local push1 = 25

local pad1 = 3
local pad2 = 1

local function showForm()
    local row = 0
    local frmMain = createForm(false)
    frmMain.centerScreen()
    frmMain.setSize(fW, fH)
    frmMain.Name = 'frmMain'
    frmMain.Caption = formCaption
    for i = 1, #Hooks do
        local cbxHook = createCheckBox(frmMain)
        if Hooks[i].Name == nil then
            Hooks[i].Name = 'cbHook' .. string.format('%03d', i)
        elseif addIndexToName then
            Hooks[i].Name = Hooks[i].Name .. string.format('%03d', i)
        end
        cbxHook.Name = Hooks[i].Name
        cbxHook.setSize(sX, sY)
        cbxHook.setPosition(pX + push1, pY + sY * row + pad2)
        cbxHook.Caption = Hooks[i].Caption
        cbxHook.OnChange = function(...)
            Hooks[i].Function(frmMain, Hooks[i], ...)
        end
        row = row + 1
    end
    if addButtons then
        local btnAbout = createButton(frmMain)
        btnAbout.Name = 'btnAbout'
        btnAbout.Caption = 'About'
        btnAbout.setSize(bW, bH)
        btnAbout.setPosition((fW / 2) - (bW + ((pY + sY) / 2)), pY + sY * row + pad2)
        btnAbout.OnClick = function(...)
            print(AboutText)
        end
        local btnClose = createButton(frmMain)
        btnClose.Name = 'btnClose'
        btnClose.Caption = 'Close'
        btnClose.setSize(bW, bH)
        btnClose.setPosition(((fW / 2) * 2) - (bW + ((pY + sY) / 2)), pY + sY * row + pad2)
        btnClose.OnClick = function(...)
            frmMain.close(...)
        end
        row = row + 1
    end
    frmMain.setSize(fW, pY + sY * row + padF)
    frmMain.show()
end

-- hideAllCEWindows()
showForm()
 
Last edited:
Top Bottom