👉Starting Guide

To execute your script move the .lua file into the %cheat_dir%/scripts folder.


Callbacks

Most of your code will be executed inside the callbacks. To register the callback function, your script should return a table in the following format:

return {
    CallbackName = FuncHandler,
}
Example
-- much more convenient way for big scripts
local script = {}

function script.OnUpdate()
    print("OnUpdate")
end

return script

or

return {
    OnUpdate = function() 
        print("OnUpdate")
    end,
}

Example Script

There is example script you can rely on:

Example
local example = {}

--#region UI

local tab = Menu.Create("General", "Main", "Example")
tab:Icon("\u{f6b6}")
local group = tab:Create("Main"):Create("Group")

local ui = {}

ui.global_switch = group:Switch("Global Switch", false, "\u{f00c}")

ui.auto_phase = group:Switch("Auto Phase Boots", true, "panorama/images/items/phase_boots_png.vtex_c")
ui.custom_radius = group:Slider("Custom Radius", 0, 1000, 0, function (value)

    if value == 0 then return "Disabled" end

    return tostring(value)
end)
ui.custom_radius:Icon("\u{f1ce}")
ui.radius_color = group:ColorPicker("Radius Color", Color(255, 255, 255), "\u{f53f}")
ui.vbe_render = group:Switch("VBE Render", false, "\u{f06e}")
ui.particle_notif = group:Switch("Particle Notification", false, "\u{f0f3}")

ui.global_switch:SetCallback(function ()

    ui.auto_phase:Disabled(not ui.global_switch:Get())
    ui.custom_radius:Disabled(not ui.global_switch:Get())
    ui.radius_color:Disabled(not ui.global_switch:Get())
    ui.vbe_render:Disabled(not ui.global_switch:Get())
    ui.particle_notif:Disabled(not ui.global_switch:Get())
end, true)

--#endregion UI

--#region Vars

local my_hero = nil
local particle = nil
local need_update_particle = false
local need_update_color = false

ui.custom_radius:SetCallback(function ()

    need_update_particle = true

    if ui.global_switch:Get() then

        ui.radius_color:Disabled(ui.custom_radius:Get() == 0)
    end
end, true)

ui.radius_color:SetCallback(function ()

    need_update_color = true
end)

--#endregion Vars

local auto_phase = function ()

    if not ui.auto_phase:Get() then return end

    local item = NPC.GetItem(my_hero, "item_phase_boots")

    if not item then return end

    if not Ability.IsCastable(item, NPC.GetMana(my_hero)) then return end

    if not NPC.IsRunning(my_hero) then return end

    Ability.CastNoTarget(item)
    return true
end

local custom_radius = function ()

    if ui.custom_radius:Get() == 0 or need_update_particle or not Entity.IsAlive(my_hero) then

        Particle.Destroy(particle)
        particle = nil
        need_update_particle = false
        return
    end

    if not particle then

        particle = Particle.Create("particles/ui_mouseactions/drag_selected_ring.vpcf", Enum.ParticleAttachment.PATTACH_ABSORIGIN_FOLLOW, my_hero)

        Particle.SetControlPoint(particle, 2, Vector(ui.custom_radius:Get(), 255, 255))
        local color = ui.radius_color:Get()
        color = Vector(color.r, color.g, color.b)
        Particle.SetControlPoint(particle, 1, color)
    end

    if particle and need_update_color then

        local color = ui.radius_color:Get()
        color = Vector(color.r, color.g, color.b)
        Particle.SetControlPoint(particle, 1, color)
    end
end

local font = Render.LoadFont("MuseoSansEx", Enum.FontCreate.FONTFLAG_ANTIALIAS)

local vbe_render = function ()

    if not ui.vbe_render:Get() then return end

    local is_visible = NPC.IsVisibleToEnemies(my_hero)

    if not is_visible then return end

    local pos = Entity.GetAbsOrigin(my_hero) + Vector(0, 0, NPC.GetHealthBarOffset(my_hero))
    local render_pos, pos_is_visible = Render.WorldToScreen(pos)

    if not pos_is_visible then return end

    local x, y = render_pos.x, render_pos.y - 80

    local text = "Visible"
    local text_size = Render.TextSize(font, 30, text)

    x = x - text_size.x / 2

    Render.Text(font, 30, text, Vec2(x + 1, y + 1), Color(0, 0, 0))
    Render.Text(font, 30, text, Vec2(x, y), Color(255, 255, 255))
end

--#region Callbacks

example.OnParticleCreate = function (data)

    if not ui.global_switch:Get() or not ui.particle_notif:Get() then return end

    --[[ data:
        {
          "index": "4",
          "entity_id": "-1",
          "fullName": "particles/units/heroes/hero_crystalmaiden/maiden_crystal_nova.vpcf",
          "hash": "3519047136",
          "particleNameIndex": "-2119646217882970990",
          "name": "maiden_crystal_nova",
          "attachType": "2",
          "entityForModifiers": "<userdata>",
          "entity_for_modifiers_id": "214"
        }
    ]]

    if data.entityForModifiers then

        local str = '<img class="HeroIcon" src="file://{images}/heroes/'..Entity.GetUnitName(data.entityForModifiers)..'.png"/>'.." "..data.fullName
        Chat.Print("ConsoleChat", str) --chat

        Notification ({ --side
            duration = 3,
            timer = 3,
            hero = Entity.GetUnitName(data.entityForModifiers),
            -- primary_text = "Sunstrike",
            -- primary_image = "panorama/images/spellicons/invoker_sun_strike_png.vtex_c",
            --secondary_image = "panorama/images/spellicons/invoker/magus_apex/invoker_sun_strike_png.vtex_c",
            secondary_text = data.fullName,
            -- active = false,
            position = Entity.GetAbsOrigin(data.entityForModifiers),
            --sound = "sounds/ui/yoink"
        })
    else

        Chat.Print("ConsoleChat", data.fullName) --chat

        Notification ({ --side
            duration = 3,
            timer = 3,
            --hero = Entity.GetUnitName(data.entityForModifiers),
            primary_text = "Particle Create",
            primary_image = "panorama/images/emoticons/dotakin_roshan_stars_png.vtex_c",
            secondary_image = "\u{2b}",
            secondary_text = data.fullName,
            -- active = false,
            --position = Entity.GetAbsOrigin(data.entityForModifiers),
            --sound = "sounds/ui/yoink"
        })
    end
end

example.OnDraw = function ()

    if not ui.global_switch:Get() or not my_hero then return end

    vbe_render()
end

example.OnUpdate = function ()

    if not ui.global_switch:Get() then

        if particle then

            Particle.Destroy(particle)
            particle = nil
        end

        return
    end

    if not my_hero then my_hero = Heroes.GetLocal(); return end

    custom_radius()

    if auto_phase() then return end
end

--#endregion Callbacks

return example

Here are some useful links:

Last updated