142 lines
3.3 KiB
Lua
142 lines
3.3 KiB
Lua
Item = {}
|
|
|
|
---* 获取物品名字通过对象
|
|
function Item.GetNameByObj(actor, itemObj)
|
|
return getiteminfo(actor, itemObj, ConstCfg.iteminfo.name)
|
|
end
|
|
|
|
---* 物品进背包前触发,未开通特权,进行绑定
|
|
function Item.Setstate(actor,itemObj)
|
|
if not isnotnull(actor) then
|
|
return false
|
|
end
|
|
|
|
local config = {
|
|
[2] = "禁止交易",
|
|
[16] = "禁止出售",
|
|
[64] = "丢弃消失",
|
|
[256] = "禁止摆摊或上架拍卖行",
|
|
[1024] = "爆出消失",
|
|
[2048] = "上线消失",
|
|
}
|
|
|
|
local bind = 0
|
|
for k, v in pairs(config) do
|
|
bind = bind + k
|
|
end
|
|
|
|
if bind > 0 then
|
|
setitemstate(actor,itemObj,bind,1)
|
|
end
|
|
end
|
|
|
|
|
|
--------------* 普通变量-----------------
|
|
---* 设置物品str变量
|
|
function Item.setstr(actor, MakeIndex, key, nValue)
|
|
SetStr(3, MakeIndex, key, nValue)
|
|
SendItemVarToc(actor, MakeIndex)
|
|
end
|
|
|
|
---* 设置物品int变量
|
|
function Item.setint(actor, MakeIndex, key, nValue)
|
|
SetInt(3, MakeIndex, key, nValue)
|
|
SendItemVarToc(actor, MakeIndex)
|
|
end
|
|
|
|
---* 获取物品str变量
|
|
function Item.getstr(MakeIndex, key)
|
|
return GetStr(3, MakeIndex, key)
|
|
end
|
|
|
|
---* 获取物品int变量
|
|
function Item.getint(MakeIndex, key)
|
|
return GetInt(3, MakeIndex, key)
|
|
end
|
|
|
|
--------------* 临时变量-----------------
|
|
---* 设置物品临时str变量
|
|
function Item.settempstr(actor, MakeIndex, key, nValue)
|
|
if not isnotnull(actor) then
|
|
return
|
|
end
|
|
SetTempStr(3, MakeIndex, key, nValue)
|
|
SendItemVarToc(actor, MakeIndex)
|
|
end
|
|
|
|
---* 设置物品临时int变量
|
|
function Item.settempint(actor, MakeIndex, key, nValue)
|
|
if not isnotnull(actor) then
|
|
return
|
|
end
|
|
SetTempInt(3, MakeIndex, key, nValue)
|
|
SendItemVarToc(actor, MakeIndex)
|
|
end
|
|
|
|
---* 设置物品临时int变量+值
|
|
function Item.additempint(actor, MakeIndex, key, nValue)
|
|
if not isnotnull(actor) then
|
|
return
|
|
end
|
|
SetTempInt(3, MakeIndex, key, Item.gettempint(MakeIndex, key) + nValue)
|
|
SendItemVarToc(actor, MakeIndex)
|
|
end
|
|
|
|
---* 获取物品临时str变量
|
|
function Item.gettempstr(MakeIndex, key)
|
|
return GetTempStr(3, MakeIndex, key)
|
|
end
|
|
|
|
---* 获取物品临时int变量
|
|
function Item.gettempint(MakeIndex, key)
|
|
return GetTempInt(3, MakeIndex, key)
|
|
end
|
|
|
|
--------------------------* 期限变量------------------------------
|
|
---* 设置玩家期限str变量
|
|
---* 玩家对象
|
|
---* 变量名
|
|
---* 值
|
|
---* 时间戳 可空 默认明天0点过期
|
|
---@param actor any
|
|
---@param key any
|
|
---@param value any
|
|
---@param time any
|
|
function Item.setTLstr(actor, MakeIndex, key, value, time)
|
|
if not isnotnull(actor) then
|
|
return
|
|
end
|
|
SetTLStr(3, MakeIndex, key, value, time or DateOBJ.getTomorrowZero())
|
|
SendItemVarToc(actor, MakeIndex)
|
|
end
|
|
|
|
---* 设置玩家期限int变量
|
|
---* 玩家对象
|
|
---* 变量名
|
|
---* 值
|
|
---* 时间戳 可空 默认明天0点过期
|
|
---@param actor any
|
|
---@param key any
|
|
---@param value any
|
|
---@param time any
|
|
function Item.setTLint(actor, MakeIndex, key, value, time)
|
|
if not isnotnull(actor) then
|
|
return
|
|
end
|
|
SetTLInt(3, MakeIndex, key, value, time or DateOBJ.getTomorrowZero())
|
|
SendItemVarToc(actor, MakeIndex)
|
|
end
|
|
|
|
---* 获取玩家期限str变量
|
|
function Item.getTLstr(MakeIndex, key)
|
|
local value, time = GetTLStr(3, MakeIndex, key)
|
|
return value
|
|
end
|
|
|
|
---* 获取玩家期限int变量
|
|
function Item.getTLint(MakeIndex, key)
|
|
local value, time = GetTLInt(3, MakeIndex, key)
|
|
return value
|
|
end
|
|
|
|
return Item
|