HOOZi文档
Skip to content

全局 + 总览

字段查表入口:模块结构总览、风格约定、全局变量。每个模块的详细字段和签名在侧栏对应页里。


模块结构总览

══ 全局 ═════════════════════════════════════════════════════════════════
_SCRIPT_PATH        当前脚本路径(read-only)
print               重定向到 log.info
Delay(sec, fn)      延迟 sec 秒后执行 fn(脚本卸载自动取消)
shared              跨脚本共享 lua table

══ 主域 9 ═══════════════════════════════════════════════════════════════

event                                   订阅
├─ on(name, fn) → handle
└─ off(handle)

gui                                     菜单 UI + 配置写入(唯一写路径)
├─ tab / sub_tab / window
├─ find / get / set / children       children(path) 返某容器直接子控件数组
├─ show / hide / set_enabled / set_visible
├─ is_visible / get_main_window      菜单状态 + 几何
├─ list_hotkeys                       拿当前所有热键控件 (Checkbox + KeybindControl)
├─ get_selected_weapon               武器库当前选中武器 ID
├─ 容器方法: group/checkbox/slider/slider_float/dropdown/
│             combobox/slider_range/color_edit/input_text/multi_dropdown/
│             keybind_control/tips/live_table/button/settings
│             settings(id,label,icon?) 齿轮折叠容器
├─ custom(id, proto, height?)        Lua-driven 自定义控件 (LuaControlProto 风格)
└─ Window 独有: bind_visible

esp                                     ESP 元素
├─ add / find / remove
├─ elements / scenario
└─ INV / VIS / DWN / ALLY

game                                    实时数据(read-only,写抛 error)
├─ localplayer
├─ entities.{players,loots,projectiles}
├─ aimbot                               含 trigger / solve / register_algorithm / set_predictor
└─ world.{ring,map_name}

net
├─ http: get / post / request             仅异步(回调在菜单线程派发)
├─ ws:   connect / send / close / is_open 客户端,全异步 4 回调
└─ ws_server: listen → :send / :broadcast / :disconnect / :close

draw                                    屏幕绘制
├─ line / rect / rect_gradient
├─ triangle_multicolor / circle_multicolor
├─ circle / triangle / quad / polyline
├─ shadow_line / shadow_rect / glow_circle  阴影 + 外发光
├─ text / image / image_rotated
├─ push_clip / pop_clip                 矩形裁剪栈
├─ measure / screen / fonts / font
└─ rgba / u8 / hex / color_mod_a / color_lerp
   color_darken / color_lighten / color_hsv

math                                    扩展 Lua stdlib
├─ Vec2 / Vec3
├─ Lerp / Clamp / Smoothstep
├─ RemapVal / RemapValClamped
├─ AngleNormalize / CalcAngle
├─ WorldToScreen / WorldToMapPixel / WorldRadiusToMapPixel
└─ ease_in / ease_out / ease_in_out / ease_in_cubic
   ease_out_cubic / ease_bounce

file                                    文件 + 资源
├─ read / write / exists / remove / rename
├─ list / scan(glob)
└─ image: load / svg / create / get / has / list / remove
   load_gif / animated 多帧动画

input                                   输入 + keybind formatter + 剪贴板
├─ is_active / format / unformat
└─ clipboard_get / clipboard_set

══ 杂项 8 ═══════════════════════════════════════════════════════════════

log         info / success / warn / error
notify      info / success / warn / error
script      load / unload
time        now / delta / curtime / game / frame_count
config      save / save_as / switch / list / current
json        encode / decode
utils       base64_encode / base64_decode / array_to_string / string_to_array
            murmur2 / fnv1a / unix_time / get_date
            db_save / db_load  (脚本级 KV 持久化)
            (剪贴板已迁出 → input.clipboard_get / clipboard_set)
mem         get_module_base / get_module_size / is_valid / find_pattern
            read_* / scatter / write_* / write_scatter  (DMA 读+写;写危险见 mem 页)
offsets     具名偏移表 offsets[section][sub][key] / offsets.find  (dumper 同步,配 .base 自助读写)

风格约定

写法用途
obj:method(args)stateful 对象方法(gui.find、网络、文件资源、esp element)
obj.fieldread-only 数据字段(game.* / event 参数 / entity 属性)
module.sub.fieldmodule.sub:method嵌套 namespace(net.http / game.entities / file.image
module.func(args)模块快捷函数

命名:模块全小写单字 / 函数字段 snake_case / 常量 SCREAMING_CASE / Usertype CamelCase / 事件名 snake_case 字符串

Owner-scoped 自动清理:脚本卸载时以下资源自动释放,无需手写 script_unloaded 监听

  • event.on 订阅(含自定义事件 handler)
  • Delay() 待触发条目(未到期一并取消)
  • esp.add 元素
  • gui.* 创建的容器和控件
  • input.format keybind formatter
  • net.http 回调(alive flag — 排队中的回调静默丢弃)
  • net.ws:connect 连接 + net.ws_server:listen 监听(含所有 client)
  • file.image:load/svg/create/load_gif 纹理

全局变量

_SCRIPT_PATH : string (read-only)

当前正在执行的脚本路径(相对 scripts/)。脚本加载前由运行时注入。

print(...)

重定向到 log.info

Delay(sec : number, fn : function)

延迟 sec 秒后调用 fn(一次性)。在 render 线程触发,跟 event.on("frame_update", ...) 同步。脚本卸载时未到期的 Delay 自动取消,不需手动清理。

lua
Delay(0.5, function() print("0.5s 后打印") end)

-- 配 Delay 做轮询/重试
local function retry(n)
    if n <= 0 then return end
    net.http:get("https://api/heartbeat", function(resp)
        if not resp.ok then Delay(1, function() retry(n - 1) end) end
    end)
end
retry(3)

shared : table

跨脚本共享的普通 Lua table。任意脚本可读写,生命周期与 Lua state 一致。写入立即对其他脚本可见,无快照、无锁。

reload 不清空:脚本 reload 仅卸载该脚本注册的 GUI / event / esp 等资源,shared 本身在 Lua state 创建时建一次后不会被清。需要"重置 namespace"的脚本要在 script 头部手动 shared.my_ns = {}

详细写法见 入门指南