Version 2.3 - cooldowns in action bar, more advanced bot, new cavebot, bug fixes

This commit is contained in:
OTCv8
2020-04-15 01:22:06 +02:00
parent ed8162a9d5
commit 9a4ab2ae3b
68 changed files with 3261 additions and 428 deletions

View File

@@ -1,7 +1,7 @@
--
-- json.lua
--
-- Copyright (c) 2018 rxi
-- Copyright (c) 2019 rxi
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy of
-- this software and associated documentation files (the "Software"), to deal in
@@ -46,26 +46,40 @@ for k, v in pairs(escape_char_map) do
end
local function make_indent(state)
return string.rep(" ", state.currentIndentLevel * state.indent)
end
local function escape_char(c)
return escape_char_map[c] or string.format("\\u%04x", c:byte())
end
local function encode_nil(val)
local function encode_nil()
return "null"
end
local function encode_table(val, stack)
local function encode_table(val, state)
local res = {}
stack = stack or {}
local stack = state.stack
local pretty = state.indent > 0
local close_indent = make_indent(state)
local comma = pretty and ",\n" or ","
local colon = pretty and ": " or ":"
local open_brace = pretty and "{\n" or "{"
local close_brace = pretty and ("\n" .. close_indent .. "}") or "}"
local open_bracket = pretty and "[\n" or "["
local close_bracket = pretty and ("\n" .. close_indent .. "]") or "]"
-- Circular reference?
if stack[val] then error("circular reference") end
stack[val] = true
if val[1] ~= nil or next(val) == nil then
if rawget(val, 1) ~= nil or next(val) == nil then
-- Treat as array -- check keys are valid and it is not sparse
local n = 0
for k in pairs(val) do
@@ -78,11 +92,13 @@ local function encode_table(val, stack)
error("invalid table: sparse array")
end
-- Encode
for i, v in ipairs(val) do
table.insert(res, encode(v, stack))
for _, v in ipairs(val) do
state.currentIndentLevel = state.currentIndentLevel + 1
table.insert(res, make_indent(state) .. encode(v, state))
state.currentIndentLevel = state.currentIndentLevel - 1
end
stack[val] = nil
return "[" .. table.concat(res, ",") .. "]"
return open_bracket .. table.concat(res, comma) .. close_bracket
else
-- Treat as an object
@@ -90,10 +106,12 @@ local function encode_table(val, stack)
if type(k) ~= "string" then
error("invalid table: mixed or invalid key types")
end
table.insert(res, encode(k, stack) .. ":" .. encode(v, stack))
state.currentIndentLevel = state.currentIndentLevel + 1
table.insert(res, make_indent(state) .. encode(k, state) .. colon .. encode(v, state))
state.currentIndentLevel = state.currentIndentLevel - 1
end
stack[val] = nil
return "{" .. table.concat(res, ",") .. "}"
return open_brace .. table.concat(res, comma) .. close_brace
end
end
@@ -121,18 +139,22 @@ local type_func_map = {
}
encode = function(val, stack)
encode = function(val, state)
local t = type(val)
local f = type_func_map[t]
if f then
return f(val, stack)
return f(val, state)
end
error("unexpected type '" .. t .. "'")
end
function json.encode(val)
return ( encode(val) )
function json.encode(val, indent)
local state = {
indent = indent or 0,
currentIndentLevel = 0,
stack = {}
}
return encode(val, state)
end

View File

@@ -155,3 +155,9 @@ end
function UITabBar:getTabsPanel()
return table.collect(self.tabs, function(_,tab) return tab.tabPanel end)
end
function UITabBar:clearTabs()
while #self.tabs > 0 do
self:removeTab(self.tabs[#self.tabs])
end
end