Lua接口/客户端函数索引:修订间差异
来自天龙知识库
跳到导航跳到搜索
新建客户端 Lua 接口页:全局函数、对象方法、窗口操作与客户端事件 |
新建客户端 Lua 接口页:全局函数、对象方法、窗口操作与客户端事件 |
||
| 第6行: | 第6行: | ||
<div role="heading" aria-level="2" class="lua-title">客户端 Lua 接口</div> | <div role="heading" aria-level="2" class="lua-title">客户端 Lua 接口</div> | ||
<div>面向客户端脚本的接口参考:全局函数与对象方法。客户端脚本负责界面与本地表现,实际数据以服务器下发为准。</div> | <div>面向客户端脚本的接口参考:全局函数与对象方法。客户端脚本负责界面与本地表现,实际数据以服务器下发为准。</div> | ||
<div class="lua-sub-lg"> | <div class="lua-sub-lg">227 个全局函数 · 70 个对象类(1705 个方法)· 891 个客户端事件 · 353 个界面脚本</div> | ||
</div> | </div> | ||
== 调用方式 == | == 调用方式 == | ||
| 第15行: | 第15行: | ||
== 全局函数 == | == 全局函数 == | ||
共 | 共 227 个,直接作为全局名调用,全部函数见[[Lua接口/客户端函数索引/全局函数|全局函数清单]]。清单里每个函数名都可点进独立页,查看参数含义、返回值与脚本中的真实调用。 | ||
{| class="wikitable" | {| class="wikitable" | ||
| 第23行: | 第23行: | ||
|- | |- | ||
| [[Lua接口/客户端函数索引/全局函数|界面与提示]] | | [[Lua接口/客户端函数索引/全局函数|界面与提示]] | ||
| | | 78 | ||
| CallScriptString、CloseAllWindow、CloseBooth、CloseFangDaohao 等 | | CallScriptString、CloseAllWindow、CloseBooth、CloseFangDaohao 等 | ||
|- | |- | ||
| [[Lua接口/客户端函数索引/全局函数|角色、物品与对象]] | | [[Lua接口/客户端函数索引/全局函数|角色、物品与对象]] | ||
| | | 18 | ||
| AcceptRide、AskDetailByGuid、AskEquipDetial、AskEvaluateAndLevelup 等 | | AcceptRide、AskDetailByGuid、AskEquipDetial、AskEvaluateAndLevelup 等 | ||
|- | |- | ||
| 第35行: | 第35行: | ||
|- | |- | ||
| [[Lua接口/客户端函数索引/全局函数|其他]] | | [[Lua接口/客户端函数索引/全局函数|其他]] | ||
| | | 114 | ||
| | | AnswerLevelUpCode、AutoHit、AutoRunToTarget、AutoRunToTargetEx 等 | ||
|} | |} | ||
== 对象方法 == | == 对象方法 == | ||
对象方法按对象分组;对象名就是脚本里冒号前使用的名称。共 | 对象方法按对象分组;对象名就是脚本里冒号前使用的名称。共 39 个对象类、1543 个方法。每个方法名都可点进独立页,查看参数含义、返回值与脚本中的真实调用。 | ||
{| class="wikitable" | {| class="wikitable" | ||
| 第47行: | 第47行: | ||
|- | |- | ||
| [[Lua接口/客户端函数索引/DataPool|DataPool]] | | [[Lua接口/客户端函数索引/DataPool|DataPool]] | ||
| <small class="lua-muted">实现类 DataPool · | | <small class="lua-muted">实现类 DataPool · 279 个方法</small> | ||
|- | |- | ||
| [[Lua接口/客户端函数索引/Pet|Pet]] | | [[Lua接口/客户端函数索引/Pet|Pet]] | ||
| <small class="lua-muted">实现类 Pet · | | <small class="lua-muted">实现类 Pet · 259 个方法</small> | ||
|- | |||
| [[Lua接口/客户端函数索引/LifeAbility|LifeAbility]] | |||
| <small class="lua-muted">实现类 LifeAbility · 101 个方法</small> | |||
|- | |- | ||
| [[Lua接口/客户端函数索引/PlayerShop|PlayerShop]] | | [[Lua接口/客户端函数索引/PlayerShop|PlayerShop]] | ||
| 第56行: | 第59行: | ||
|- | |- | ||
| [[Lua接口/客户端函数索引/Player|Player]] | | [[Lua接口/客户端函数索引/Player|Player]] | ||
| <small class="lua-muted">实现类 PlayerMySelf · | | <small class="lua-muted">实现类 PlayerMySelf · 80 个方法</small> | ||
|- | |- | ||
| [[Lua接口/客户端函数索引/GameProduceLogin|GameProduceLogin]] | | [[Lua接口/客户端函数索引/GameProduceLogin|GameProduceLogin]] | ||
| <small class="lua-muted">实现类 CGameProduce_Login · 69 个方法</small> | | <small class="lua-muted">实现类 CGameProduce_Login · 69 个方法</small> | ||
|- | |- | ||
| [[Lua接口/客户端函数索引/ | | [[Lua接口/客户端函数索引/TargetPet|TargetPet]] | ||
| <small class="lua-muted">实现类 | | <small class="lua-muted">实现类 TargetPet · 65 个方法</small> | ||
|- | |||
| [[Lua接口/客户端函数索引/PlayerPackage|PlayerPackage]] | |||
| <small class="lua-muted">实现类 PlayerPackage · 60 个方法</small> | |||
|- | |- | ||
| [[Lua接口/客户端函数索引/Guild|Guild]] | | [[Lua接口/客户端函数索引/Guild|Guild]] | ||
| <small class="lua-muted">实现类 Guild · 54 个方法</small> | | <small class="lua-muted">实现类 Guild · 54 个方法</small> | ||
|- | |- | ||
| [[Lua接口/客户端函数索引/GuildLeague|GuildLeague]] | | [[Lua接口/客户端函数索引/GuildLeague|GuildLeague]] | ||
| <small class="lua-muted">实现类 GuildLeague · 47 个方法</small> | | <small class="lua-muted">实现类 GuildLeague · 47 个方法</small> | ||
|- | |- | ||
| [[Lua接口/客户端函数索引/Talk|Talk]] | | [[Lua接口/客户端函数索引/Talk|Talk]] | ||
| <small class="lua-muted">实现类 Talk · | | <small class="lua-muted">实现类 Talk · 47 个方法</small> | ||
|- | |- | ||
| [[Lua接口/客户端函数索引/Target|Target]] | | [[Lua接口/客户端函数索引/Target|Target]] | ||
| <small class="lua-muted">实现类 Character · | | <small class="lua-muted">实现类 Character · 46 个方法</small> | ||
|- | |||
| [[Lua接口/客户端函数索引/City|City]] | |||
| <small class="lua-muted">实现类 CityTable · 45 个方法</small> | |||
|- | |- | ||
| [[Lua接口/客户端函数索引/SystemSetup|SystemSetup]] | | [[Lua接口/客户端函数索引/SystemSetup|SystemSetup]] | ||
| <small class="lua-muted">实现类 SystemSetup · | | <small class="lua-muted">实现类 SystemSetup · 43 个方法</small> | ||
|- | |||
| [[Lua接口/客户端函数索引/SuperTooltips|SuperTooltips]] | |||
| <small class="lua-muted">实现类 SuperTooltips · 41 个方法</small> | |||
|- | |- | ||
| [[Lua接口/客户端函数索引/StallSale|StallSale]] | | [[Lua接口/客户端函数索引/StallSale|StallSale]] | ||
| <small class="lua-muted">实现类 StallSale · 28 个方法</small> | | <small class="lua-muted">实现类 StallSale · 28 个方法</small> | ||
|- | |- | ||
| [[Lua接口/客户端函数索引/Exchange|Exchange]] | | [[Lua接口/客户端函数索引/Exchange|Exchange]] | ||
| <small class="lua-muted">实现类 Exchange · 24 个方法</small> | | <small class="lua-muted">实现类 Exchange · 24 个方法</small> | ||
|- | |||
| [[Lua接口/客户端函数索引/NpcShop|NpcShop]] | |||
| <small class="lua-muted">实现类 NpcShop · 23 个方法</small> | |||
|- | |- | ||
| [[Lua接口/客户端函数索引/StallBuy|StallBuy]] | | [[Lua接口/客户端函数索引/StallBuy|StallBuy]] | ||
| 第103行: | 第106行: | ||
| <small class="lua-muted">实现类 Bank · 17 个方法</small> | | <small class="lua-muted">实现类 Bank · 17 个方法</small> | ||
|- | |- | ||
| [[Lua接口/客户端函数索引/ | | [[Lua接口/客户端函数索引/CActionItem|CActionItem]] | ||
| <small class="lua-muted">实现类 | | <small class="lua-muted">实现类 CActionItem · 16 个方法</small> | ||
|- | |- | ||
| [[Lua接口/客户端函数索引/Friend|Friend]] | | [[Lua接口/客户端函数索引/Friend|Friend]] | ||
| <small class="lua-muted">实现类 Friend · 16 个方法</small> | | <small class="lua-muted">实现类 Friend · 16 个方法</small> | ||
|- | |- | ||
| [[Lua接口/客户端函数索引/FindFriendDataPool|FindFriendDataPool]] | | [[Lua接口/客户端函数索引/FindFriendDataPool|FindFriendDataPool]] | ||
| 第132行: | 第132行: | ||
| [[Lua接口/客户端函数索引/StallBbs|StallBbs]] | | [[Lua接口/客户端函数索引/StallBbs|StallBbs]] | ||
| <small class="lua-muted">实现类 StallBbs · 5 个方法</small> | | <small class="lua-muted">实现类 StallBbs · 5 个方法</small> | ||
|- | |||
| [[Lua接口/客户端函数索引/PetEquipSuitDepart|PetEquipSuitDepart]] | |||
| <small class="lua-muted">实现类 PetEquipSuitDepart · 4 个方法</small> | |||
|- | |||
| [[Lua接口/客户端函数索引/PetEquipSuitUp|PetEquipSuitUp]] | |||
| <small class="lua-muted">实现类 PetEquipSuitUp · 3 个方法</small> | |||
|- | |- | ||
| [[Lua接口/客户端函数索引/Blog|Blog]] | | [[Lua接口/客户端函数索引/Blog|Blog]] | ||
| 第150行: | 第156行: | ||
| [[Lua接口/客户端函数索引/Variable|Variable]] | | [[Lua接口/客户端函数索引/Variable|Variable]] | ||
| <small class="lua-muted">实现类 CVariableSystem · 2 个方法</small> | | <small class="lua-muted">实现类 CVariableSystem · 2 个方法</small> | ||
|- | |||
| [[Lua接口/客户端函数索引/Macro|Macro]] | |||
| <small class="lua-muted">实现类 SceneMacro · 1 个方法</small> | |||
|- | |||
| [[Lua接口/客户端函数索引/AttrCompare|AttrCompare]] | |||
| <small class="lua-muted">实现类 AttrCompare · 1 个方法</small> | |||
|} | |} | ||
窗口控件类(31 个类、162 个方法)见[[Lua接口/客户端窗口操作|客户端窗口操作]],其中的方法同样各有独立页。 | |||
== 已下架接口 == | |||
现有源码里已不再注册、但旧脚本/旧文档可能仍在引用的 9 个接口,页面保留并标注已下架:[[Lua接口/客户端/LifeAbility/ClearSlotFour|LifeAbility:ClearSlotFour]]、[[Lua接口/客户端/LifeAbility/Compound_Preparation|LifeAbility:Compound_Preparation]]、[[Lua接口/客户端/LifeAbility/Do_Combine|LifeAbility:Do_Combine]]、[[Lua接口/客户端/LifeAbility/Do_Enchase|LifeAbility:Do_Enchase]]、[[Lua接口/客户端/LifeAbility/Do_Enchase_Four|LifeAbility:Do_Enchase_Four]]、[[Lua接口/客户端/LifeAbility/Enchase_Confirm|LifeAbility:Enchase_Confirm]]、[[Lua接口/客户端/LifeAbility/Enchase_Four_Confirm|LifeAbility:Enchase_Four_Confirm]]、[[Lua接口/客户端/LifeAbility/Is_SlotFour|LifeAbility:Is_SlotFour]]、[[Lua接口/客户端/LifeAbility/Open_Compose_Gem_Page|LifeAbility:Open_Compose_Gem_Page]]。继续调用会取到 <code>nil</code>,按方法调用会直接报错。 | |||
== 界面脚本 == | == 界面脚本 == | ||
界面上的每个功能面板(钱庄、宝石镶嵌、摆摊、珍兽…)都由 <code>Data/Interface/</code> 下的一个 <code>.lua</code> 脚本负责,共 | 界面上的每个功能面板(钱庄、宝石镶嵌、摆摊、珍兽…)都由 <code>Data/Interface/</code> 下的一个 <code>.lua</code> 脚本负责,共 353 个。想知道某个功能对应哪个客户端文件(<code>.lua</code> 脚本与 <code>.layout.xml</code> 布局),见[[Lua接口/客户端界面索引|客户端界面索引]];布局 <code>.layout.xml</code> 的元素、属性、事件绑定与控件命名约定,见[[Lua接口/客户端界面布局|客户端界面布局]]。 | ||
== 约定 == | == 约定 == | ||
* 参数个数与类型由实现体推断:客户端实现没有结构化注释块,类型来自 <code>args[n].Is/Get*</code> 或 <code>lua_is*/lua_to*</code> 的取值点,取不到类型的参数会缺失。 | * 参数个数与类型由实现体推断:客户端实现没有结构化注释块,类型来自 <code>args[n].Is/Get*</code> 或 <code>lua_is*/lua_to*</code> 的取值点,取不到类型的参数会缺失。 | ||
* | * '''独立页的标题是「归属:名称」''':全局函数直接是函数名,对象方法是 <code>对象名:方法名</code>,窗口控件方法是 <code>控件类:方法名</code>。同名方法可能存在于多个类(如 <code>Show</code> 同属 <code>Window</code> 与 <code>CUIWindowItem</code>),因此必须带归属前缀才能唯一定位。 | ||
* 返回项数来自 <code>return n</code> | * 返回项数来自 <code>return n</code>;实现体把返回值直接转发给内部函数时(<code>return 内部函数(...)</code>),个数由内部实现决定,页面会如实注明而不是写「无返回值」。 | ||
* 每行下方标注的是 | * 每行下方标注的是'''实现体所在的源码文件''',可按函数名回查核对;不标行号,避免源码改动后失效。 | ||
* 数字 0 与 -1 在 Lua 条件判断中都是真值,判断成功必须用明确比较。 | * 数字 0 与 -1 在 Lua 条件判断中都是真值,判断成功必须用明确比较。 | ||
* 客户端函数只影响本机界面与本地数据,不改变服务器状态。 | * 客户端函数只影响本机界面与本地数据,不改变服务器状态。 | ||
2026年10月24日 (六) 14:26的版本
客户端 Lua 接口
面向客户端脚本的接口参考:全局函数与对象方法。客户端脚本负责界面与本地表现,实际数据以服务器下发为准。
227 个全局函数 · 70 个对象类(1705 个方法)· 891 个客户端事件 · 353 个界面脚本
调用方式
- 全局函数直接按名称调用,例如
ShowSystemInfo("文本")。 - 对象方法要先取得对象再用冒号调用,例如
local n = DataPool:GetFriendCount()。 this是当前窗口对象,脚本里的this:RegisterEvent("事件名")、this:Show()属于窗口操作。- 事件名在客户端事件中查阅。
全局函数
共 227 个,直接作为全局名调用,全部函数见全局函数清单。清单里每个函数名都可点进独立页,查看参数含义、返回值与脚本中的真实调用。
| 分组 | 函数数 | 说明 |
|---|---|---|
| 界面与提示 | 78 | CallScriptString、CloseAllWindow、CloseBooth、CloseFangDaohao 等 |
| 角色、物品与对象 | 18 | AcceptRide、AskDetailByGuid、AskEquipDetial、AskEvaluateAndLevelup 等 |
| 系统与设置 | 17 | ClearAllTimer、KillTimer、PlaySound、QuitApplication 等 |
| 其他 | 114 | AnswerLevelUpCode、AutoHit、AutoRunToTarget、AutoRunToTargetEx 等 |
对象方法
对象方法按对象分组;对象名就是脚本里冒号前使用的名称。共 39 个对象类、1543 个方法。每个方法名都可点进独立页,查看参数含义、返回值与脚本中的真实调用。
| 对象 | |
|---|---|
| DataPool | 实现类 DataPool · 279 个方法 |
| Pet | 实现类 Pet · 259 个方法 |
| LifeAbility | 实现类 LifeAbility · 101 个方法 |
| PlayerShop | 实现类 PlayerShop · 87 个方法 |
| Player | 实现类 PlayerMySelf · 80 个方法 |
| GameProduceLogin | 实现类 CGameProduce_Login · 69 个方法 |
| TargetPet | 实现类 TargetPet · 65 个方法 |
| PlayerPackage | 实现类 PlayerPackage · 60 个方法 |
| Guild | 实现类 Guild · 54 个方法 |
| GuildLeague | 实现类 GuildLeague · 47 个方法 |
| Talk | 实现类 Talk · 47 个方法 |
| Target | 实现类 Character · 46 个方法 |
| City | 实现类 CityTable · 45 个方法 |
| SystemSetup | 实现类 SystemSetup · 43 个方法 |
| SuperTooltips | 实现类 SuperTooltips · 41 个方法 |
| StallSale | 实现类 StallSale · 28 个方法 |
| Exchange | 实现类 Exchange · 24 个方法 |
| NpcShop | 实现类 NpcShop · 23 个方法 |
| StallBuy | 实现类 StallBuy · 19 个方法 |
| Bank | 实现类 Bank · 17 个方法 |
| CActionItem | 实现类 CActionItem · 16 个方法 |
| Friend | 实现类 Friend · 16 个方法 |
| FindFriendDataPool | 实现类 CFindFriendDataPool · 10 个方法 |
| PetInviteFriend | 实现类 PetInviteFriend · 9 个方法 |
| FriendSearcher | 实现类 FriendSearcher · 8 个方法 |
| AbilityTeacher | 实现类 AbilityTeacher · 7 个方法 |
| CommisionShop | 实现类 CommisionShop · 7 个方法 |
| MissionReply | 实现类 MissionReply · 6 个方法 |
| StallBbs | 实现类 StallBbs · 5 个方法 |
| PetEquipSuitDepart | 实现类 PetEquipSuitDepart · 4 个方法 |
| PetEquipSuitUp | 实现类 PetEquipSuitUp · 3 个方法 |
| Blog | 实现类 Blog · 3 个方法 |
| GemCarve | 实现类 GemCarve · 3 个方法 |
| Sound | 实现类 CSoundSystemFMod · 3 个方法 |
| Helper | 实现类 CHelperSystem · 3 个方法 |
| GemMelting | 实现类 GemMelting · 2 个方法 |
| Variable | 实现类 CVariableSystem · 2 个方法 |
| Macro | 实现类 SceneMacro · 1 个方法 |
| AttrCompare | 实现类 AttrCompare · 1 个方法 |
窗口控件类(31 个类、162 个方法)见客户端窗口操作,其中的方法同样各有独立页。
已下架接口
现有源码里已不再注册、但旧脚本/旧文档可能仍在引用的 9 个接口,页面保留并标注已下架:LifeAbility:ClearSlotFour、LifeAbility:Compound_Preparation、LifeAbility:Do_Combine、LifeAbility:Do_Enchase、LifeAbility:Do_Enchase_Four、LifeAbility:Enchase_Confirm、LifeAbility:Enchase_Four_Confirm、LifeAbility:Is_SlotFour、LifeAbility:Open_Compose_Gem_Page。继续调用会取到 nil,按方法调用会直接报错。
界面脚本
界面上的每个功能面板(钱庄、宝石镶嵌、摆摊、珍兽…)都由 Data/Interface/ 下的一个 .lua 脚本负责,共 353 个。想知道某个功能对应哪个客户端文件(.lua 脚本与 .layout.xml 布局),见客户端界面索引;布局 .layout.xml 的元素、属性、事件绑定与控件命名约定,见客户端界面布局。
约定
- 参数个数与类型由实现体推断:客户端实现没有结构化注释块,类型来自
args[n].Is/Get*或lua_is*/lua_to*的取值点,取不到类型的参数会缺失。 - 独立页的标题是「归属:名称」:全局函数直接是函数名,对象方法是
对象名:方法名,窗口控件方法是控件类:方法名。同名方法可能存在于多个类(如Show同属Window与CUIWindowItem),因此必须带归属前缀才能唯一定位。 - 返回项数来自
return n;实现体把返回值直接转发给内部函数时(return 内部函数(...)),个数由内部实现决定,页面会如实注明而不是写「无返回值」。 - 每行下方标注的是实现体所在的源码文件,可按函数名回查核对;不标行号,避免源码改动后失效。
- 数字 0 与 -1 在 Lua 条件判断中都是真值,判断成功必须用明确比较。
- 客户端函数只影响本机界面与本地数据,不改变服务器状态。
- 未在游戏内执行验证,编号类参数与取值需按本服实机确认。