Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
996m2 3
https://github.com/zhaixingge/996m2-3-
Admin
内涵服务端开发文档和客户端开发文档
Tokens:
53,294
Snippets:
327
Trust Score:
3.2
Update:
1 year ago
Context
Chat
Benchmark
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### Player Shops: Start and Success (Lua) Source: https://github.com/zhaixingge/996m2-3-/blob/main/服务端开发文档/Lua/脚本触发.md Handles the logic for players starting a shop and confirms shop setup success. Includes a check for player level before allowing shop creation. ```lua function startmyshop(actor) if getbaseinfo(actor,6) < 50 then say(actor,"50级后才可摆摊") forbidmyshop(actor) return end end ``` -------------------------------- ### Lua: Store Interaction Examples Source: https://github.com/zhaixingge/996m2-3-/blob/main/客户端开发文档/接口/功能/界面/打开购买弹窗.txt Provides example Lua code demonstrating various store interactions using the `SL` library. This includes fetching store data, opening/closing buy pop-ups, checking inventory space, and requesting item purchases. ```lua local textList = { {text = "获取商城数据根据页签", func = function() SL:Dump(SL:GetStoreDataByPage(1)) end}, {text = "打开购买弹窗",func = function() SL:OpenStoreBuyPop(SL:GetStoreDataByPage(1)[1]) end}, {text = "关闭购买弹窗",func = function() SL:CloseStoreBuyPop() end}, {text = "检测背包是否有位置", func = function() SL:Dump(SL:CheckNeedSpace(10020, 9999)) end}, {text = "请求查看商城数据(page: 1~5)",func = function() SL:RequestStoreData(1) end}, {text = "请求购买商城道具",func = function() SL:RequestStoreBuyItem(5, 99) end}, } for i, v in ipairs(textList) do local title = GUI:Text_Create(parent, "texts_" .. i, 400, 400 - 30 * i, 18, "#FFFFFF", "点我:" ..v.text) GUI:setTouchEnabled(title, true) GUI:addOnClickEvent(title, function() v.func() end) end -- 商城刷新 SL:RegisterLUAEvent(LUA_EVENT_STORE_REFRESH, "Store_ceshi", function(page) SL:Dump(page) end) ``` -------------------------------- ### Example: Creating and Animating Text Source: https://github.com/zhaixingge/996m2-3-/blob/main/客户端开发文档/GUI/动作(Action).txt This Lua example demonstrates creating a text element and applying a sequence of animations to it, including scaling and a callback function. It utilizes functions like Text_Create, ActionSequence, DelayTime, ActionScaleTo, and CallFunc. ```lua local str = "我的名字" or "" local Text_name = GUI:Text_Create(parent, "Text_name", 0, 0, 16, "#ffffff", str) local function callback() SL:Print("_____") end GUI:runAction(Text_name, GUI:ActionSequence(GUI:DelayTime(1), GUI:ActionScaleTo(0.1, 1.4), GUI:ActionScaleTo(0.1, 1), GUI:CallFunc(callback))) ``` -------------------------------- ### Adding a Top Button with Red Dot Using addbutton Interface Source: https://github.com/zhaixingge/996m2-3-/blob/main/服务端开发文档/Lua/红点功能.md This example demonstrates how to add a button to the main interface and dynamically control its red dot visibility using a variable condition. It includes the necessary script commands and the corresponding `cfg_vui_redpoint` table configuration. ```lua #IF #ACT delbutton 102 99 mov S$主界面Top图标 <Button|id=aaa|children={redxxx}|x=-400|y=10|nimg=private/main/bottom/1900013022.png|link=@aaaa> inc S$主界面Top图标 <Img|id=redxxx|img=private\bag_ui\bag_ui_mobile\item_red.png|visible=1> addbutton 102 99 <$STR(S$主界面Top图标)> ;其中参数visible=1表示该控件默认不可见 ;cfg_vui_redpoint表配置如下,用U1变量控制该按钮的红点是否显示 local config = { [1] = { IDX=1, url="main/main_root", rpName="redxxx", levelCondition="U1=1", }, } return config ``` -------------------------------- ### Get All Storage Items Source: https://github.com/zhaixingge/996m2-3-/blob/main/服务端开发文档/Lua/物品操作.md Retrieves a list of all items currently stored in the player's storage. ```APIDOC ## GET /getstorageitems ### Description Retrieves a list of all items currently stored in the player's storage. ### Method GET ### Endpoint /getstorageitems ### Parameters #### Query Parameters - **play** (object) - Required - Player object. ### Response #### Success Response (200) - **result** (object) - A list of item objects stored in the storage. ``` -------------------------------- ### Example of Setting Custom Item Attributes Source: https://github.com/zhaixingge/996m2-3-/blob/main/服务端开发文档/Lua/物品操作.md This Lua code snippet demonstrates how to construct a table representing custom item attributes and then apply it to an item using `setitemcustomabil`. It also shows how to refresh the item's display afterwards. This example showcases the structure of the 'abil' and 'name' fields within the custom attribute table. ```Lua local tbl = { ["abil"] = { { ["i"] = 0, ["t"] = "[星级测试]\<IMG:3>\星级:3", ["c"] = 251, ["v"] = { {0,3,1,0,1,0,1}, {0,4,1,0,1,0,2}, {0,5,1,0,9,2,3}, {0,6,1,0,9,2,4}, {0,6,1,0,9,2,4}, {0,7,1,0,10,3,5}, {0,8,1,0,10,3,6}, {0,25,0,1,2,4,7}, }, }, }, ["name"] = itemName .. "[锻造 + 1]", } setitemcustomabil(actor,itemobj,tbl2json(tbl)) refreshitem(actor,itemobj) ``` -------------------------------- ### Newbie Interface Guidance Source: https://github.com/zhaixingge/996m2-3-/blob/main/服务端开发文档/Lua/全局函数.md Implements a guided tutorial for new players, directing them to specific UI elements or items. It supports various parameters for defining the target, guidance text, direction, and interaction type (weak/strong). ```lua navigationex 参数 类型 空 默认 注释 player object 否 玩家对象 param1 string 否 父窗口 param2 string 否 节点(没有则填0) param3 string 否 引导描述 param4 integer 否 方向(1~8)从左按顺时针,填0为默认方向 param5 integer 否 是否强制引导(0为弱引导、1为强引导) param6 string 否 SMakeIndex背包道具唯一ID(没有则填0) param7 string 否 点击引导触发,若无触发(没有则填写0) param8 string 否 引导结束回调触发(没有则填写0) 说明: 1、参数1父窗口为F8工具里界面的路径,也可在控制台窗口查看,例如装备界面player_layer/equip,脚本say的界面统一为 npc/npc_talk_layer 2、参数2为F8中的节点名称,如果引导任务栏则填写任务id,若是脚本say的,则填写标签中的id 3、参数6只有在引导背包物品时才有用,其他情况下填0 4、触发的方法名必须以 @diyfunc_ 开头 navigationex(player, "bag_panel/bag_panel", "0", "双击使用", 0, 1, "10001_10544", 0, 0) ``` -------------------------------- ### Get All Bag Items Source: https://github.com/zhaixingge/996m2-3-/blob/main/服务端开发文档/Lua/物品操作.md Retrieves a list of all items present in the player's inventory bag. ```APIDOC ## GET /getbagitems ### Description Retrieves a list of all items present in the player's inventory bag. Can filter by item name and binding status. ### Method GET ### Endpoint /getbagitems ### Parameters #### Query Parameters - **player** (object) - Required - Player object. - **itemName** (string) - Optional - Filters items by this name. - **isbind** (integer) - Optional - Filters by binding status: 0=ignore, 1=unbound, 2=bound. ### Response #### Success Response (200) - **result** (table) - A list of item objects found in the bag. ``` -------------------------------- ### Get Item Info by Index Source: https://github.com/zhaixingge/996m2-3-/blob/main/服务端开发文档/Lua/物品操作.md Retrieves item information from the player's inventory using its index. ```APIDOC ## GET /getiteminfobyindex ### Description Retrieves item information from the player's inventory using its index. This is useful for checking item details before consumption or deletion. ### Method GET ### Endpoint /getiteminfobyindex ### Parameters #### Query Parameters - **play** (object) - Required - Player object. - **index** (integer) - Required - The index of the item in the inventory (0-based). ### Response #### Success Response (200) - **result** (object) - The item object containing detailed information. ``` -------------------------------- ### Store Data Management and UI - Lua Source: https://github.com/zhaixingge/996m2-3-/blob/main/客户端开发文档/接口/功能/游戏/请求购买商城道具.txt Provides Lua code examples for interacting with the store's data and UI. This includes fetching store data by page, opening and closing purchase dialogs, checking for inventory space, and requesting store data. It also demonstrates registering a Lua event for store refreshes. ```Lua local textList = { {text = "获取商城数据根据页签", func = function() SL:Dump(SL:GetStoreDataByPage(1)) end}, {text = "打开购买弹窗",func = function() SL:OpenStoreBuyPop(SL:GetStoreDataByPage(1)[1]) end}, {text = "关闭购买弹窗",func = function() SL:CloseStoreBuyPop() end}, {text = "检测背包是否有位置", func = function() SL:Dump(SL:CheckNeedSpace(10020, 9999)) end}, {text = "请求查看商城数据(page: 1~5)",func = function() SL:RequestStoreData(1) end}, {text = "请求购买商城道具",func = function() SL:RequestStoreBuyItem(5, 99) end}, } for i, v in ipairs(textList) do local title = GUI:Text_Create(parent, "texts_ " .. i, 400, 400 - 30 * i, 18, "#FFFFFF", "点我:" ..v.text) GUI:setTouchEnabled(title, true) GUI:addOnClickEvent(title, function() v.func() end) end -- 商城刷新 SL:RegisterLUAEvent(LUA_EVENT_STORE_REFRESH, "Store_ceshi", function(page) SL:Dump(page) end) ``` -------------------------------- ### Get All Storage Items Source: https://github.com/zhaixingge/996m2-3-/blob/main/服务端开发文档/Lua/物品操作.md Retrieves a list of all items stored in the player's storage. Requires the player object. ```Lua getstorageitems(play) ``` -------------------------------- ### TextInput Content and Events Source: https://github.com/zhaixingge/996m2-3-/blob/main/客户端开发文档/GUI/输入框(TextInput).txt Functions to get text content and handle user events for text input fields. ```APIDOC ## POST /GUI/TextInput_Content_Events ### Description Functions to get text content and handle user events for text input fields. ### Method POST ### Endpoint /GUI/TextInput_Content_Events ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **widget** (obj) - Required - The text input widget object. - **value** (string/function) - Required - The value or callback function to set. ### Request Example (getString) ```json { "widget": "myTextInput", "function": "getString" } ``` ### Request Example (addOnEvent) ```json { "widget": "myTextInput", "function": "addOnEvent", "value": "function(event) { console.log('Input changed:', event); }" } ``` ### Available Functions: - `getString(widget)`: Retrieves the current text content of the input field. - `addOnEvent(widget, eventCB)`: Attaches an event handler function (`eventCB`) to the text input. ### Response #### Success Response (200) - **content** (string) - The text content retrieved by `getString`. - **status** (string) - Indicates success or failure for `addOnEvent`. #### Response Example (getString) ```json { "content": "User entered text" } ``` #### Response Example (addOnEvent) ```json { "status": "success" } ``` ``` -------------------------------- ### Lua: OpenCommonTipsPop Function Example Source: https://github.com/zhaixingge/996m2-3-/blob/main/客户端开发文档/接口/功能/界面/通用弹窗.txt This Lua code snippet demonstrates how to use the OpenCommonTipsPop function to display a general pop-up window. It shows how to configure various parameters like button types, images, text content, callback functions, and input field settings. The function takes a 'data' table as input to customize the pop-up's appearance and behavior. ```lua function ceshi.test(_type) if _type == 1 then SL:Print("拒绝") elseif _type == 2 then SL:Print("同意") end end local data = {} -- data.btnType = 2 --按钮类型 btnType=1 "确定" = 2 "确定","取消" -- data.btnRes={{"res/01/010005.png","res/01/010006.png"},{"res/01/010005.png","res/01/010006.png"}}--按钮图片 -- data.btnStyle={1009,255} --参考 cfg_colour_style 表 或者 data.data={size=16,colour="#ffe400"}自定义样式 -- data.str="<font color='#C0C0C0' size='16'>通用弹窗示例</font>" --文本内容 -- data.callback=ceshi.test --回调函数 参数 == 1 时为"确定"; 参数 == 2 为"取消" -- data.editParams=9999 --输入框参数 可以不传{str, inputMode, maxLength} -- data.showEdit=false --是否显示输入框 --或者 data.btnDesc = {"拒绝","同意"} data.btnRes={{"res/01/010005.png","res/01/010006.png"},{"res/01/010005.png","res/01/010006.png"}}--按钮图片 data.btnStyle={1009,255} --参考 cfg_colour_style 表 data.str="<font color='#C0C0C0' size='16'>通用弹窗示例</font>" --文本内容 data.callback=ceshi.test --回调函数 参数 == 1 时为"拒绝"; 参数 == 2 为"同意" data.showEdit=true --是否显示输入框 data.editParams={str="请输入",inputMonde=4,maxLength=5} --输入框参数{str, inputMode, maxLength}可为空 --[[inputMode 输入框类型: 0 所有字符; 1 邮件地址; 2 整数; 3 电话号吗; 4 地址URL; 5 浮点数; 6 单行字符;]] SL:OpenCommonTipsPop(data) 触发函数[参数1: 点击的按钮id 参数2: 额外参数 table: {editStr=输入框字符串}] ``` -------------------------------- ### Get Text Input String Source: https://github.com/zhaixingge/996m2-3-/blob/main/客户端开发文档/GUI/输入框(TextInput).txt Retrieves the current text content from the input widget. Returns a string. ```Lua local currentText = GUI:TextInput_getString(widget) ``` -------------------------------- ### Get Item Info by Index Source: https://github.com/zhaixingge/996m2-3-/blob/main/服务端开发文档/Lua/物品操作.md Retrieves detailed information about an item in the inventory using its index. Returns the item object if found. ```Lua getiteminfobyindex(play, index) ``` -------------------------------- ### Lua Timeline_Progress Function Example Source: https://github.com/zhaixingge/996m2-3-/blob/main/客户端开发文档/接口/窗口/操作/设置进度条控件的变化动画.txt This Lua code demonstrates how to use the Timeline_Progress function to create and animate a progress bar. It initializes parameters like target progress, step, interval, colors, and a callback function. It also shows the creation of the background and progress bar widgets and sets their properties before calling Timeline_Progress. The function itself is not provided, only its usage. ```lua local idx = 0 local function progress() idx = idx + 1 SL:ShowSystemTips("进度条触发第"..idx.."次进入") end local params = {} params.count = 3 -- 重置次数 params.to = 100 -- 目标进度值 params.step = 1 -- 动画步长 params.interval = 0.02 -- 增长的速度, 默认0.01 params.type = 2, -- 进度条类型 params.colors = { -- 血条颜色变化顺序,可不填 [0] = "#0000FF", [1] = "#00FF00", [2] = "#0000FF", [3] = "#00FF00", [4] = "#0000FF", } params.callback = progress --回调函数 local widgetBg = GUI:Layout_Create(_parent, "layout_widgetBg", 228, 245, 200, 14) GUI:Layout_setBackGroundColor(widgetBg, "#0000FF") GUI:Layout_setBackGroundColorType(widgetBg, 1) local widget = GUI:LoadingBar_Create(widgetBg, "bar_widget",0, 0, "Default/LoadingBarFile.png",0) GUI:LoadingBar_setPercent(widget, 0) GUI:LoadingBar_setDirection(widget, 1) widget:setColor(SL:ConvertColorFromHexString(data.colors[1])) GUI:Timeline_Progress(widget, widgetBg, params) ``` -------------------------------- ### Automated Pathfinding and Navigation Source: https://github.com/zhaixingge/996m2-3-/blob/main/服务端开发文档/Lua/人物相关操作.md Functions for automated player navigation. `gotonow` guides a player to a specific set of coordinates on the current map. The `findpathbegin`, `findpathstop`, and `findpathend` functions are event handlers for pathfinding processes, used for debugging and tracking pathfinding status. ```lua --自动寻路到指定坐标 gotonow(actor,330, 330) --寻路开启 function findpathbegin(actor) release_print("findpathstop",getbaseinfo(actor,1),getconst(actor, "<$ToPointX>"),getconst(actor, "<$ToPointY>")) end --寻路中断 function findpathstop(actor) release_print("findpathstop",getbaseinfo(actor,1)) end --寻路结束 function findpathend(actor) release_print("findpathend",getbaseinfo(actor,1)) end ``` -------------------------------- ### Get Equip Gem Socket Status Source: https://github.com/zhaixingge/996m2-3-/blob/main/服务端开发文档/Lua/物品操作.md Retrieves the current gem socket status for an equipped item. ```APIDOC ## GET /getsocketableitem ### Description Retrieves the current gem socket status for an equipped item. Returns a JSON string indicating which gems are socketed in which holes. ### Method GET ### Endpoint /getsocketableitem ### Parameters #### Query Parameters - **play** (object) - Required - Player object. - **item** (object) - Required - Equipment object. ### Response #### Success Response (200) - **result** (string) - A JSON string representing the socketed gems. Example: `{\"socket0\": 20333, \"socket1\": 0}` where 0 means no gem and -1 means no hole. ``` -------------------------------- ### Create Drag Container with Callbacks (Lua) Source: https://github.com/zhaixingge/996m2-3-/blob/main/客户端开发文档/接口/窗口/创建/创建拖拽容器.txt Creates a draggable container (widget) that can be moved within its parent. It accepts callback functions for handling the start, end, and cancellation of drag operations. The 'ext' parameter allows for additional configurations like 'equipPos' and custom callback functions. ```lua local function beginMoveCallBack(node) GUI:setVisible(node, false) end local function endMoveCallBack(node) GUI:setVisible(node, true) end local function cancelMoveCallBack(node) GUI:setVisible(node, true) end local moveWidget = GUI:MoveWidget_Create(bg, "moveWidget", 35, 35, 70, 70, SL:GetItemForm().PALYER_EQUIP, {equipPos = 1, beginMoveCB = beginMoveCallBack, cancelMoveCB = cancelMoveCallBack, endMoveCB = endMoveCallBack}) ``` -------------------------------- ### Real-time Variable Push Command for Red Dots Source: https://github.com/zhaixingge/996m2-3-/blob/main/服务端开发文档/Lua/红点功能.md This section describes the command used to manually push variable data to the client for red dot updates. It's useful for immediate updates outside the regular detection interval. The command is available in both a generic format and a Lua-specific implementation. ```txt #if #act SENDREDVARTOCLIENT ``` ```lua sendredvartoclient(actor) ``` -------------------------------- ### Get Item Database Field Value Source: https://github.com/zhaixingge/996m2-3-/blob/main/服务端开发文档/Lua/物品操作.md Retrieves a specific field value from an item's database entry. Can be queried by item ID or name, and a field name. Example uses 'stdmode' field for '木剑'. ```Lua getdbitemfieldvalue(itemIdx/itemName, fieldName) ``` -------------------------------- ### 创建富文本控件 (Lua) Source: https://github.com/zhaixingge/996m2-3-/blob/main/客户端开发文档/GUI/多功能富文本(RichTextCustom).txt 使用 `GUI:RichTextCustom_Create` 函数创建一个多功能富文本控件。该函数需要父节点、唯一ID、位置、文本内容、宽度和可选的间距作为参数。支持在文本内容中嵌入道具和特效。 ```Lua local text1 = "<font color='#ff0000' size=20>道具</font>" local item = "{{item,id=10019,width=40, height=40, bgVisible=true}}" local text2 = "特效" local effect = "{{effect, id=62, x=20, y=0, scale=50, speed=1}}" local str = text1 .. item .. text2 .. effect local richText = GUI:RichTextCustom_Create(parent, "richText", 50,200, str, 300) ``` -------------------------------- ### Remove Bubble Element with Lua (RmvBeStrongItem) Source: https://github.com/zhaixingge/996m2-3-/blob/main/客户端开发文档/接口/功能/界面/去除气泡.txt This Lua code demonstrates the usage of SL:RmvBeStrongItem to remove a bubble element. It requires a unique 'id' for the element to be removed. The example also includes setup for GUI elements like text input and buttons for adding and removing bubbles. ```Lua local parent = GUI:Attach_LeftBottom() local layout_input = GUI:Layout_Create(parent, "layout_input", 300, 300, 200, 50, true) GUI:Layout_debug(layout_input) local TextField_input = GUI:TextInput_Create(layout_input, "TextField_input", 0, 0, 200, 50, 18) GUI:TextInput_setInputMode(TextField_input, 2) local handle_add = GUI:Text_Create(parent, "handle_add", 500, 330, 18, "#FFFFFF", "添加气泡") GUI:setTouchEnabled(handle_add, true) GUI:addOnClickEvent(handle_add, function() local index = tonumber(GUI:TextInput_getString(TextField_input)) if not index then return end local data = {} data.id = index -- 唯一ID data.name = "标题" .. index -- 名字 data.order = index -- 排序序号 data.clickCB = function() -- 按钮事件 SL:ShowSystemTips(string.format("我是%s", data.name)) end SL:AddBeStrongItem(data) end) local handle_remove = GUI:Text_Create(parent, "handle_remove", 500, 300, 18, "#FFFFFF", "去除气泡") GUI:setTouchEnabled(handle_remove, true) GUI:addOnClickEvent(handle_remove, function() local index = tonumber(GUI:TextInput_getString(TextField_input)) if not index then return end SL:RmvBeStrongItem({ id = index }) end) ``` -------------------------------- ### AddMoveWidgetTypeEvent Lua Function for Drag and Drop Source: https://github.com/zhaixingge/996m2-3-/blob/main/客户端开发文档/接口/窗口/操作/新增拖拽类型和拖拽事件.txt This Lua function, AddMoveWidgetTypeEvent, is used to register custom drag-and-drop behaviors between different widget types. It takes the source and destination widget type names as strings and optional callback functions for when a drag operation starts or ends. The example demonstrates creating two draggable widgets and a close button to remove them. ```lua -- Custom drag event handlers local function fromToEvent(_, data) SL:Print("++++++FromToEvent 111 -> 222") end local function toFromEvent(_, data) SL:Print("++++++ToFromEvent 222 -> 111") end -- Register the drag-and-drop event for 'from' to 'to' types GUI:AddMoveWidgetTypeEvent("from", "to", fromToEvent, toFromEvent) -- Create the first draggable widget (type 'from') local moveWidget11 = GUI:MoveWidget_Create(GUI:Attach_LeftBottom(), "moveWidget11", 500, 300, 70, 70, SL:GetItemForm().from, {cancelMoveCB = cancelMoveCallBack, endMoveCB = endMoveCallBack}) local img = GUI:Image_Create(moveWidget11, "img", 0, 0, "res/public/word_fubentg_1.png") local tt11 = GUI:Text_Create(moveWidget11, "tt", 0, 35, 18, "#000000", "111") -- Create the second draggable widget (type 'to') local moveWidget22 = GUI:MoveWidget_Create(GUI:Attach_LeftBottom(), "moveWidget22", 300, 300, 70, 70, SL:GetItemForm().to, {cancelMoveCB = cancelMoveCallBack, endMoveCB = endMoveCallBack}) local img = GUI:Image_Create(moveWidget22, "img", 0, 0, "res/public/word_fubentg_2.png") local tt11 = GUI:Text_Create(moveWidget22, "tt", 0, 35, 18, "#000000", "222") -- Create a layout to close/remove the widgets local CloseLayout = GUI:Layout_Create(GUI:Attach_LeftBottom(), "CloseLayout", 600, 300, 60, 60, true) GUI:Layout_debug(CloseLayout) GUI:setTouchEnabled(CloseLayout, true) GUI:addOnClickEvent(CloseLayout, function () GUI:removeFromParent(moveWidget11) GUI:removeFromParent(moveWidget22) GUI:removeFromParent(CloseLayout) end) GUI:Text_Create(CloseLayout, "closeText", 0, 0, 18, "#FFFFFF", "关闭") ``` -------------------------------- ### Create Scaling Actions (GUI) Source: https://github.com/zhaixingge/996m2-3-/blob/main/客户端开发文档/GUI/动作(Action).txt Functions for scaling UI elements. ActionScaleTo scales an element to a specified ratio, and ActionScaleBy scales it by a relative ratio. Both require time and the ratio as input. ```lua GUI:ActionScaleTo(time, ratio) GUI:ActionScaleBy(time, ratio) ``` -------------------------------- ### Get Global Game Information (Lua) Source: https://github.com/zhaixingge/996m2-3-/blob/main/服务端开发文档/Lua/全局信息.md Retrieves various global game information using the `grobalinfo` function. It supports fetching data like player information, server deployment times, player counts, and more. The function takes an integer ID to specify the type of information to retrieve. ```Lua function main(self) say(self,"当前开服天数"..grobalinfo(1).."在线玩家数:"..grobalinfo(6)) end ``` -------------------------------- ### ListView Creation and Basic Configuration Source: https://github.com/zhaixingge/996m2-3-/blob/main/客户端开发文档/GUI/列表容器(ListView).txt Functions for creating a ListView, setting its gravity, direction, and item margins. ```APIDOC ## POST /GUI/ListView_Create ### Description Creates a list view container. ### Method POST ### Endpoint /GUI/ListView_Create ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **parent** (obj) - Required - Parent node object. - **ID** (string) - Required - Unique ID. - **x** (int) - Required - X-coordinate position. - **y** (int) - Required - Y-coordinate position. - **width** (int) - Required - Width of the list view. - **height** (int) - Required - Height of the list view. - **direction** (int) - Required - Layout direction (1: Vertical; 2: Horizontal). ### Request Example ```json { "parent": "someParentObject", "ID": "myListView", "x": 0, "y": 0, "width": 300, "height": 400, "direction": 1 } ``` ### Response #### Success Response (200) - **widget** (obj) - The created ListView object. #### Response Example ```json { "widget": "listViewObject" } ``` --- ## POST /GUI/ListView_setGravity ### Description Sets the alignment of the list view content. ### Method POST ### Endpoint /GUI/ListView_setGravity ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **widget** (obj) - Required - The ListView object. - **value** (int) - Required - Alignment value (0: Left, 1: Right, 2: Center Horizontal, 3: Top, 4: Bottom, 5: Center Vertical). ### Request Example ```json { "widget": "listViewObject", "value": 0 } ``` ### Response #### Success Response (200) - **status** (string) - Operation status. #### Response Example ```json { "status": "success" } ``` --- ## POST /GUI/ListView_setDirection ### Description Sets the scrolling direction of the list view. ### Method POST ### Endpoint /GUI/ListView_setDirection ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **widget** (obj) - Required - The ListView object. - **value** (int) - Required - Scrolling direction (0: Horizontal, 1: Vertical). ### Request Example ```json { "widget": "listViewObject", "value": 1 } ``` ### Response #### Success Response (200) - **status** (string) - Operation status. #### Response Example ```json { "status": "success" } ``` --- ## POST /GUI/ListView_setItemsMargin ### Description Sets the margin between items in the list view. ### Method POST ### Endpoint /GUI/ListView_setItemsMargin ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **widget** (obj) - Required - The ListView object. - **value** (int) - Required - The margin size in pixels. ### Request Example ```json { "widget": "listViewObject", "value": 50 } ``` ### Response #### Success Response (200) - **status** (string) - Operation status. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Character Attribute Management Source: https://github.com/zhaixingge/996m2-3-/blob/main/服务端开发文档/Lua/人物相关操作.md Endpoints for refreshing, getting, and modifying character attributes. ```APIDOC ## POST /api/character/recalcabilitys ### Description Refreshes the character's attributes. ### Method POST ### Endpoint /api/character/recalcabilitys ### Parameters #### Request Body - **play** (object) - Required - The player object. ### Request Example ```json { "play": {} } ``` ### Response #### Success Response (200) Indicates successful refresh of character attributes. #### Response Example ```json { "status": "success" } ``` ## GET /api/character/gethumability ### Description Retrieves a specific attribute value for a character. ### Method GET ### Endpoint /api/character/gethumability ### Parameters #### Query Parameters - **play** (object) - Required - The player object. - **id** (int) - Required - The ID of the attribute to retrieve (1-20). ### Request Example ```json { "play": {}, "id": 5 } ``` ### Response #### Success Response (200) - **result** (int) - The value of the requested attribute. #### Response Example ```json { "result": 150 } ``` ## POST /api/character/changehumability ### Description Modifies a specific attribute value for a character. ### Method POST ### Endpoint /api/character/changehumability ### Parameters #### Request Body - **play** (object) - Required - The player object. - **id** (int) - Required - The ID of the attribute to modify (1-20). - **value** (int) - Required - The new value for the attribute. - **time** (int) - Optional - The duration in seconds for which the attribute change should apply. ### Request Example ```json { "play": {}, "id": 5, "value": 160, "time": 3600 } ``` ### Response #### Success Response (200) Indicates successful modification of the character attribute. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Create GUI Button Source: https://github.com/zhaixingge/996m2-3-/blob/main/客户端开发文档/GUI/按钮(Button).txt Creates a new GUI button with specified parent, ID, position, and initial image. It also demonstrates setting anchor point, title text, font size, and adding an click event. ```lua local BtnOk = GUI:Button_Create(FrameLayout, "BtnOk", 0, 0, "res/public/1900000611.png") GUI:setAnchorPoint(BtnOk, { x = 0.5, y = 0.5 }) GUI:Button_setTitleText(BtnOk, "确定") GUI:Button_setTitleFontSize(BtnOk, 16) GUI:addOnClickEvent(BtnOk, function() -- do something end) ``` -------------------------------- ### Create TextInput Source: https://github.com/zhaixingge/996m2-3-/blob/main/客户端开发文档/GUI/输入框(TextInput).txt Creates a new text input GUI element with specified properties. ```APIDOC ## POST /GUI/TextInput_Create ### Description Creates a new text input GUI element with specified properties. ### Method POST ### Endpoint /GUI/TextInput_Create ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **parent** (obj) - Required - The parent GUI object. - **ID** (string) - Required - A unique identifier for the text input. - **x** (int) - Required - The horizontal position of the text input. - **y** (int) - Required - The vertical position of the text input. - **width** (int) - Required - The width of the text input. - **height** (int) - Required - The height of the text input. - **fontSize** (int) - Required - The font size for the text input. ### Request Example ```json { "parent": "some_parent_object", "ID": "myTextInput", "x": 10, "y": 20, "width": 200, "height": 30, "fontSize": 16 } ``` ### Response #### Success Response (200) - **widget** (obj) - The created text input widget object. #### Response Example ```json { "widget": "text_input_widget_instance" } ``` ``` -------------------------------- ### Get Equip Hole Data Source: https://github.com/zhaixingge/996m2-3-/blob/main/服务端开发文档/Lua/物品操作.md Retrieves the current drilling status of holes in an equipped item. ```APIDOC ## GET /getdrillhole ### Description Retrieves the current drilling status of holes in an equipped item. Returns a JSON string describing the state of each hole. ### Method GET ### Endpoint /getdrillhole ### Parameters #### Query Parameters - **play** (object) - Required - Player object. - **item** (object) - Required - Equipment object. ### Response #### Success Response (200) - **result** (string) - A JSON string detailing the state of each hole (0-9). Example: `{\"hole0\": 1, \"hole1\": 0}`. ``` -------------------------------- ### CheckBox State Management Source: https://github.com/zhaixingge/996m2-3-/blob/main/客户端开发文档/GUI/复选框(CheckBox).txt Functions to set and get the selection state of a CheckBox. ```APIDOC ## CheckBox State Management ### Description Functions to set and get the selection state of a CheckBox. ### Methods - **GUI:CheckBox_setSelected(widget, value)** - Sets the selection state of the checkbox. - **widget** (obj) - Required - The checkbox object. - **value** (bool) - Required - `true` to select, `false` to deselect. - **GUI:CheckBox_isSelected(widget)** - Gets the current selection state of the checkbox. - **widget** (obj) - Required - The checkbox object. - **Returns**: (bool) `true` if selected, `false` otherwise. ### Request Example ```lua -- Select the checkbox GUI:CheckBox_setSelected(checkBox, true) -- Check if the checkbox is selected local isSelected = GUI:CheckBox_isSelected(checkBox) print("Checkbox is selected: " .. tostring(isSelected)) ``` ``` -------------------------------- ### PageView Creation API Source: https://github.com/zhaixingge/996m2-3-/blob/main/客户端开发文档/GUI/翻页容器(PageView).txt Functions for creating and initializing Page View widgets. ```APIDOC ## GUI:PageView_Create ### Description Creates a new Page View container for managing paginated content. ### Method GUI Call ### Endpoint N/A (Function Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **parent** (obj) - Required - The parent object for the new Page View. - **ID** (string) - Required - A unique identifier for the Page View. - **x** (int) - Required - The horizontal position of the Page View. - **y** (int) - Required - The vertical position of the Page View. - **width** (int) - Required - The width of the Page View. - **height** (int) - Required - The height of the Page View. - **direction** (int) - Required - Determines the scroll direction (0 for horizontal, 1 for vertical). ### Request Example ```lua local pageView = GUI:PageView_Create(parent, "pageView", 0, 0, 300, 500, 1) ``` ### Response #### Success Response (200) Returns the created Page View widget object. #### Response Example ```json { "widget": "PageViewObject" } ``` ``` -------------------------------- ### Character Flag and Status Management Source: https://github.com/zhaixingge/996m2-3-/blob/main/服务端开发文档/Lua/人物相关操作.md Endpoints for getting and setting character flags or status indicators. ```APIDOC ## GET /api/character/getflagstatus ### Description Retrieves the value of a character flag or status indicator. ### Method GET ### Endpoint /api/character/getflagstatus ### Parameters #### Query Parameters - **play** (object) - Required - The player object. - **nIndex** (int) - Required - The index of the flag (0-799). ### Request Example ```json { "play": {}, "nIndex": 10 } ``` ### Response #### Success Response (200) - **result** (int) - The value of the specified flag. #### Response Example ```json { "result": 1 } ``` ## POST /api/character/setflagstatus ### Description Sets the value of a character flag or status indicator. ### Method POST ### Endpoint /api/character/setflagstatus ### Parameters #### Request Body - **play** (object) - Required - The player object. - **nIndex** (int) - Required - The index of the flag (0-799). - **nvalue** (int) - Required - The new value for the flag. ### Request Example ```json { "play": {}, "nIndex": 10, "nvalue": 1 } ``` ### Response #### Success Response (200) Indicates successful setting of the character flag value. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Lua: QManage Login and Timer Logic Source: https://github.com/zhaixingge/996m2-3-/blob/main/服务端开发文档/Lua/引用文件.md Implements the login function for an actor and sets up a timer for subsequent events. The timer triggers sending VIP level and drop rate responses using configurations from `NetMsgCfg.lua`. It relies on the Global and Message modules. ```Lua ssrNetMsgCfg = include("QuestDiary/net/NetMsgCfg.lua") function login(actor) Global.login(actor) setontimer(actor, 1, 3, 1) end function ontimer1(actor) log.write("OnTimer1") --vip Message:sendmsg1(actor, ssrNetMsgCfg.main_VipLevelResponse, 10) --爆率 Message:sendmsg1(actor, ssrNetMsgCfg.main_DropRateResponse, 100) end ``` -------------------------------- ### Manage Action Sequences and Spawning (GUI) Source: https://github.com/zhaixingge/996m2-3-/blob/main/客户端开发文档/GUI/动作(Action).txt Enables the creation of complex animation sequences. ActionSequence plays actions in order, while ActionSpawn plays them concurrently. These are essential for choreographing animations. ```lua GUI:ActionSequence(...) GUI:ActionSpawn(...) ``` -------------------------------- ### Lua: Open Store Buy Pop-up Source: https://github.com/zhaixingge/996m2-3-/blob/main/客户端开发文档/接口/功能/界面/打开购买弹窗.txt Opens a purchase pop-up window for a store item. It requires the item's data table as input. This function is part of the `SL` library for managing store interactions. ```lua SL:OpenStoreBuyPop(itemData) ``` -------------------------------- ### Get Custom Item Progress Bar Source: https://github.com/zhaixingge/996m2-3-/blob/main/服务端开发文档/Lua/物品操作.md Retrieves the configuration data for a custom progress bar on an equipped item. ```APIDOC ## GET /getcustomitemprogressbar ### Description Retrieves the configuration data for a custom progress bar on an equipped item. Returns the progress bar's settings as a JSON string. ### Method GET ### Endpoint /getcustomitemprogressbar ### Parameters #### Query Parameters - **play** (object) - Required - Player object. - **item** (object) - Required - The equipment object. - **index** (integer) - Required - The index of the progress bar (0-2). ### Response #### Success Response (200) - **result** (string) - A JSON string containing the progress bar's configuration. ``` -------------------------------- ### TextInput Styling Source: https://github.com/zhaixingge/996m2-3-/blob/main/客户端开发文档/GUI/输入框(TextInput).txt Functions to set font properties, placeholder text, and alignment for text input fields. ```APIDOC ## POST /GUI/TextInput_Setters ### Description Functions to set font properties, placeholder text, and alignment for text input fields. ### Method POST ### Endpoint /GUI/TextInput_Setters ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **widget** (obj) - Required - The text input widget object. - **value** (string/int/function) - Required - The value to set, type depends on the specific setter function. - **value2** (string) - Optional - An additional string value for some font settings. ### Request Example (setFontColor) ```json { "widget": "myTextInput", "function": "setFontColor", "value": "#FF0000" } ``` ### Request Example (setFont) ```json { "widget": "myTextInput", "function": "setFont", "value": "path/to/font.ttf", "value2": "Arial" } ``` ### Request Example (setMaxLength) ```json { "widget": "myTextInput", "function": "setMaxLength", "value": 50 } ``` ### Available Setter Functions: - `setFontColor(widget, value)`: Sets the font color (e.g., "#000000"). - `setFont(widget, value, value2)`: Sets the font (e.g., `value` = font path, `value2` = font name). - `setFontSize(widget, value)`: Sets the font size. - `setPlaceholderFont(widget, value, value2)`: Sets the placeholder font. - `setPlaceholderFontColor(widget, value)`: Sets the placeholder font color. - `setPlaceholderFontSize(widget, value)`: Sets the placeholder font size. - `setPlaceHolder(widget, value)`: Sets the placeholder text. - `setString(widget, value)`: Sets the input string. - `setMaxLength(widget, value)`: Sets the maximum input length. - `setTextHorizontalAlignment(widget, value)`: Sets horizontal text alignment (0=top, 1=bottom, 2=center). - `setInputMode(widget, value)`: Sets the input mode (e.g., password, email, number). ### Response #### Success Response (200) - **status** (string) - Indicates success or failure of the operation. #### Response Example ```json { "status": "success" } ``` ```