基础对象
获得对象唯一id get_uuid
- args:
名字 | 类型 | 说明、描述 |
---|---|---|
obj | userdata | 对象 |
- | - | - |
- ret:
number
唯一id
通过唯一id获得对象 get_by_uuid
- args:
名字 | 类型 | 说明、描述 |
---|---|---|
uuid | number | 唯一id |
- | - | - |
ret:
userdata
对象示例:
function isc_test_object:get_by_uuid()
local obj = edi.player:owner(module.player)
local uuid = edi.object:get_uuid(obj)
local result = edi.object:get_by_uuid(uuid)
LOGI("isc test: " .. edi.object:get_uuid(result))
end
获取对象基础属性 int get_attr_int
- args:
名字 | 类型 | 说明、描述 |
---|---|---|
obj | userdata | 对象 |
id | number | 属性id |
- | - | - |
ret:
number
属性值示例:
function isc_test_object:get_attr_int()
local obj = edi.player:owner(module.player)
-- 当前生命
local hp = edi.object:get_attr_int(obj, AttrDef.EN_ATTR_1)
LOGI("isc test: " .. hp)
end
设置对象基础属性 int set_attr_int
- args:
名字 | 类型 | 说明、描述 |
---|---|---|
obj | userdata | 对象 |
id | number | 属性id |
val | number | 属性值 |
- | - | - |
ret:
boolean
是否成功示例:
function isc_test_object:set_attr_int()
local obj = edi.player:owner(module.player)
-- 当前生命
local hp = edi.object:get_attr_int(obj, AttrDef.EN_ATTR_1)
edi.object:set_attr_int(obj, AttrDef.EN_ATTR_1, hp - 100)
hp = edi.object:get_attr_int(obj, AttrDef.EN_ATTR_1)
LOGI("isc test: " .. hp)
end
获得对象名字 get_name
- args:
名字 | 类型 | 说明、描述 |
---|---|---|
obj | userdata | 对象 |
- | - | - |
ret:
string
名字示例:
function isc_test_object:get_name()
local obj = edi.player:owner(module.player)
LOGI("isc test: " .. edi.object:get_name(obj))
end
判断对象是否是玩家 is_player
- args:
名字 | 类型 | 说明、描述 |
---|---|---|
obj | userdata | 对象 |
- | - | - |
ret:
boolean
true:是,false:否示例:
function isc_test_object:is_player()
local obj = edi.player:owner(module.player)
LOGI("isc test: " .. tostring(edi.object:is_player(obj)))
end
判断对象是否是怪物 is_monster
- args:
名字 | 类型 | 说明、描述 |
---|---|---|
obj | userdata | 对象 |
- | - | - |
ret:
boolean
true:是,false:否示例:
function isc_test_object:is_monster()
local obj = edi.player:owner(module.player)
LOGI("isc test: " .. tostring(edi.object:is_monster(obj)))
end
判断对象是否是npc is_npc
- args:
名字 | 类型 | 说明、描述 |
---|---|---|
obj | userdata | 对象 |
- | - | - |
ret:
boolean
true:是,false:否示例:
function isc_test_object:is_npc()
local obj = edi.player:owner(module.player)
LOGI("isc test: " .. tostring(edi.object:is_npc(obj)))
end
判断对象是否是宠物 is_pet
- args:
名字 | 类型 | 说明、描述 |
---|---|---|
obj | userdata | 对象 |
- | - | - |
ret:
boolean
true:是,false:否示例:
function isc_test_object:is_pet()
local obj = edi.player:owner(module.player)
LOGI("isc test: " .. tostring(edi.object:is_pet(obj)))
end
判断对象是否是场景道具 is_scene_item
- args:
名字 | 类型 | 说明、描述 |
---|---|---|
obj | userdata | 对象 |
- | - | - |
ret:
boolean
true:是,false:否示例:
function isc_test_object:is_scene_item()
local obj = edi.player:owner(module.player)
LOGI("isc test: " .. tostring(edi.object:is_scene_item(obj)))
end
获得对象当前场景 get_scene
- args:
名字 | 类型 | 说明、描述 |
---|---|---|
obj | userdata | 对象 |
- | - | - |
ret:
userdata
当前场景示例:
function isc_test_object:get_scene()
local obj = edi.player:owner(module.player)
local pScene = edi.object:get_scene(obj)
if not pScene then
return
end
local scene_uid = edi.scene:get_uuid(pScene)
LOGI("curr scene uuid :"..scene_uuid)
end
获得对象当前场景配置id get_scene_id
- args:
名字 | 类型 | 说明、描述 |
---|---|---|
obj | userdata | 对象 |
- | - | - |
- ret:
number
当前场景配置id
获得对象当前场景唯一id get_scene_uuid
- args:
名字 | 类型 | 说明、描述 |
---|---|---|
obj | userdata | 对象 |
- | - | - |
- ret:
number
当前场景唯一id
获得对象当前坐标 get_scene_pos
- args:
名字 | 类型 | 说明、描述 |
---|---|---|
obj | userdata | 对象 |
- | - | - |
- ret:
pos_info
当前坐标
设置对象立即死亡 set_dead
- args:
名字 | 类型 | 说明、描述 |
---|---|---|
obj | userdata | 对象 |
- | - | - |
ret: 无
示例:
function isc_test_object:set_dead()
local obj = edi.player:owner(module.player)
edi.object:set_dead(obj)
local hp = edi.object:get_attr_int(obj, AttrDef.EN_ATTR_1)
LOGI("isc test: " .. hp)
end
判断对象是否死亡 is_dead
- args:
名字 | 类型 | 说明、描述 |
---|---|---|
obj | userdata | 对象 |
- | - | - |
ret:
boolean
是否死亡示例:
function isc_test_object:is_dead()
local obj = edi.player:owner(module.player)
local bRet = edi.npc:is_dead(obj)
if bRet == true then
print("当前对象处于死亡状态")
end
end
刷新外观信息 refresh_appear
- args:
名字 | 类型 | 说明、描述 |
---|---|---|
obj | userdata | 对象 |
- | - | - |
ret: 无
示例:
function isc_test_object:refresh_appear()
local obj = edi.player:owner(module.player)
-- edi.object:refresh_appear(obj)
end
获得对象自定义扩展数据(运行时数据,不存储数据库) get_ext
- args:
名字 | 类型 | 说明、描述 |
---|---|---|
obj | userdata | 对象 |
key | string | 扩展数据key |
- | - | - |
ret:
string
扩展数据示例:
function isc_test_object:get_ext()
local obj = edi.player:owner(module.player)
local test_key = "object测试的key-1"
local test_val = "object测试的value-1"
edi.object:set_ext(obj, test_key, test_val)
LOGI("isc test: " .. edi.object:get_ext(obj, test_key))
end
设置对象自定义扩展数据(运行时数据,不存储数据库) set_ext
- args:
名字 | 类型 | 说明、描述 |
---|---|---|
obj | userdata | 对象 |
key | string | 扩展数据key |
val | string | 扩展数据 |
- | - | - |
ret: 无
示例:
function isc_test_object:set_ext(obj, key, val)
local obj = edi.player:owner(module.player)
local test_key = "object测试的key-1"
local test_val = "object测试的value-1"
edi.object:set_ext(obj, test_key, test_val)
LOGI("isc test: " .. edi.object:get_ext(obj, test_key))
end
获得对象之间的距离(不在同一场景返回-1) get_distance
- args:
名字 | 类型 | 说明、描述 |
---|---|---|
obj1 | userdata | 对象 |
obj2 | userdata | 对象 |
- | - | - |
ret:
number
距离示例:
function isc_test_object:get_distance(obj, key, val)
local obj = edi.player:owner(module.player)
local obj_npc = edi.npc:get_by_id(201) -- "新人大使"
LOGI("isc test: " .. edi.object:get_distance(obj, obj_npc))
end
获得对象与指定坐标点的距离 pos_distance
- args:
名字 | 类型 | 说明、描述 |
---|---|---|
obj | userdata | 对象 |
cpt | pos_info | 坐标点 |
- | - | - |
ret:
number
距离示例:
function isc_test_object:pos_distance()
local obj = edi.player:owner(module.player)
local pos = edi.object:get_scene_pos(obj)
local nextPos =
{
x = pos.x + 5,
y = pos.y + 5
}
local distance = edi.object:pos_distance(obj, nextPos)
print("distance = ", distance)
end
设置显示信息 set_show
- args:
名字 | 类型 | 说明、描述 |
---|---|---|
obj | userdata | 对象 |
show | player_show_info | 显示信息对象(player_show_info结构) |
- | - | - |
ret:
boolean
是否成功示例:
function isc_test_object:set_show()
local obj = edi.player:owner(module.player)
local ret = edi.npc:set_show(obj, {id = 1, show_type=1, ctx="context"})
print("result = ", ret)
end
获取显示信息 get_show
- args:
名字 | 类型 | 说明、描述 |
---|---|---|
obj | userdata | 对象 |
id | number | 显示信息id |
- | - | - |
ret:
player_show_info
显示信息对象(player_show_info结构)示例:
function isc_test_object:get_show()
local obj = edi.player:owner(module.player)
local ret = edi.npc:get_show(obj, 1)
print("result = ", ret)
end
清除显示信息 clear_show
- args:
名字 | 类型 | 说明、描述 |
---|---|---|
obj | userdata | 对象 |
id | number | 显示信息id |
- | - | - |
ret:
boolean
是否成功示例:
function isc_test_object:clear_show()
local obj = edi.player:owner(module.player)
local ret = edi.npc:clear_show(obj, 1)
print("result = ", ret)
end