This commit is contained in:
Igor Timofeev
2017-08-21 15:03:52 +03:00
parent d5ceae4455
commit f797470338
3 changed files with 24 additions and 25 deletions

View File

@@ -1,6 +1,6 @@
--[[
Advanced Lua Library v1.1 by ECS
This library extends a lot of default Lua methods
@@ -70,7 +70,7 @@ end
-- Split nubmer to it's own bytes with specified count of bytes (0xAABB, 5 -> {0x00, 0x00, 0x00, 0xAA, 0xBB})
function bit32.numberToFixedSizeByteArray(number, size)
local byteArray, counter = {}, 0
repeat
table.insert(byteArray, 1, bit32.band(number, 0xFF))
number = bit32.rshift(number, 8)
@@ -100,12 +100,13 @@ function bit32.bitArrayToByte(bitArray)
for i = 1, #bitArray do
number = bit32.bor(bitArray[i], bit32.lshift(number, 1))
end
return number
end
-------------------------------------------------- Math extensions --------------------------------------------------
function math.round(num)
function math.round(num)
if num >= 0 then
return math.floor(num + 0.5)
else
@@ -207,7 +208,7 @@ function filesystem.sortedList(path, sortingMethod, showHiddenFiles)
currentExtensionList, currentExtension = {fileList[i][1]}, fileList[i][2]
end
end
table.sort(currentExtensionList, function(a, b) return a < b end)
for j = 1, #currentExtensionList do
table.insert(sortedFileList, currentExtensionList[j])
@@ -251,7 +252,7 @@ function filesystem.directorySize(path)
size = size + filesystem.size(path .. file)
end
end
return size
end
@@ -260,7 +261,7 @@ end
local function doSerialize(array, prettyLook, indentationSymbol, indentationSymbolAdder, equalsSymbol, currentRecusrionStack, recursionStackLimit)
local text, keyType, valueType, stringValue = {"{"}
table.insert(text, (prettyLook and "\n" or nil))
for key, value in pairs(array) do
keyType, valueType, stringValue = type(key), type(value), tostring(value)
@@ -270,7 +271,7 @@ local function doSerialize(array, prettyLook, indentationSymbol, indentationSymb
table.insert(text, (keyType == "string" and table.concat({"\"", key, "\""}) or key))
table.insert(text, "]")
table.insert(text, equalsSymbol)
if valueType == "number" or valueType == "boolean" or valueType == "nil" then
table.insert(text, stringValue)
elseif valueType == "string" or valueType == "function" then
@@ -285,7 +286,7 @@ local function doSerialize(array, prettyLook, indentationSymbol, indentationSymb
table.insert(text, "...")
end
end
table.insert(text, ",")
table.insert(text, (prettyLook and "\n" or nil))
end
@@ -416,7 +417,7 @@ end
function table.indexOf(t, object)
for i = 1, #t do
if t[i] == object then
if t[i] == object then
return i
end
end
@@ -459,7 +460,7 @@ function string.optimizeForURLRequests(code)
end)
code = string.gsub(code, " ", "+")
end
return code
return code
end
function string.unicodeFind(str, pattern, init, plain)
@@ -470,9 +471,9 @@ function string.unicodeFind(str, pattern, init, plain)
init = #unicode.sub(str, 1, init - 1) + 1
end
end
a, b = string.find(str, pattern, init, plain)
if a then
local ap, bp = str:sub(1, a - 1), str:sub(a,b)
a = unicode.len(ap) + 1
@@ -527,7 +528,7 @@ function string.wrap(strings, limit)
strings[currentString + 1] = right .. " " .. strings[currentString + 1]
else
strings[currentString + 1] = right
end
end
end
break
else
@@ -578,5 +579,3 @@ end
------------------------------------------------------------------------------------------------------------------
return {loaded = true}