Skip to content

区域模块管理接口 Area

具体函数名及描述如下:

序号函数名函数描述
1CreateAreaRectByRange(...)创建矩形区域(通过范围)
2DestroyArea(...)销毁区域
3GetAreaCenter(...)获取区域中间点
4GetAreaRectLength(...)获取区域各边长
5GetAreaRectRange(...)获取区域范围
6GetRandomPos(...)随机区域内位置
7ObjInArea(...)检测obj是否在区域内
8BlockInArea(...)检测区域内是否有某个方块
9PosInArea(...)位置是否在区域内
10GetAreaPlayers(...)获取区域中的所有玩家
11GetAreaCreatures(...)获取区域中的所有生物(当帧创建的生物获取不到)
12ClearAllBlock(...)清空区域内全部方块
13CloneAreaBlock(...)复制区域内方块到另一个区域
14ReplaceAreaBlock(...)替换方块类型为新的方块类型
15GetAllObjsInAreaRange(...)获取区域范围内全部对象
16GetAllPlayersInAreaRange(...)获取区域范围内全部玩家
17GetAllCreaturesInAreaRange(...)获取区域范围内全部生物
18FillBlockAreaRange(...)用方块填充区域范围(分帧处理,当前帧率操作不到填充的方块)
19ClearAllBlockAreaRange(...)清空区域范围内方块
20DestroyAllBlock(...)破坏区域内的方块
21CloneAreaRange(...)复制区域范围内方块到另一个区域
22ReplaceAreaRangeBlock(...)替换区域范围方块
23GetRandomAirPos(...)获取一个区域内随机空气方块
24GetAreaBlockTypes(...)获取区域内的方块类型
25GetBlockNum(...)获取区域内的方块数量
26CheckRangeCanPlace(...)检查指定范围内是否可以放置方块
27GetRelativeActors(...)获取区域中指定玩家关系的角色

CreateAreaRectByRange

  • 参数及类型:
    • posBeg:table区域起始坐标
    • posEnd:table区域结束坐标
    • btmp:boolean是否是临时区域
  • 返回值及类型:
  • 该方法的主要作用: 创建矩形区域(通过范围)
  • 具体使用案例如下:
lua
local ret = Area:CreateAreaRectByRange(posBeg, posEnd, btmp)

DestroyArea

  • 参数及类型:
  • 返回值及类型:
  • 该方法的主要作用: 销毁区域
  • 具体使用案例如下:
lua
local ret = Area:DestroyArea(areaid)

GetAreaCenter

  • 参数及类型:
  • 返回值及类型:
    • ret:table区域中心位置
  • 该方法的主要作用: 获取区域中间点
  • 具体使用案例如下:
lua
local ret = Area:GetAreaCenter(areaid)

GetAreaRectLength

  • 参数及类型:
  • 返回值及类型:
  • 该方法的主要作用: 获取区域各边长
  • 具体使用案例如下:
lua
local ret, leny, lenz = Area:GetAreaRectLength(areaid)

GetAreaRectRange

  • 参数及类型:
  • 返回值及类型:
    • ret:table区域起始坐标
    • posEnd:table区域结束坐标
  • 该方法的主要作用: 获取区域范围
  • 具体使用案例如下:
lua
local ret, posEnd = Area:GetAreaRectRange(areaid)

GetRandomPos

  • 参数及类型:
  • 返回值及类型:
  • 该方法的主要作用: 随机区域内位置
  • 具体使用案例如下:
lua
local ret = Area:GetRandomPos(areaid)

ObjInArea

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否在区域内
  • 该方法的主要作用: 检测obj是否在区域内
  • 具体使用案例如下:
lua
local ret = Area:ObjInArea(areaid, objid)

BlockInArea

  • 参数及类型:
    • areaid:number区域ID
    • blockid:number,string方块类型ID
  • 返回值及类型:
    • ret:bool是否在区域内
  • 该方法的主要作用: 检测区域内是否有某个方块
  • 具体使用案例如下:
lua
local ret = Area:BlockInArea(areaid, blockid)

PosInArea

  • 参数及类型:
  • 返回值及类型:
    • ret:bool是否在区域内
  • 该方法的主要作用: 位置是否在区域内
  • 具体使用案例如下:
lua
local ret = Area:PosInArea(areaid, pos)

GetAreaPlayers

  • 参数及类型:
  • 返回值及类型:
    • playerlist:table玩家objid组
  • 该方法的主要作用: 获取区域中的所有玩家
  • 具体使用案例如下:
lua
local playerlist = Area:GetAreaPlayers(areaid)

GetAreaCreatures

  • 参数及类型:
  • 返回值及类型:
    • playerlist:table生物objid组
  • 该方法的主要作用: 获取区域中的所有生物(当帧创建的生物获取不到)
  • 具体使用案例如下:
lua
local playerlist = Area:GetAreaCreatures(areaid)

ClearAllBlock

  • 参数及类型:
    • areaid:number区域唯一ID
    • blockid:number,string方块类型ID
    • num:number最大清除数量
    • btriggerevent:boolean:是否触发事件
  • 返回值及类型:
  • 该方法的主要作用: 清空区域内全部方块
  • 具体使用案例如下:
lua
local ret = Area:ClearAllBlock(areaid, blockid, num, btriggerevent)

CloneAreaBlock

  • 参数及类型:
  • 返回值及类型:
  • 该方法的主要作用: 复制区域内方块到另一个区域
  • 具体使用案例如下:
lua
local ret = Area:CloneAreaBlock(areaid, pos)

