### Start Dialogue Source: https://u5-creator.s3.game.163.com/manual/mobile/eggycode/category_action.html Initiates a dialogue for a player. ```APIDOC ## Start Dialogue ### Description Player {#0} starts dialogue {#1}. ### Parameters 1. Optional: Player, Player List 2. Dialogue Preset ``` -------------------------------- ### Get Obstacles by Raycast Source: https://u5-creator.s3.game.163.com/manual/pc_md/lua/EggyAPI.html Fetches a list of obstacles that intersect with a raycast. It requires start and end points (Point3) for the raycast and returns a ListObstacle. ```javascript GameAPI.get_obstacles_by_raycast(_start_pos, _end_pos) ``` -------------------------------- ### 初始化并行计算线程 Source: https://u5-creator.s3.game.163.com/manual/pc_md/lua/lua_advance.html 在游戏启动时调用以设置辅助计算线程的数量。该函数仅能调用一次,建议放置在 main.lua 的入口处。 ```lua LuaAPI.dispatch_init(2) -- 设置并行计算辅助线程数为2 ``` -------------------------------- ### Get Custom Trigger Spaces in Raycast Source: https://u5-creator.s3.game.163.com/manual/pc_md/lua/EggyAPI.html Retrieves a list of custom trigger spaces that intersect with a raycast. It requires start and end points (Point3) for the raycast and returns a ListCustomTriggerSpace. ```javascript GameAPI.get_customtriggerspaces_in_raycast(_start_pos, _end_pos) ``` -------------------------------- ### Creating Welding Preview Prefab and Initialization (Lua) Source: https://u5-creator.s3.game.163.com/manual/pc_md/game_demo/lua_demo_build.html This code demonstrates how to create a welding preview indicator using a prefab and initialize it for each player upon game start. It retrieves prefab data and dynamically creates obstacles for visual feedback during the welding process. ```lua -- Prefab.lua data is automatically generated by the editor local UnitPrefab = require("Data.Prefab").unit for _, role in ipairs(GameAPI.get_all_valid_roles()) do local roleId = role.get_roleid() -- Create an indicator for previewing the welding position self.previewUnits[roleId] = GameAPI.create_obstacle( UnitPrefab["焊接预览"], math.Vector3(0, 0, 0), math.Quaternion(0, 0, 0), math.Vector3(scale, scale, scale), role ) ---"Code omitted"--- end ``` -------------------------------- ### Registering Purchase Success Event and Initializing UI (Lua) Source: https://u5-creator.s3.game.163.com/manual/pc_md/game_demo/lua_demo_shopping.html Handles game initialization by registering event listeners for button clicks and purchase success. It iterates through all valid roles, refreshes their mall panels, and sets up a listener for the 'SPEC_ROLE_PURCHASE_GOODS' event to refresh the mall UI upon successful purchase. ```Lua -- 游戏开始事件 LuaAPI.global_register_trigger_event({ EVENT.GAME_INIT }, function() -- 注册按钮事件 register_events() -- 获取所有有效角色 local allRoles = GameAPI.get_all_valid_roles() for _, role in ipairs(allRoles) do -- 刷新商城界面 refresh_mall_panel(role) -- 注册购买成功事件 LuaAPI.global_register_trigger_event({ EVENT.SPEC_ROLE_PURCHASE_GOODS, role.get_roleid() }, function(_, _, data) -- 购买成功后刷新角色商城界面 refresh_mall_panel(role) end) end end) ``` -------------------------------- ### Get First Custom Trigger Space in Raycast Source: https://u5-creator.s3.game.163.com/manual/pc_md/lua/EggyAPI.html Finds the first custom trigger space encountered by a raycast. It takes start and end points (Point3) and returns a single CustomTriggerSpace object. ```javascript GameAPI.get_first_customtriggerspace_in_raycast(_start_pos, _end_pos) ``` -------------------------------- ### 封装异步回调引擎 Source: https://u5-creator.s3.game.163.com/manual/pc_md/lua/lua_advance.html 通过封装 queue/sync 过程,将异步调用转化为回调函数形式,简化多任务处理逻辑。 ```lua local Engine = {} local dispatchCallbacks = {} function Engine.Setup(asyncCount) LuaAPI.dispatch_init(asyncCount) end function Engine.Dispatch(asyncIndex, functionName, params, callback) table.insert(dispatchCallbacks, callback or false) LuaAPI.dispatch_queue(asyncIndex, functionName, params) end function Engine.Flush() LuaAPI.dispatch_flush() end function Engine.Tick() local result = LuaAPI.dispatch_sync() for i, v in ipairs(result) do local callback = dispatchCallbacks[i] if callback then callback(v[1], v[2]) else error("Error occured in Engine.Tick() " .. v[2]) end end dispatchCallbacks = {} end return Engine ``` -------------------------------- ### Get Camera Direction Source: https://u5-creator.s3.game.163.com/manual/pc_md/lua/EggyAPI.html Gets the direction the player's camera is facing. This requires player camera rotation synchronization to be enabled and returns a Vector3. ```lua Role.get_camera_direction() ``` -------------------------------- ### GET /character/area-detection Source: https://u5-creator.s3.game.163.com/manual/pc_md/eggycode/category_args.html 基于几何区域检测角色或生物。 ```APIDOC ## GET /character/area-detection ### Description 在指定的球形或矩形区域内筛选符合阵营关系的角色或生物列表。 ### Method GET ### Endpoint /character/area-detection ### Parameters #### Query Parameters - **center** (坐标点) - Required - 检测中心点 - **radius** (定点数) - Optional - 球形半径 - **length/width/height** (定点数) - Optional - 矩形尺寸 - **relation** (阵营关系类型) - Required - 筛选的阵营关系 ### Response #### Success Response (200) - **list** (array) - 符合条件的角色/生物列表 ``` -------------------------------- ### Character Setup and Equipment Source: https://u5-creator.s3.game.163.com/manual/pc_md/game_demo/lua_demo_mowing.html Iterates through all valid roles in the game, retrieves their control units, and sets their reborn properties. It then creates and equips a sword and a gun to each character. ```Lua for _, role in ipairs(GameAPI.get_all_valid_roles()) do local character = role.get_ctrl_unit() character.set_reborn_in_place(true, false) -- 创建并装备剑 local sword = GameAPI.create_equipment(ItemData.Sword.prefabID, character.get_position()) character.swap_equipment_slot(sword, Enums.EquipmentSlotType.EQUIPPED, 1) -- 创建并装备枪 local gun = GameAPI.create_equipment(ItemData.Gun.prefabID, character.get_position()) character.swap_equipment_slot(gun, Enums.EquipmentSlotType.EQUIPPED, 2) end ``` -------------------------------- ### EditorAPI.input_equipment_prefab Source: https://u5-creator.s3.game.163.com/manual/pc_md/lua/EggyEditorAPI.html Imports equipment prefab data from a specified file path. ```APIDOC ## POST /EditorAPI/input_equipment_prefab ### Description Imports equipment prefab data from a specified file path. ### Method POST ### Endpoint /EditorAPI/input_equipment_prefab ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **_path** (Str) - Required - The file path from which to import the equipment prefab data. ### Request Example ```json { "_path": "/path/to/equipment_prefab.json" } ``` ### Response #### Success Response (200) - **status** (String) - Indicates the result of the import operation. #### Response Example ```json { "status": "Equipment prefab imported successfully." } ``` ``` -------------------------------- ### GET /character/spatial Source: https://u5-creator.s3.game.163.com/manual/pc_md/eggycode/category_args.html 查询角色或生物的空间属性,如位置、朝向、速度等。 ```APIDOC ## GET /character/spatial ### Description 获取角色或生物的物理空间属性,包括位置、旋转、线速度和角速度。 ### Method GET ### Endpoint /character/spatial ### Parameters #### Path Parameters - **target** (角色I生物) - Required - 目标角色或生物对象 ### Response #### Success Response (200) - **position** (vector3) - 坐标位置 - **rotation** (vector3) - 旋转角 - **linear_velocity** (vector3) - 线速度 - **angular_velocity** (vector3) - 角速度 ``` -------------------------------- ### 执行与获取异步任务结果 Source: https://u5-creator.s3.game.163.com/manual/pc_md/lua/lua_advance.html 使用 dispatch_flush 手动触发异步任务执行,并使用 dispatch_sync 获取所有已完成任务的返回值列表。 ```lua LuaAPI.dispatch_flush() local results = LuaAPI.dispatch_sync() for i, v in ipairs(results) do local result = results[i] if result[1] then print(result[2]) else error("Error occured! Message: " .. result[2]) end end ``` -------------------------------- ### GET /character/health Source: https://u5-creator.s3.game.163.com/manual/pc_md/eggycode/category_args.html 获取角色或生物的健康值及恢复速度。 ```APIDOC ## GET /character/health ### Description 获取角色或生物当前的健康值以及每5秒的健康恢复速度。 ### Method GET ### Endpoint /character/health ### Parameters #### Path Parameters - **target** (角色I生物) - Required - 目标角色或生物对象 ### Response #### Success Response (200) - **health** (number) - 当前健康值 - **recovery_rate** (number) - 每5秒恢复量 ``` -------------------------------- ### GET /api/data/weightpool/random Source: https://u5-creator.s3.game.163.com/manual/mobile/eggycode/category_args.html 从权重池中按照权重随机获取一个或多个值。 ```APIDOC ## GET /api/data/weightpool/random ### Description 从权重池中按照权重进行随机取值,支持获取单个或多个元素。 ### Method GET ### Endpoint /api/data/weightpool/random ### Parameters #### Query Parameters - **pool** (WeightPool) - Required - 权重池对象 - **count** (Integer) - Optional - 获取数量 - **repeat** (Boolean) - Optional - 是否允许重复 ### Request Example { "pool": "timer_weight_pool", "count": 1, "repeat": false } ### Response #### Success Response (200) - **result** (Any) - 随机获取的结果 #### Response Example { "result": "timer_01" } ``` -------------------------------- ### GET /api/data/property/get Source: https://u5-creator.s3.game.163.com/manual/mobile/eggycode/category_args.html 获取对象身上通过字符串记录的自定义属性数据。 ```APIDOC ## GET /api/data/property/get ### Description 获取一个对象身上通过字符串记录的数据。若未设置或类型不匹配,则获取失败。 ### Method GET ### Endpoint /api/data/property/get ### Parameters #### Query Parameters - **target** (Object) - Required - 目标对象(如单位、玩家、生物等) - **key** (String) - Required - 属性键名 ### Request Example { "target": "player_01", "key": "custom_attr_name" } ### Response #### Success Response (200) - **value** (Any) - 属性值 #### Response Example { "value": "attribute_value" } ``` -------------------------------- ### Initialize Shop and Purchase Triggers Source: https://u5-creator.s3.game.163.com/manual/pc_md/game_demo/lua_demo_run_merchant.html Initializes shop desks, registers trigger areas for player interaction, and handles the purchase logic when a player interacts with a shop item. ```lua for i = 1, 2 do local desk = LuaAPI.query_unit("商品桌子" .. i) self:randomAddItem(desk) local triggerArea = desk.get_child_by_name("商品触发器") TriggerAreaHandler.new(triggerArea, function(role) G.uiHandler:setItemOpHandler(role, "购买", function() local deskUnitId = LuaAPI.get_unit_id(desk) local item = self.deskItems[deskUnitId] if item and G.itemManager:buyItem(role, item) then self:enterRefreshState(desk) G.itemManager:destroyItem(item) self.deskItems[deskUnitId] = nil end end) end, function(role) G.uiHandler:setItemOpHandler(role, "", nil) end) end ``` -------------------------------- ### GET /api/data/list/get Source: https://u5-creator.s3.game.163.com/manual/mobile/eggycode/category_args.html 从列表变量中根据索引获取特定元素。 ```APIDOC ## GET /api/data/list/get ### Description 从指定的列表变量中取出对应索引的值。如果索引不存在,则获取失败。 ### Method GET ### Endpoint /api/data/list/get ### Parameters #### Query Parameters - **list** (List) - Required - 目标列表对象 - **index** (Integer) - Required - 索引位置 ### Request Example { "list": "animation_preset_list", "index": 0 } ### Response #### Success Response (200) - **value** (Any) - 获取到的列表元素 #### Response Example { "value": "animation_data_01" } ``` -------------------------------- ### EditorAPI.input_decoration_prefab Source: https://u5-creator.s3.game.163.com/manual/pc_md/lua/EggyEditorAPI.html Imports decoration prefab data from a specified file path. ```APIDOC ## POST /EditorAPI/input_decoration_prefab ### Description Imports decoration prefab data from a specified file path. ### Method POST ### Endpoint /EditorAPI/input_decoration_prefab ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **_path** (Str) - Required - The file path from which to import the decoration prefab data. ### Request Example ```json { "_path": "/path/to/decoration_prefab.json" } ``` ### Response #### Success Response (200) - **status** (String) - Indicates the result of the import operation. #### Response Example ```json { "status": "Decoration prefab imported successfully." } ``` ``` -------------------------------- ### Define and Instantiate Objects in Lua Source: https://u5-creator.s3.game.163.com/manual/pc_md/game_demo/lua_demo_mowing.html Demonstrates defining classes and instantiating objects in Lua, as used for game entities like Heroes and Monsters. Includes initialization logic for the Hero class and the HeroManager for managing multiple heroes. ```Lua ---构造函数,初始化英雄 ---@param character Character 角色对象 function Hero:ctor(character) self.character = character -- 设置英雄的角色 sself.level = 1 -- 初始等级为1 self.exp = 0 -- 初始经验值为0 local role = GameAPI.get_role(self.character.get_role_id()) -- 获取角色对象 sself.setLevel(self.level) -- 设置初始等级 role.set_progressbar_current(UINodes["经验值"], self.exp) -- 设置经验值进度条当前值 role.set_progressbar_max(UINodes["经验值"], self:getLevelUpExp()) -- 设置经验值进度条最大值 end -- 获取升到下一级级所需经验值 function Hero:getLevelUpExp() -- 代码省略 -- end -- 设置英雄等级 function Hero:setLevel() -- 代码省略 -- end -- 增加经验值 function Hero:addExp() -- 代码省略 -- end ``` ```Lua function HeroManager:ctor() -- 初始化英雄列表 self.heroes = {} -- 遍历所有有效角色 for _, role in ipairs(GameAPI.get_all_valid_roles()) do -- 获取角色控制的单位 local character = role.get_ctrl_unit() -- 创建新的英雄对象 local hero = Hero.new(character) -- 将英雄对象添加到列表中,以角色ID为键 self.heroes[role.get_roleid()] = hero end end ``` -------------------------------- ### 在 PC 编辑器中开启开发者模式 Source: https://u5-creator.s3.game.163.com/manual/pc_md/lua/lua_environment.html 通过 LuaAPI 开启开发者模式,可解除部分沙盒限制并启用 LuaSocket 等库,仅限 PC 编辑器试玩环境使用。 ```lua local success = LuaAPI.enable_developer_mode() ``` -------------------------------- ### GET /list/random Source: https://u5-creator.s3.game.163.com/manual/pc_md/eggycode/category_args.html Retrieves random elements from a list. ```APIDOC ## GET /list/random ### Description Retrieves random elements from a list. Supports picking multiple elements or a single element. ### Method GET ### Parameters #### Query Parameters - **list** (list) - Required - The source list - **count** (integer) - Optional - Number of elements to pick - **allowDuplicates** (boolean) - Optional - Whether to allow duplicate selection ### Response #### Success Response (200) - **result** (list/any) - A list of random elements or a single random element ``` -------------------------------- ### GET /list/random Source: https://u5-creator.s3.game.163.com/manual/mobile/eggycode/category_args.html Retrieves random elements from a list. ```APIDOC ## GET /list/random ### Description Extracts one or more random elements from a list to form a new list. ### Method GET ### Endpoint /list/random ### Parameters #### Query Parameters - **list** (List) - Required - The source list. - **count** (Integer) - Optional - Number of elements to pick. - **allowDuplicates** (Boolean) - Optional - Whether to allow picking the same element multiple times. ### Response #### Success Response (200) - **elements** (List) - The randomly selected elements. #### Response Example { "elements": ["item_a", "item_c"] } ``` -------------------------------- ### Equipment Management Methods Source: https://u5-creator.s3.game.163.com/manual/pc_md/lua/EggyAPI.html Methods for managing equipment properties including stack counts, pricing, UI icons, and usage states. ```Lua Equipment.set_auto_aim_enabled(_is_auto_aim) Equipment.set_auto_fire_enabled(_is_auto_fire) Equipment.set_current_stack_num(_num) Equipment.set_desc(_desc) Equipment.set_droppable(_droppable) Equipment.set_price(_res_type, _price) Equipment.set_charge_cost_free(_is_free) Equipment.set_icon(_icon_key) Equipment.set_max_stack_num(_num) Equipment.set_name(_name) Equipment.set_saleable(_saleable) Equipment.start_charge() Equipment.set_usable(_usable) ``` -------------------------------- ### GET /api/data/attribute Source: https://u5-creator.s3.game.163.com/manual/pc_md/eggycode/category_args.html Retrieves a custom attribute from a game object. ```APIDOC ## GET /api/data/attribute ### Description Fetches a custom data attribute stored as a string on a game object. Fails if the attribute was not set or if the type mismatch occurs. ### Method GET ### Endpoint /api/data/attribute ### Parameters #### Query Parameters - **object_type** (string) - Required - The type of object (e.g., unit, player, creature). - **attribute_key** (string) - Required - The key name of the custom attribute. ### Request Example { "object_type": "unit", "attribute_key": "health_multiplier" } ### Response #### Success Response (200) - **value** (any) - The value of the custom attribute. #### Response Example { "value": 1.5 } ``` -------------------------------- ### Lua 模块加载与使用 Source: https://u5-creator.s3.game.163.com/manual/pc_md/lua/lua_quickstart.html 演示如何在蛋仔编辑器中创建和加载 Lua 模块。首先创建一个名为 `helper.lua` 的模块文件,其中包含一个 `add` 函数。然后,在 `main.lua` 文件中通过 `require` 函数加载该模块并调用其函数。 ```lua local helper = {} function helper.add(a, b) return a + b end return helper ``` ```lua local helper = require("helper") print("add result: " .. helper.add(1, 2)) ``` -------------------------------- ### 全局触发器事件注册与回调 Source: https://u5-creator.s3.game.163.com/manual/pc_md/lua/lua_quickstart.html 介绍了如何在 Lua 中注册全局触发器事件的回调函数。支持游戏初始化事件 (`EVENT.GAME_INIT`) 和自定义事件 (`EVENT.CUSTOM_EVENT`)。自定义事件需要提供事件名称,并且回调函数可以接收自定义参数。 ```lua LuaAPI.global_register_trigger_event({ EVENT.GAME_INIT }, function () print("GAME INIT!") end) LuaAPI.global_register_trigger_event({ EVENT.CUSTOM_EVENT, "测试自定义事件名称" }, function (name, unit, data) print("Custom Event!") end) ``` -------------------------------- ### GET /object/attribute Source: https://u5-creator.s3.game.163.com/manual/pc_md/eggycode/category_args.html Retrieves a custom attribute from a game object. ```APIDOC ## GET /object/attribute ### Description Retrieves data stored on an object via a string key. Fails if the key does not exist or if the data type mismatch occurs. ### Method GET ### Parameters #### Query Parameters - **object** (object) - Required - The target object (e.g., Joint, Unit, Player) - **key** (string) - Required - The attribute key name ### Response #### Success Response (200) - **value** (any) - The value associated with the key ``` -------------------------------- ### GET /api/list/value Source: https://u5-creator.s3.game.163.com/manual/mobile/eggycode/category_args.html Retrieves a value from a list at a specific index. ```APIDOC ## GET /api/list/value ### Description Retrieves a value from a list at a specific index. Fails if the index is out of bounds. ### Method GET ### Endpoint /api/list/value ### Parameters #### Query Parameters - **list** (array) - Required - The source list. - **index** (integer) - Required - The zero-based index. ### Response #### Success Response (200) - **value** (any) - The value at the specified index. #### Response Example { "value": "element_at_index" } ``` -------------------------------- ### Lua Data Loading for Dress-Up Areas Source: https://u5-creator.s3.game.163.com/manual/pc_md/game_demo/lua_demo_cos_play.html Demonstrates how to load configuration data from a Lua file into the main script. By using `require`, the `DressUpData` table becomes accessible, allowing the game to utilize the defined profession information for creating dress-up areas. ```Lua -- Import data from DressUpData.lua local DressUpData = require("Data.DressUpData") ``` -------------------------------- ### GET /object/attribute Source: https://u5-creator.s3.game.163.com/manual/mobile/eggycode/category_args.html Retrieves a custom attribute from a game object. ```APIDOC ## GET /object/attribute ### Description Retrieves data stored on an object via a string key. Fails if the key does not exist or the data type mismatch occurs. ### Method GET ### Endpoint /object/attribute ### Parameters #### Query Parameters - **target** (Object) - Required - The game object (e.g., Player, Unit, Item). - **key** (String) - Required - The attribute key string. ### Response #### Success Response (200) - **value** (Any) - The retrieved attribute value. #### Response Example { "value": 1625000000 } ``` -------------------------------- ### 派发异步计算任务 Source: https://u5-creator.s3.game.163.com/manual/pc_md/lua/lua_advance.html 使用 dispatch_queue 将任务派发到指定的从虚拟机。参数必须打包为表结构,不支持直接传递可变参数。 ```lua LuaAPI.dispatch_queue(0, "foo", { "param1", "param2", "param3" }) ``` -------------------------------- ### Start Move to Position with Threshold (LifeEntity) Source: https://u5-creator.s3.game.163.com/manual/pc_md/lua/EggyAPI.html Commands a life entity to move towards a target position within a specified threshold. Requires target position, duration, and threshold. ```lua LifeEntity.start_move_to_pos_with_threshold(_target_pos, _duration, _threshold) ``` -------------------------------- ### GET /api/time/diff Source: https://u5-creator.s3.game.163.com/manual/mobile/eggycode/category_args.html Calculates the difference in seconds between two timestamps. ```APIDOC ## GET /api/time/diff ### Description Calculates the time difference between two provided timestamps in seconds. ### Method GET ### Endpoint /api/time/diff ### Parameters #### Query Parameters - **timestamp1** (timestamp) - Required - The start time. - **timestamp2** (timestamp) - Required - The end time. ### Response #### Success Response (200) - **seconds** (integer) - The difference in seconds. ``` -------------------------------- ### GET /api/lists/value Source: https://u5-creator.s3.game.163.com/manual/mobile/eggycode/category_args.html Retrieves a value from a list at a specified index. ```APIDOC ## GET /api/lists/value ### Description Retrieves a specific value from a list variable based on the provided index. If the index does not exist, the operation fails. ### Method GET ### Endpoint /api/lists/value ### Parameters #### Query Parameters - **list** (array) - Required - The source list (e.g., unit list, integer list, string list). - **index** (integer) - Required - The index to retrieve. ### Response #### Success Response (200) - **value** (any) - The value found at the specified index. ``` -------------------------------- ### POST /api/component/create Source: https://u5-creator.s3.game.163.com/manual/pc_md/eggycode/category_action.html Dynamically creates a new component in the game scene. ```APIDOC ## POST /api/component/create ### Description Dynamically creates a component at a specific coordinate with rotation and scale. ### Method POST ### Endpoint /api/component/create ### Parameters #### Request Body - **preset** (string) - Required - Component preset ID - **position** (vector3) - Required - Target coordinates - **rotation** (vector3) - Required - Rotation angles - **scale** (vector3) - Required - Scale vector - **owner** (string) - Optional - Owning player ### Request Example { "preset": "box_01", "position": {"x": 0, "y": 10, "z": 0}, "rotation": {"x": 0, "y": 0, "z": 0}, "scale": {"x": 1, "y": 1, "z": 1} } ### Response #### Success Response (200) - **component_id** (string) - The ID of the created component ``` -------------------------------- ### GET /api/pool/random Source: https://u5-creator.s3.game.163.com/manual/mobile/eggycode/category_args.html Retrieves a random value from a weighted pool. ```APIDOC ## GET /api/pool/random ### Description Retrieves one or more items from a weighted pool based on their defined weights. ### Method GET ### Endpoint /api/pool/random ### Parameters #### Query Parameters - **pool** (object) - Required - The weighted pool data structure - **count** (integer) - Optional - Number of items to retrieve - **allow_repeat** (boolean) - Optional - Whether to allow duplicate items ### Request Example { "pool": {"item1": 10, "item2": 90}, "count": 1 } ### Response #### Success Response (200) - **items** (array) - The items selected based on weight #### Response Example { "items": ["item2"] } ``` -------------------------------- ### Show Store to Player Source: https://u5-creator.s3.game.163.com/manual/mobile/eggycode/category_action.html Displays a specified store to a player. ```APIDOC ## Show Store to Player ### Description Displays store {#1} to player {#0}. ### Parameters 1. Optional: Player, Player List 2. Store ### Notes Displays a specified store to the designated player. ``` -------------------------------- ### GET /api/list/value Source: https://u5-creator.s3.game.163.com/manual/mobile/eggycode/category_args.html Retrieves a specific value from a list by its index. ```APIDOC ## GET /api/list/value ### Description Retrieves a specific value from a list variable based on the provided index. If the index does not exist, the retrieval fails. ### Method GET ### Endpoint /api/list/value ### Parameters #### Query Parameters - **list** (array) - Required - The source list (e.g., decorations, tables, etc.) - **index** (integer) - Required - The zero-based index to retrieve ### Request Example { "list": ["item1", "item2"], "index": 0 } ### Response #### Success Response (200) - **value** (any) - The element at the specified index #### Response Example { "value": "item1" } ``` -------------------------------- ### Lua Configuration for Dress-Up Area Data Source: https://u5-creator.s3.game.163.com/manual/pc_md/game_demo/lua_demo_cos_play.html Provides an example of how to configure dress-up area information using a separate Lua file. This approach centralizes data, making it easier to manage and modify details like the area name and the creature model key for different professions. ```Lua return { Doctor = { name = "医生", modelCreatureKey = Prefab.character["职业-医生1"], }, Director = { name = "指挥员", modelCreatureKey = Prefab.character["职业-指挥员12"], }, -- Other configurations omitted } ``` -------------------------------- ### Lua: Main Game Logic with Parallel Dispatch Source: https://u5-creator.s3.game.163.com/manual/pc_md/lua/lua_advance.html This Lua script demonstrates how to use the U5 Engine's parallel processing features. It initializes the engine, dispatches map initialization and search functions to multiple threads, and handles asynchronous queries within a game loop. It also includes a strategy for managing frame-based updates and asynchronous task synchronization. ```lua local Engine = require("engine") -- 使用上文提供的封装接口 local threadCount = 3 Engine.Setup(threadCount) local map = { 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 2, 1, 0, 1, 0, 0, 3, 0, 2, 1, 3, 6, 4, 1, 1, 0, 0, 2, 5 } for i = 1, threadCount do -- 每个线程上的虚拟机都需要加载search.lua Engine.Dispatch(i, "require", { "search" }, function (ok, result) if not ok then error("Error occured on loading search.lua: " .. result) end end) -- 初始化地图 Engine.Dispatch(i, "Init", { map, 6, 5 }, function (ok, result) if not ok then error("Error occured on Init data: " .. result) end end) end function PreFrame() -- 每帧前都先同步所有异步调用 Engine.Tick() end -- 查询的信息,四个一组,每组为 x, y, radius, typeid local queries = { 1, 2, 2, 1, 3, 3, 1, 2, 2, 1, 2, 3, 4, 3, 2, 4, 1, 3, 2, 1 } local frameIndex = 0 function PostFrame() -- 每帧结束时发起异步查询 -- 为了避免被输出刷屏,每隔60帧(2秒)发起一轮 if frameIndex % 60 == 0 then for i = 1, #queries // 4 do local x, y, r, t = queries[i * 4 - 3], queries[i * 4 - 2], queries[i * 4 - 1], queries[i * 4] Engine.Dispatch(i % threadCount, "Query", { x, y, r, t }, function (ok, result) -- 每个回调对应一次异步调用 if ok then print("Query result of Task " .. tostring(i) .. " (" .. tostring(t) .. ")= " .. table.concat(result, ",")) else error("Error occured in Task " .. tostring(i) .. ": " .. result) end end) end end frameIndex = frameIndex + 1 Engine.Flush() end LuaAPI.set_tick_handler(PreFrame, PostFrame) ``` -------------------------------- ### GET /api/workshop/pool/random Source: https://u5-creator.s3.game.163.com/manual/pc_md/eggycode/category_args.html Retrieves a random value from a weighted pool. ```APIDOC ## GET /api/workshop/pool/random ### Description Selects a random element from a weighted pool based on defined weights. ### Method GET ### Endpoint /api/workshop/pool/random ### Parameters #### Query Parameters - **pool_id** (string) - Required - The identifier for the weighted pool ### Request Example { "pool_id": "animation_weight_pool" } ### Response #### Success Response (200) - **result** (any) - The randomly selected element #### Response Example { "result": "animation_jump" } ``` -------------------------------- ### GET /api/data/list/value Source: https://u5-creator.s3.game.163.com/manual/pc_md/eggycode/category_args.html Retrieves a specific value from a list based on an index. ```APIDOC ## GET /api/data/list/value ### Description Retrieves the value at a specific index from a provided list variable. If the index does not exist, the operation fails. ### Method GET ### Endpoint /api/data/list/value ### Parameters #### Query Parameters - **list_variable** (string) - Required - The source list (e.g., shape list, unit list). - **index** (integer) - Required - The zero-based index to retrieve. ### Request Example { "list_variable": "shape_list_01", "index": 0 } ### Response #### Success Response (200) - **value** (any) - The value found at the specified index. #### Response Example { "value": "shape_data_01" } ``` -------------------------------- ### EditorAPI.input_ability_prefab Source: https://u5-creator.s3.game.163.com/manual/pc_md/lua/EggyEditorAPI.html Imports ability prefab data from a specified file path. ```APIDOC ## POST /EditorAPI/input_ability_prefab ### Description Imports ability prefab data from a specified file path. ### Method POST ### Endpoint /EditorAPI/input_ability_prefab ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **_path** (Str) - Required - The file path from which to import the ability prefab data. ### Request Example ```json { "_path": "/path/to/ability_prefab.json" } ``` ### Response #### Success Response (200) - **status** (String) - Indicates the result of the import operation. #### Response Example ```json { "status": "Ability prefab imported successfully." } ``` ``` -------------------------------- ### GET /list/value Source: https://u5-creator.s3.game.163.com/manual/pc_md/eggycode/category_args.html Retrieves a specific value from a list based on an index. ```APIDOC ## GET /list/value ### Description Retrieves a specific value from a list variable by index. Returns failure if the index does not exist. ### Method GET ### Parameters #### Query Parameters - **list** (list) - Required - The source list (e.g., JointTypeList, JointPresetList) - **index** (integer) - Required - The zero-based index to retrieve ### Response #### Success Response (200) - **value** (any) - The element at the specified index ``` -------------------------------- ### Control AI Start Move Source: https://u5-creator.s3.game.163.com/manual/pc_md/lua/EggyAPI.html This function initiates movement for an AI unit in a specified direction for a given duration. Parameters include direction and time. ```Lua LifeEntity.ai_command_start_move(_direction, _t) ``` -------------------------------- ### Ability Management Methods Source: https://u5-creator.s3.game.163.com/manual/pc_md/lua/EggyAPI.html Methods to configure ability cooldowns, charge times, and usage limits. ```Lua Ability.set_left_charge_time(_cd_time) Ability.set_left_cd_time(_cd_time) Ability.set_max_release_num(_release_num_max) Ability.set_cur_release_num(_release_num) ``` -------------------------------- ### GET /ui/controls/sub-controls Source: https://u5-creator.s3.game.163.com/manual/pc_md/eggycode/category_args.html Retrieves the children controls of a specific interface control. ```APIDOC ## GET /ui/controls/sub-controls ### Description Retrieves all controls contained within the next level of a specified interface control. ### Method GET ### Endpoint /ui/controls/sub-controls ### Parameters #### Query Parameters - **parent_control** (object) - Required - The parent interface control ### Request Example { "parent_control": "panel_container" } ### Response #### Success Response (200) - **controls** (array) - List of child controls #### Response Example { "controls": ["button_1", "label_1", "image_1"] } ``` -------------------------------- ### GET /api/list/value Source: https://u5-creator.s3.game.163.com/manual/pc_md/eggycode/category_args.html Retrieves a specific value from a list based on an index. ```APIDOC ## GET /api/list/value ### Description Retrieves the value at a specific index from a provided list. If the index is out of bounds, the operation fails. ### Method GET ### Endpoint /api/list/value ### Parameters #### Query Parameters - **list** (list) - Required - The source list to query. - **index** (integer) - Required - The zero-based index of the element to retrieve. ### Response #### Success Response (200) - **value** (any) - The element found at the specified index. #### Response Example { "value": "sound_effect_01" } ```