Appearance
世界模块管理接口 World
具体函数名及描述如下:
StopParticleOnPos
- 参数及类型:
- 返回值及类型:
- ret:
boolean是否成功
- ret:
- 该方法的其他说明: 停止指定位置的粒子特效(支持传特效ID或路径)
- 具体使用案例如下:
lua
local x, y, z = Actor:GetPosition(Player:GetHostUin())
local result = World:StopParticleOnPos(x, y, z, 1001, WorldId)SetParticleTransform
- 参数及类型:
- 返回值及类型:
- ret:
boolean是否成功
- ret:
- 该方法的其他说明: 调整指定位置的粒子特效偏移/旋转/缩放(支持单个或多个特效)
- 具体使用案例如下:
lua
local x, y, z = Actor:GetPosition(Player:GetHostUin())
-- 设置效果缩放2倍
local result = World:SetParticleTransform({x = x, y = y, z = z}, 1001, nil, nil, {x = 2, y = 2, z = 2}, WorldId)PlayParticle
- 参数及类型:
- 返回值及类型:
- ret:
boolean是否成功
- ret:
- 该方法的其他说明: 在指定位置播放粒子特效(支持单个或多个特效)
- 具体使用案例如下:
lua
local x, y, z = Actor:GetPosition(Player:GetHostUin())
local result = World:PlayParticle({x = x, y = y, z = z}, 1001, 2, WorldId)GetLightByPos
- 参数及类型:
- 返回值及类型:
- lv:
number光照强度(0~16),失败为-1
- lv:
- 该方法的其他说明: 获取指定位置的光照强度
- 具体使用案例如下:
lua
local light = World:GetLightByPos(x, y, z, WorldId)
print("获取光照强度 ", light)SpawnCreature
- 参数及类型:
- 返回值及类型:
- objs:
table/ nil 生成的生物ID数组
- objs:
- 该方法的其他说明: 在指定位置生成生物(怪物/NPC/动物等)
- 具体使用案例如下:
lua
local x1, y1, z1 = Actor:GetPosition(Player:GetHostUin())
local creatures = World:SpawnCreature(x1 + 5, y1 + 1, z1, 3400, 1, true, WorldId)DespawnActor
- 参数及类型:
- objid:
number对象objID
- objid:
- 返回值及类型:
- ret:
boolean是否成功
- ret:
- 该方法的其他说明: 移除一个生物,如果是骑乘的生物则会先把骑乘关系处理掉再移除生物。(玩家不允许移除)
- 具体使用案例如下:
lua
local result = World:DespawnActor(creatureId)GetPlayerTotal
- 参数及类型:
- alive:
number/ nil 玩家状态(0阵亡 1存活 -1全部)
- alive:
- 返回值及类型:
- ret:
number玩家数量,失败为-1
- ret:
- 该方法的其他说明: 获取当前玩家数量(可按存活/死亡筛选)
- 具体使用案例如下:
lua
local total = World:GetPlayerTotal()GetAllPlayers
- 参数及类型:
- alive:
number/ nil 玩家状态(0阵亡 1存活 -1全部)
- alive:
- 返回值及类型:
- list:
table/ nil 玩家objid数组
- list:
- 该方法的其他说明: 获取当前地图中全部玩家对象ID列表(可按存活/死亡筛选)
- 具体使用案例如下:
lua
local players = World:GetAllPlayers()GetSpawnPoint
lua
local x, y, z = World:GetSpawnPoint()FindCanSpawnMobPosList
- 参数及类型:
- 返回值及类型:
- posList:
table/ nil 位置列表
- posList:
- 该方法的其他说明: 获取指定中心点周围,以设置的半径为范围的「可刷怪」位置列表,可选是否把中心点也算进结果里
- 具体使用案例如下:
lua
local x, y, z = Actor:GetPosition(Player:GetHostUin())
local posList = World:FindCanSpawnMobPosList(x, y, z, 10, true, WorldId)
if posList then
for i, v in ipairs(posList) do
print("可以创建生物位置", v.x, v.y, v.z)
end
endFindNearestPlayerByPos
- 参数及类型:
- 返回值及类型:
- objid:
number/ nil 玩家ID
- objid:
- 该方法的其他说明: 以指定位置为中心、在半径范围内查找玩家,返回最近的玩家ID
- 具体使用案例如下:
lua
local playerId = World:FindNearestPlayerByPos(x, y, z, WorldId)PlaySoundEffectOnPos
- 参数及类型:
- 返回值及类型:
- ret:
boolean是否成功
- ret:
- 该方法的其他说明: 在指定位置播放音效(可设置音量/音调/是否循环)
- 具体使用案例如下:
lua
local x, y, z = Actor:GetPosition(Player:GetHostUin())
local result = World:PlaySoundEffectOnPos({x = x, y = y, z = z}, 10946, 100, 1, false, WorldId)StopSoundEffectOnPos
- 参数及类型:
- 返回值及类型:
- ret:
boolean是否成功
- ret:
- 该方法的其他说明: 停止指定位置上的音效(传 -1 表示停止该位置所有音效)
- 具体使用案例如下:
lua
local x, y, z = Actor:GetPosition(Player:GetHostUin())
local result = World:StopSoundEffectOnPos({x = x, y = y, z = z}, 10946, WorldId)PauseSoundEffectOnPos
- 参数及类型:
- 返回值及类型:
- ret:
boolean是否成功
- ret:
- 该方法的其他说明: 暂停或恢复指定位置的音效(传 -1 表示该位置所有音效)
- 具体使用案例如下:
lua
local x, y, z = Actor:GetPosition(Player:GetHostUin())
local result = World:PauseSoundEffectOnPos({x = x, y = y, z = z}, 10946, true, WorldId)IsDaytime
- 参数及类型: 无
- 返回值及类型:
- ret:
boolean是否白天
- ret:
- 该方法的其他说明: 当前是否为白天
- 具体使用案例如下:
lua
local isDaytime = World:IsDaytime()SetHours
lua
local result = World:SetHours(2)GetHours
- 参数及类型: 无
- 返回值及类型:
- curHour:
number/ nil 小时
- curHour:
- 该方法的其他说明: 获取当前世界时间(小时)
- 具体使用案例如下:
lua
local hours = World:GetHours()GetDay
- 参数及类型: 无
- 返回值及类型:
- ret:
number/ nil 天数
- ret:
- 该方法的其他说明: 获取当前世界过了多少天
- 具体使用案例如下:
lua
local day = World:GetDay()SetGravity
lua
local result = World:SetGravity(12)AddGravity
lua
local ret = World:AddGravity(value)GetGravity
- 参数及类型:
- worldId:
number/ nil 星球ID(默认当前主机所在星球)
- worldId:
- 返回值及类型:
- value:
number/ nil 重力值
- value:
- 该方法的其他说明: 获取当前星球重力值
- 具体使用案例如下:
lua
local gravity = World:GetGravity()IsChunkLoaded
- 参数及类型:
- 返回值及类型:
- ret:
boolean是否已加载
- ret:
- 该方法的其他说明: 判断某个区块是否已加载
- 具体使用案例如下:
lua
local x, y, z = Actor:GetPosition(Player:GetHostUin())
local worldId = World:GetHostWorldId()
local result = World:IsChunkLoaded(x, z, worldId)CanMobSpawnOnPosXZ
- 参数及类型:
- 返回值及类型:
- posy:
number查到的可刷怪落脚 Y(-1 表示未找到)
- posy:
- 该方法的其他说明: 在指定的 x、z 处从高度 y 向上查找,得到第一个可落脚刷怪的高度,找不到合适位置返回 -1。
- 具体使用案例如下:
lua
local canSpawnY = World:CanMobSpawnOnPosXZ(x,y, z, WorldId)
if canSpawnY and canSpawnY > 0 then
print("可以创建生物位置", x, canSpawnY, z)
endGetHostWorldId
- 参数及类型: 无
- 返回值及类型:
- worldId:
number星球ID
- worldId:
- 该方法的其他说明: 获取主机所在星球ID
- 具体使用案例如下:
lua
local worldId = World:GetHostWorldId()
print("获取主机世界id ", worldId)SpawnProjectile
- 参数及类型:
- 返回值及类型:
- objid:
number/ nil 投掷物objid
- objid:
- 该方法的其他说明: 在起点生成一个投掷物并朝目标点飞行(可指定速度)
- 具体使用案例如下:
lua
local x, y, z = Actor:GetPosition(Player:GetHostUin())
-- 生成石箭往x+20,y+5,z方向射出, 速度10
local projectile = World:SpawnProjectile(Player:GetHostUin(), 12051, x, y, z, x + 20, y + 5, z, 10, WorldId)SpawnProjectileByDir
- 参数及类型:
- 返回值及类型:
- ret:
number/ nil 投掷物ID(失败返回nil)
- ret:
- 该方法的其他说明: 在指定位置生成投掷物,按指定方向飞行(可指定速度)
- 具体使用案例如下:
lua
local x, y, z = Actor:GetPosition(Player:GetHostUin())
local projectile = World:SpawnProjectileByDir(Player:GetHostUin(), 12051, x, y, z, 20, 5, 20, 10, WorldId)GetBiomeType
- 参数及类型:
- 返回值及类型:
- ret:
number/ nil 地形类型(BiomeType)
- ret:
- 该方法的其他说明: 获取指定位置的地形类型;取不到返回 nil
- 具体使用案例如下:
lua
local biomeType = World:GetBiomeType(x, y, WorldId)
if biomeType == BiomeType.GrassLand then
print("草原")
elseif biomeType == BiomeType.Forest then
print("森林")
endGetBiomeGroup
- 参数及类型:
- 返回值及类型:
- ret:
number/ nil 地形组类型(WeatherGroup)
- ret:
- 该方法的其他说明: 获取指定位置的地形组类型;取不到返回 nil
- 具体使用案例如下:
lua
local group = World:GetBiomeGroup(x, z, WorldId)FindEcosystem
- 参数及类型:
- 返回值及类型:
- retX|retY|retZ:
number/ nil 找到的地形位置坐标(失败返回nil)
- retX|retY|retZ:
- 该方法的其他说明: 从起点附近搜索指定地形类型,找到则返回目标坐标,找不到返回 nil
- 具体使用案例如下:
lua
local x,y,z = World:FindEcosystem(centerX, centerY, centerZ, BiomeType.GrassLand, 50)
if x and y and z then
print("找到草原", x, y, z)
endPixelMapAddMarker
- 参数及类型:
- 返回值及类型:
- ret:
boolean是否添加成功
- ret:
- 该方法的其他说明: 在地图上添加一个开发者标记点(查看下案例,了解params结构)
- 具体使用案例如下:
lua
-- 参数说明
local x, y, z = Actor:GetPosition(Player:GetHostUin())
local params = {
posX = x,--(必填)
posZ = z,--(必填)
-- name ="测试名", --名字
iconName = "0_10074", --图片路径(必填)
-- zoomMin = 0, --最小scale倍率
-- zoomMax = 100, --最大scale倍率
-- isTrace = false, --是否追踪
-- isRadarTrace = false, --雷达上是否追踪
-- appearInBlockFog = true, --
-- isCanUI = false, --是否能点击
-- desc = "", --描述
-- level = 4, --UI层级
}
local result = World:PixelMapAddMarker(Player:GetHostUin(), "markId_123", params)PixelMapRefreshMarker
- 参数及类型:
- 返回值及类型:
- ret:
boolean是否刷新成功
- ret:
- 该方法的其他说明: 刷新地图上的开发者标记点(params 只需提供要变更的字段)
- 具体使用案例如下:
lua
local x, y, z = Actor:GetPosition(Player:GetHostUin())
local params = {
posX = x,
posZ = z,
-- name = defaultCustomMarkerConfig[1].name, 名字
iconName = "0_10103", --图片ID
-- zoomMin = 0, 最小scale倍率
-- zoomMax = 100, 最大scale倍率
-- isTrace = false, 是否追踪
-- isRadarTrace = false, 雷达上是否追踪
-- appearInBlockFog = true,
-- isCanUI = false, 是否能点击
-- desc = "", 描述
-- level = 4, UI层级
}
local result = World:PixelMapRefreshMarker(Player:GetHostUin(), "markId_123", params)PixelMapDelMarker
lua
local result = World:PixelMapDelMarker(Player:GetHostUin(), "markId_123")PixelMapAddTexture
- 参数及类型:
- 返回值及类型:
- ret:
boolean是否添加成功
- ret:
- 该方法的其他说明: 在地图纹理节点上叠加一张纹理(可用于背景/遮罩/自定义装饰)
- 具体使用案例如下:
lua
--开发者添加纹理到地图纹理节点,可以修饰原本的地图纹理(比如加背景,遮罩,自定义地图纹理)
local x, y, z = Actor:GetPosition(Player:GetHostUin())
local params = {
filePath = "0_10103", --图片id
width = 100, --宽度
height = 100, --高度
posX = x, --在地图上的方块位置
posZ = z, --在地图上的方块位置
level = 11, --层级 官方地图纹理层级为10
pivotX = 0, --x轴锚点
pivotY = 0, --z轴锚点
alpha = 1, --透明度
scale = 1, --缩放
rotation = 0, --旋转
colorR = 255, --颜色
colorG = 255, --颜色
colorB = 255, --颜色
}
local result = World:PixelMapAddTexture(Player:GetHostUin(), "textureId_1", params)PixelMapRefreshTexture
- 参数及类型:
- 返回值及类型:
- ret:
boolean是否刷新成功
- ret:
- 该方法的其他说明: 刷新地图上的开发者纹理标签(params 只需提供要变更的字段)
- 具体使用案例如下:
lua
local x, y, z = Actor:GetPosition(Player:GetHostUin())
local params = {
filePath = "0_10104", --图片id
width = 100, --宽度
height = 100, --高度
posX = x, --在地图上的方块位置
posZ = z, --在地图上的方块位置
level = 11, --层级 官方地图纹理层级为10
pivotX = 0, --x轴锚点
pivotY = 0, --z轴锚点
alpha = 1, --透明度
scale = 1, --缩放
rotation = 0, --旋转
colorR = 255, --颜色
colorG = 255, --颜色
colorB = 255, --颜色
}
local result = World:PixelMapRefreshTexture(Player:GetHostUin(), "textureId_1", params)PixelMapDelTexture
lua
local result = World:PixelMapDelTexture(Player:GetHostUin(), "textureId_1")SetSkyBoxColorAnim
- 参数及类型:
- 返回值及类型:
- ret:
boolean是否设置成功
- ret:
- 该方法的其他说明: 给指定玩家设置天空盒颜色参数(带动画过渡)
- 具体使用案例如下:
lua
local result = World:SetSkyBoxColorAnim(Player:GetHostUin(), SkyboxColor.Moon, [=[0xffe082]=], Easing.Linear, 1)SetTimeVanishingSpeed
lua
local result = World:SetTimeVanishingSpeed(20)SetSkyBoxTemplate
- 参数及类型:
- 返回值及类型:
- ret:
boolean是否设置成功
- ret:
- 该方法的其他说明: 设置天空盒模板(官方模板填数值,自定义模板填ID)
- 具体使用案例如下:
lua
local result = World:SetSkyBoxTemplate(7)SetSkyBoxMaps
- 参数及类型:
- 返回值及类型:
- ret:
boolean是否设置成功
- ret:
- 该方法的其他说明: 设置天空盒贴图
- 具体使用案例如下:
lua
local result = World:SetSkyBoxMaps(SkyboxMap.Sky, [=[0_30011]=])SetSkyBoxColor
- 参数及类型:
- time:
number游戏时间(小时) - itype:
number颜色属性枚举(SkyboxColor)SkyboxColor - color:
string16进制颜色值(如0xffffff)
- time:
- 返回值及类型:
- ret:
boolean是否设置成功
- ret:
- 该方法的其他说明: 设置天空盒在指定时间点的颜色参数
- 具体使用案例如下:
lua
local result = World:SetSkyBoxColor(SkyboxTime.Current, SkyboxColor.Top, [=[0x1e88e5]=])SetSkyBoxAttr
- 参数及类型:
- time:
number游戏时间(小时) - itype:
number参数类型(SkyboxAttr)SkyboxAttr - value:
number参数值(0~100)
- time:
- 返回值及类型:
- ret:
boolean是否设置成功
- ret:
- 该方法的其他说明: 设置天空盒在指定时间点的属性参数
- 具体使用案例如下:
lua
local result = World:SetSkyBoxAttr(SkyboxTime.Current, SkyboxAttr.SunScale, 20)SetSkyBoxAttrWithNoTime
- 参数及类型:
- itype:
number参数类型(SkyboxAttr)SkyboxAttr - value:
number参数值(0~100)
- itype:
- 返回值及类型:
- ret:
boolean是否设置成功
- ret:
- 该方法的其他说明: 设置天空盒属性参数(不带时间维度,直接作用于当前配置)
- 具体使用案例如下:
lua
local ret = World:SetSkyBoxAttrWithNoTime(itype, value)SetSkyBoxFilter
- 参数及类型:
- playerid:
number玩家ID - itype:
number参数类型(SkyboxFilter)SkyboxFilter - value:
number/string参数值(0~100)或16进制颜色值(如0xffffff)
- playerid:
- 返回值及类型:
- ret:
boolean是否设置成功
- ret:
- 该方法的其他说明: 给指定玩家设置天空盒滤镜参数(数值或颜色)
- 具体使用案例如下:
lua
local result = World:SetSkyBoxFilter(Player:GetHostUin(), SkyboxFilter.Contrast, 50)SetSkyBoxSwitch
- 参数及类型:
- time:
number游戏时间(小时) - itype:
number参数类型(SkyboxSwitch)SkyboxSwitch - value:
number开关值(0/1)
- time:
- 返回值及类型:
- ret:
boolean是否设置成功
- ret:
- 该方法的其他说明: 设置天空盒属性开关
- 具体使用案例如下:
lua
local result = World:SetSkyBoxSwitch(SkyboxTime.Current, SkyboxSwitch.Fogenable, true)SetSkyBoxMapsAnim
- 参数及类型:
- 返回值及类型:
- ret:
boolean是否设置成功
- ret:
- 该方法的其他说明: 给指定玩家设置天空盒贴图(带动画过渡)
- 具体使用案例如下:
lua
local result = World:SetSkyBoxMapsAnim(Player:GetHostUin(), SkyboxMap.Sky, [=[0_30005]=], Easing.BackOut, 1)SetSkyBoxFilterAnim
- 参数及类型:
- 返回值及类型:
- ret:
boolean是否设置成功
- ret:
- 该方法的其他说明: 给指定玩家设置天空盒滤镜参数(带动画过渡)
- 具体使用案例如下:
lua
local result = World:SetSkyBoxFilterAnim(Player:GetHostUin(), SkyboxFilter.Color, [=[0xffee58]=], Easing.Linear, 1)GetLocalDate
lua
local date = World:GetLocalDate(EventDate.Day)GetLocalDateString
- 参数及类型: 无
- 返回值及类型:
- ret:
string时间字符串
- ret:
- 该方法的其他说明: 获取完整本地设备时间字符串
- 具体使用案例如下:
lua
local dateString = World:GetLocalDateString()GetServerDate
- 参数及类型:
- enum:
number枚举值(EventDate)
- enum:
- 返回值及类型:
- ret:
number时间值(取不到返回0)
- ret:
- 该方法的其他说明: 获取服务器时间的指定字段(云服模式下会回退到本地时间)
- 具体使用案例如下:
lua
local date = World:GetServerDate()GetDateFromTime
- 参数及类型:
- 返回值及类型:
- ret:
number时间值(入参非法返回0)
- ret:
- 该方法的其他说明: 把时间戳拆出指定字段(年/月/日/时/分/秒等)
- 具体使用案例如下:
lua
local date = World:GetDateFromTime(os.time(), EventDate.Day)GetDirRayDetection
- 参数及类型:
- 返回值及类型: ret:number|nil,vec:table|nil:命中ID与命中位置{x=0,y=0,z=0}(未命中返回nil)
- 该方法的其他说明: 从起点沿方向做射线检测,返回命中的对象/方块及命中位置
- 具体使用案例如下:
lua
local ray = Player:GetAimDir(uin)
local x,y,z = Player:GetRayOriginPos(uin)
local id = World:GetDirRayDetection({x=x, y=y, z=z}, {x= ray.x, y= ray.y, z= ray.z}, 10, RayDetectType.Block, WorldId)GetRayLength
- 参数及类型:
- 返回值及类型:
- ret:
number/ nil 射线长度(失败返回nil)
- ret:
- 该方法的其他说明: 从起点到终点方向做射线检测,计算射线在遇到方块前的长度
- 具体使用案例如下:
lua
local x, y, z = Actor:GetPosition(Player:GetHostUin())
local length = World:GetRayLength(x, y, z, x, y + 20, z, 100, WorldId)GetRayBlock
- 参数及类型:
- 返回值及类型:
- 该方法的其他说明: 从起点沿指定面/方向做射线检测,返回命中的方块ID(未命中返回nil)
- 具体使用案例如下:
lua
local x, y, z = Actor:GetPosition(Player:GetHostUin())
local block = World:GetRayBlock(x, y, z, FaceDir.NegY, 100, WorldId)CalcDirectionByYawDirection
- 参数及类型:
- 返回值及类型: ret:table|nil:世界方向向量{x: number, y: number, z: number}(失败返回nil)
- 该方法的其他说明: 把局部坐标方向转换为世界方向(忽略视角仰角)
- 具体使用案例如下:
lua
local direction = World:CalcDirectionByYawDirection(Player:GetHostUin(), 100, 100, 100)CalcDirectionByYawAngle
- 参数及类型:
- 返回值及类型:
- ret:
table/ nil 世界方向向量{x,y,z}(失败返回nil)
- ret:
- 该方法的其他说明: 把局部球坐标方向转换为世界方向(忽略视角仰角)
- 具体使用案例如下:
lua
local direction = World:CalcDirectionByYawAngle(Player:GetHostUin(), 30, 45)CalcDirectionByCoord
- 参数及类型:
- 返回值及类型: ret:table:方向向量{x: number, y: number, z: number}
- 该方法的其他说明: 不做任何数学换算,只是把三个坐标放进一张表里
- 具体使用案例如下:
lua
local direction = World:CalcDirectionByCoord(10 ,20, 30)CalcDirectionByAngle
- 参数及类型:
- 返回值及类型: ret:table|nil:方向向量{x: number, y: number, z: number}(入参非法返回nil)
- 该方法的其他说明: 把水平角和俯仰角转换为方向向量
- 具体使用案例如下:
lua
local direction = World:CalcDirectionByAngle(45, 45)RandomParticleEffectID
- 参数及类型: 无
- 返回值及类型:
- ret:
number/ nil 特效ID(取不到返回nil)
- ret:
- 该方法的其他说明: 从粒子特效表中随机返回一个可触发的特效ID
- 具体使用案例如下:
lua
local id = World:RandomParticleEffectID()RandomSoundID
- 参数及类型: 无
- 返回值及类型:
- ret:
number/ nil 音效ID(取不到返回nil)
- ret:
- 该方法的其他说明: 从音效表中随机返回一个音效ID
- 具体使用案例如下:
lua
local id = World:RandomSoundID()CalcDistance
- 参数及类型:
- posSrc:table:源坐标{x: number, y: number, z: number}
- posDst:table:目标坐标{x: number, y: number, z: number}
- 返回值及类型:
- ret:
number/ nil 两点距离(入参非法返回nil)
- ret:
- 该方法的其他说明: 计算两个三维坐标之间的直线距离
- 具体使用案例如下:
lua
local distance = World:CalcDistance({x = 0, y = 0, z = 0}, {x = 10, y = 0, z = 0})SetGroupWeather
- 参数及类型:
- groupid:
number天气组ID(WeatherGroup)WeatherGroup - weatherid:
number天气ID(GroupWeatherType)GroupWeatherType
- groupid:
- 返回值及类型:
- ret:
boolean是否设置成功
- ret:
- 该方法的其他说明: 设置某个天气组的天气状态
- 具体使用案例如下:
lua
local result = World:SetGroupWeather(WeatherGroup.Common, GroupWeatherType.Shine)RandomWeatherID
- 参数及类型: 无
- 返回值及类型:
- ret:
number/ nil 天气ID(取不到返回nil)
- ret:
- 该方法的其他说明: 从可用天气列表中随机一个天气ID
- 具体使用案例如下:
lua
local id = World:RandomWeatherID()GetGroupWeather
- 参数及类型:
- groupid:
number天气组ID(WeatherGroup)
- groupid:
- 返回值及类型:
- ret:
number/ nil 天气值(入参非法返回nil)
- ret:
- 该方法的其他说明: 获取指定天气组当前的天气值
- 具体使用案例如下:
lua
local weather = World:GetGroupWeather(WeatherGroup.Common)SetSpawnPoint
lua
local x, y, z = Actor:GetPosition(Player:GetHostUin())
local result = World:SetSpawnPoint(x, y, z)CalcDirectionByPos2Pos
- 参数及类型:
- 返回值及类型:
- ret:
table/ nil 单位方向{x,y,z}(入参非法返回nil)
- ret:
- 该方法的其他说明: 计算从位置1指向位置2的单位方向向量
- 具体使用案例如下:
lua
local ret = World:CalcDirectionByPos2Pos(pos1, pos2)SetWorldCreateMobRule
- 参数及类型:
- 返回值及类型:
- ret:
boolean是否设置成功
- ret:
- 该方法的其他说明: 设置世界生物生成规则(不保存,退出游戏后失效)
- 具体使用案例如下:
lua
local cfgs = {
-- 草原
[BiomeType.GrassLand] = {
{
id = 3400, -- 生物id,嘟嘟鸟
weight = 100 -- 权重
},
{
id = 3401, -- 生物id
weight = 100 -- 权重
},
},
[BiomeType.Forest] = {--迷拉星森林
{
id = 3400,
weight = 50
}
}
}
local result = World:SetWorldCreateMobRule(cfgs)SetMobSpawnDensity
- 参数及类型:
- 返回值及类型:
- ret:
boolean是否设置成功
- ret:
- 该方法的其他说明: 设置生物生成密度(不保存,退出游戏后失效)
- 具体使用案例如下:
lua
local result = World:SetMobSpawnDensity(MobType.Passive, 100) -- 设置动物密度SetPlantGrowRate
- 参数及类型:
- 返回值及类型:
- ret:
boolean是否设置成功
- ret:
- 该方法的其他说明: 设置农作物生长时间倍率(在原时间上乘以系数;不保存,退出游戏后失效)
- 具体使用案例如下:
lua
local result = World:SetPlantGrowRate(0.5) -- 设置生长速度为原来的0.5倍SetInnerViewEnable
- 参数及类型:
- iview:
number弹窗类型枚举(InnerPopUpview)InnerPopUpview - bopen:
boolean启用(true)/禁用(false)
- iview:
- 返回值及类型:
- ret:
boolean是否设置成功
- ret:
- 该方法的其他说明: 设置某类内置界面是否禁用
- 具体使用案例如下:
lua
-- 一般和Player:OpenInnerView 接口配合使用
local ret = World:SetInnerViewEnable(InnerPopUpview.CollectMaps,false)
if ret then
print("设置成功")
endSetMidJoin
lua
local ret = World:SetMidJoin(true)
if ret then
print("设置成功")
endGetGameMode
- 参数及类型: 无
- 返回值及类型:
- ret:
number/ nil 游戏模式(WorldType)
- ret:
- 该方法的其他说明: 获取当前游戏模式
- 具体使用案例如下:
lua
local curmode = World:GetGameMode()
if curmode and curmode == WorldType.GamemakerRun then
print("当前地图是玩法模式")
elseif curmode and curmode == WorldType.Single then
print("当前地图是冒险模式")
endSetLightByPos
- 参数及类型:
- 返回值及类型:
- ret:
boolean是否设置成功
- ret:
- 该方法的其他说明: 设置指定位置的方块光照强度<1.50+>
- 具体使用案例如下:
lua
local result = World:SetLightByPos(x, y, z, 10, WorldId)
print("设置光照强度 10 ", result)