ReplaceAreaBlock

  • 参数及类型:
    • areaid:number区域唯一ID
    • srcblockid:number,string区域内的方块类型
    • destblockid:number,string替换的方块类型
    • face:number方块朝向
    • color:string,number颜色
  • 返回值及类型:
  • 该方法的主要作用: 替换方块类型为新的方块类型
  • 具体使用案例如下:
lua
local ret = Area:ReplaceAreaBlock(areaid, srcblockid, destblockid, face, color)

GetAllObjsInAreaRange

  • 参数及类型:
  • 返回值及类型:
  • 该方法的主要作用: 获取区域范围内全部对象
  • 具体使用案例如下:
lua
local objs = Area:GetAllObjsInAreaRange(posbeg, posend, objtype)

GetAllPlayersInAreaRange

  • 参数及类型:
  • 返回值及类型:
  • 该方法的主要作用: 获取区域范围内全部玩家
  • 具体使用案例如下:
lua
local objs = Area:GetAllPlayersInAreaRange(posbeg, posend)

GetAllCreaturesInAreaRange

  • 参数及类型:
  • 返回值及类型:
  • 该方法的主要作用: 获取区域范围内全部生物
  • 具体使用案例如下:
lua
local objs = Area:GetAllCreaturesInAreaRange(posbeg, posend)

FillBlockAreaRange

  • 参数及类型:
    • posbeg:table起始位置
    • posend:table末点位置
    • blockid:number,string方块类型
    • face:number朝向
    • color:string,number颜色
    • switch:boolean是否开启
    • filltype:number填充类型(CmpEnvEnum.AreaFillType)
  • 返回值及类型:
    • ret:bool成功(true)
  • 该方法的主要作用: 用方块填充区域范围(分帧处理,当前帧率操作不到填充的方块)
  • 具体使用案例如下:
lua
local ret = Area:FillBlockAreaRange(posbeg, posend, blockid, face, color, switch, filltype)

ClearAllBlockAreaRange

  • 参数及类型:
    • posbeg:table起始位置
    • posend:table末点位置
    • blockid:number,string方块类型
    • btriggerevent:boolean:是否触发事件
  • 返回值及类型:
    • ret:bool成功(true)
  • 该方法的主要作用: 清空区域范围内方块
  • 具体使用案例如下:
lua
local ret = Area:ClearAllBlockAreaRange(posbeg, posend, blockid, btriggerevent)

DestroyAllBlock

  • 参数及类型:
    • areaid:number区域ID
    • blockid:string,number方块ID或资产ID
    • n:number销毁数量(不填或者0则全部销毁)
    • candrop:boolean是否掉落物品
    • btriggerevent:boolean是否触发事件
  • 返回值及类型:
  • 该方法的主要作用: 破坏区域内的方块
  • 具体使用案例如下:
lua
local ret = Area:DestroyAllBlock(areaid, blockid, n, candrop, btriggerevent)

CloneAreaRange

  • 参数及类型:
    • posbeg:table起始位置
    • posend:table末点位置
    • deststartpos:table目标起始位置
  • 返回值及类型:
    • ret:boolean操作是否成功(true/false)
  • 该方法的主要作用: 复制区域范围内方块到另一个区域
  • 具体使用案例如下:
lua
local ret = Area:CloneAreaRange(posbeg, posend, deststartpos, itype)

ReplaceAreaRangeBlock

  • 参数及类型:
    • posbeg:table起始位置
    • posend:table末点位置
    • srcblockid:number,string方块类型
    • destblockid:number,string目标方块类型
    • face:number朝向
    • inair:boolean是否包括空气方块
  • 返回值及类型:
    • ret:boolean操作是否成功(true/false)
  • 该方法的主要作用: 替换区域范围方块
  • 具体使用案例如下:
lua
local ret = Area:ReplaceAreaRangeBlock(posbeg, posend, srcblockid, destblockid, face, inair)

GetRandomAirPos

  • 参数及类型:
    • posbeg:table区域起始位置
    • posend:table区域结束位置
  • 返回值及类型:
    • ret:table随机空气位置(x
    • y
    • z)
  • 该方法的主要作用: 获取一个区域内随机空气方块
  • 具体使用案例如下:
lua
local ret = Area:GetRandomAirPos(posbeg, posend)

GetAreaBlockTypes

  • 参数及类型:
  • 返回值及类型:
  • 该方法的主要作用: 获取区域内的方块类型
  • 具体使用案例如下:
lua
local ret = Area:GetAreaBlockTypes(areaid)

GetBlockNum

  • 参数及类型:
    • areaid:number区域ID
    • blockid:string,number方块ID
  • 返回值及类型:
  • 该方法的主要作用: 获取区域内的方块数量
  • 具体使用案例如下:
lua
local ret = Area:GetBlockNum(areaid, blockid)

CheckRangeCanPlace

  • 参数及类型:
    • posbeg:table区域起始位置
    • posend:table区域结束位置
    • blockid:string,number方块ID
  • 返回值及类型:
    • ret:boolean是否可以放置方块(true/false)
  • 该方法的主要作用: 检查指定范围内是否可以放置方块
  • 具体使用案例如下:
lua
local ret = Area:CheckRangeCanPlace(posbeg, posend, blockid)

GetRelativeActors

  • 参数及类型:
  • 返回值及类型:
  • 该方法的主要作用: 获取区域中指定玩家关系的角色
  • 具体使用案例如下:
lua
local num,arr = Area:GetRelativeActors(posbeg, posend, uin, relativing, actortype)