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
function table_merge(into,from) | |
local stack = {} | |
local node1 = into | |
local node2 = from | |
while (true) do | |
for k,v in pairs(node2) do | |
if (type(v) == "table" and type(node1[k]) == "table") then | |
table.insert(stack,{node1[k],node2[k]}) | |
else | |
node1[k] = v |
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
--[[ | |
author: Alundaio (aka Revolucas) | |
A function that creates a new class-like table suitable for combining table properties. | |
It is very simple, only 20 lines and it is very aesthetically pleasing to define new 'classes' | |
ex 1. Class "new_class" | |
ex 2. Class "new_class" (inherit) | |
ex 3. Class "new_class" (inherit1,inherit2,...) | |
The only requirement is that you need to give _G a metatable where 'this' returns the table | |
being indexed, which in my opinion is useful on it's own as it will return the current table |
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
--[[ | |
Most pure lua print table functions I've seen have a problem with deep recursion and tend to cause a stack overflow when | |
going too deep. This print table function that I've written does not have this problem. It should also be capable of handling | |
really large tables due to the way it handles concatenation. In my personal usage of this function, it outputted 63k lines to | |
file in about a second. | |
The output also keeps lua syntax and the script can easily be modified for simple persistent storage by writing the output to | |
file if modified to allow only number, boolean, string and table data types to be formatted. | |
author: Alundaio (aka Revolucas) |