编写人员:雪舞
--===================
--通过道具ID 获取元宝商店物品价格
--===================
function LuaFnGetItemPrice(ItemId)
if ItemId < 10000000 then
return -1
end
if ItemId >= 60000000 then
return -1
end
local handle = io.open("./ShopTable.dll","r")
local nItemID = 0
local nItemNum = 0
local ItemPrice = 0
local nItemSign =100
local line = handle:read("*line")
while line do
nData = LuaSplit(line,"\t")
if tonumber(nData[6]) ~= nil then
if ItemId == tonumber(nData[6]) then
nItemID = tonumber(nData[6]) --物品id
nItemNum = tonumber(nData[7]) --物品数量
ItemPrice = tonumber(nData[8]) --物品价格
nItemSign = tonumber(nData[9]) --物品折扣
break
end
end
line = handle:read("*line")
end
handle:close()
--返回商店价格,货币类型由商店自行判断,有元宝、红利、福禄点等。
--返回 -1 代表获取错误
return ItemPrice,nItemNum,nItemID,nItemSign
end
--分割函数
function LuaSplit(szFullString, szSeparator)
local nFindStartIndex = 1
local nSplitIndex = 1
local nSplitArray = {}
while 1 do
local nFindLastIndex = string.find(szFullString, szSeparator, nFindStartIndex)
if not nFindLastIndex then
nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, string.len(szFullString))
break
end
nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, nFindLastIndex - 1)
nFindStartIndex = nFindLastIndex + string.len(szSeparator)
nSplitIndex = nSplitIndex + 1
end
return nSplitArray
end
|