跳转至

API 参考

Lua 脚本可用的 API 函数列表。

玩家对象 (Player)

属性

属性 类型 说明
Name string 角色名称
Level int 角色等级
Job int 职业 (0战士/1法师/2道士)
Gold int 金币
GameGold int 元宝

方法

-- 发送消息
player:SendMessage("消息内容")

-- 发放物品
player:GiveItem("物品名", 数量)

-- 扣除物品
player:TakeItem("物品名", 数量)

-- 检查物品
local has = player:HasItem("物品名", 数量)

-- 传送
player:MoveTo(mapId, x, y)

-- 添加 BUFF
player:AddBuff(buffId, duration)

全局函数

-- 全服公告
SendWorldMessage("公告内容")

-- 获取在线玩家
local players = GetOnlinePlayers()

-- 定时器
SetTimer(function()
    print("5秒后执行")
end, 5000)

数据存储

-- 保存数据
player:SetData("key", value)

-- 读取数据
local value = player:GetData("key")

-- 每日标记
player:SetDailyFlag("flag", 1)
local flag = player:GetDailyFlag("flag")