mirror of
https://github.com/edubart/otclient.git
synced 2025-04-30 17:49:21 +02:00

* Started building the market UI. * More work on the market functionality. * Fixes to the market protocol. (Known issue: if I use safeSend method from Market (like so: MarketProtocol.send~) is thinks it is a bot). * Fixes to the market offer class. * Outfit window will no longer display the mount box if you are using protocol < 870. * Added getFeature to playermount module. * Added isMarketable and getMarketData to the lua binding. * Added lua casts for MarketData. * Fixed typo in the module manager. * Added new 'light flat panel' for more variation (can change later) will require some graphics for market. * Added new functions to table lib. * Fixed some styling issues from previous commits.
78 lines
1.3 KiB
Lua
78 lines
1.3 KiB
Lua
-- @docclass table
|
|
|
|
function table.dump(t, depth)
|
|
if not depth then depth = 0 end
|
|
for k,v in pairs(t) do
|
|
str = (' '):rep(depth * 2) .. k .. ': '
|
|
if type(v) ~= "table" then
|
|
print(str .. tostring(v))
|
|
else
|
|
print(str)
|
|
table.dump(v, depth+1)
|
|
end
|
|
end
|
|
end
|
|
|
|
function table.copy(t)
|
|
local res = {}
|
|
for k,v in pairs(t) do
|
|
res[k] = v
|
|
end
|
|
return res
|
|
end
|
|
|
|
function table.selectivecopy(t, keys)
|
|
local res = { }
|
|
for i,v in ipairs(keys) do
|
|
res[v] = t[v]
|
|
end
|
|
return res
|
|
end
|
|
|
|
function table.merge(t, src)
|
|
for k,v in pairs(src) do
|
|
t[k] = v
|
|
end
|
|
end
|
|
|
|
function table.find(t, value)
|
|
for k,v in pairs(t) do
|
|
if v == value then return k end
|
|
end
|
|
end
|
|
|
|
function table.findKey(t, key)
|
|
if t and type(t) == 'table' then
|
|
for k,v in pairs(t) do
|
|
if k == key then return k end
|
|
end
|
|
end
|
|
end
|
|
|
|
function table.hasKey(t, key)
|
|
return table.findKey(t, key) ~= nil
|
|
end
|
|
|
|
function table.removevalue(t, value)
|
|
for k,v in pairs(t) do
|
|
if v == value then
|
|
table.remove(t, k)
|
|
break
|
|
end
|
|
end
|
|
end
|
|
|
|
function table.compare(t, other)
|
|
if #t ~= #other then return false end
|
|
for k,v in pairs(t) do
|
|
if v ~= other[k] then return false end
|
|
end
|
|
return true
|
|
end
|
|
|
|
function table.empty(t)
|
|
if t and type(t) == 'table' then
|
|
return next(t) == nil
|
|
end
|
|
return true
|
|
end |