-
-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
getMonster - getHouseByPlayerGUID - getPlayersByAccountNumber - getPlayersByIPAddress - setDescription - setText - setUniqueId - isPromoted - is(isDruid, isKnight, isPaladin, isMage, isSorcerer) depositMoney - transferMoneyTo - withdrawMoney - getTile - string.split - string.trim - string.starts - string.titleCase - isHouse - isPz - tables Fix enchanting system
- Loading branch information
Showing
12 changed files
with
299 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
string.split = function(str, sep) | ||
local res = {} | ||
for v in str:gmatch("([^" .. sep .. "]+)") do | ||
res[#res + 1] = v | ||
end | ||
return res | ||
end | ||
|
||
string.trim = function(str) | ||
return str:match'^()%s*$' and '' or str:match'^%s*(.*%S)' | ||
end | ||
|
||
string.starts = function(str, substr) | ||
return string.sub(str, 1, #substr) == substr | ||
end | ||
|
||
string.titleCase = function(str) | ||
return str:gsub("(%a)([%w_']*)", function(first, rest) return first:upper() .. rest:lower() end) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
table.append = table.insert | ||
table.empty = function (t) | ||
return next(t) == nil | ||
end | ||
|
||
table.find = function (table, value) | ||
for i, v in pairs(table) do | ||
if(v == value) then | ||
return i | ||
end | ||
end | ||
|
||
return nil | ||
end | ||
|
||
table.contains = function (txt, str) | ||
for i, v in pairs(str) do | ||
if(txt:find(v) and not txt:find('(%w+)' .. v) and not txt:find(v .. '(%w+)')) then | ||
return true | ||
end | ||
end | ||
|
||
return false | ||
end | ||
table.isStrIn = table.contains | ||
|
||
table.count = function (table, item) | ||
local count = 0 | ||
for i, n in pairs(table) do | ||
if(item == n) then | ||
count = count + 1 | ||
end | ||
end | ||
|
||
return count | ||
end | ||
table.countElements = table.count | ||
|
||
table.getCombinations = function (table, num) | ||
local a, number, select, newlist = {}, #table, num, {} | ||
for i = 1, select do | ||
a[#a + 1] = i | ||
end | ||
|
||
local newthing = {} | ||
while(true) do | ||
local newrow = {} | ||
for i = 1, select do | ||
newrow[#newrow + 1] = table[a[i]] | ||
end | ||
|
||
newlist[#newlist + 1] = newrow | ||
i = select | ||
while(a[i] == (number - select + i)) do | ||
i = i - 1 | ||
end | ||
|
||
if(i < 1) then | ||
break | ||
end | ||
|
||
a[i] = a[i] + 1 | ||
for j = i, select do | ||
a[j] = a[i] + j - i | ||
end | ||
end | ||
|
||
return newlist | ||
end | ||
|
||
function table.serialize(x, recur) | ||
local t = type(x) | ||
recur = recur or {} | ||
|
||
if(t == nil) then | ||
return "nil" | ||
elseif(t == "string") then | ||
return string.format("%q", x) | ||
elseif(t == "number") then | ||
return tostring(x) | ||
elseif(t == "boolean") then | ||
return t and "true" or "false" | ||
elseif(getmetatable(x)) then | ||
error("Can not serialize a table that has a metatable associated with it.") | ||
elseif(t == "table") then | ||
if(table.find(recur, x)) then | ||
error("Can not serialize recursive tables.") | ||
end | ||
table.append(recur, x) | ||
|
||
local s = "{" | ||
for k, v in pairs(x) do | ||
s = s .. "[" .. table.serialize(k, recur) .. "]" | ||
s = s .. " = " .. table.serialize(v, recur) .. "," | ||
end | ||
s = s .. "}" | ||
return s | ||
else | ||
error("Can not serialize value of type '" .. t .. "'.") | ||
end | ||
end | ||
|
||
function table.unserialize(str) | ||
return loadstring("return " .. str)() | ||
end |
Oops, something went wrong.