Table Editor Module

Table Editor Module:

  • Introduction:

This module makes it easier to read, edit and merge Tables, or convert a table to a folder or folder to a table, best used with dictionaries.

  • Where to get(Free):

1. Marketplace: https://create.roblox.com/store/asset/17777629551/TableEditor

2. Code: require(17777629551)

  • Uses and example code:

1. Search values in nested dictionaries

example of reading values:

local TED = require(17777629551)
local ExampleTable = {
	["Guy1"] = {
		["Name"] = "Jake",
		["Inventory"] = {
			["Money"] = 132,
			["Apples"] = 2
		}
	},
	["Guy2"] = {
		["Name"] = "John",
		["Inventory"] = {
			["Money"] = 12,
			["Apples"] = 19
		}
	}
}
local JakeMoney = TED.Read(ExampleTable, "Money", {"Guy1"})
print(JakeMoney) -- Prints 132
local JohnApples = TED.Read(ExampleTable, "Apples", {"Guy2"})
print(JohnApples) -- Prints 19
--[[
arguments :
table: the table to be searched in
Key: the key that you wanna search for
Ancestors: only finds key with given ancestors
//Returns a value
]]

2. Edit values in nested dictionaries

example of editing values:

local TED= require(17777629551)
local ExampleTable = {
	["Guy1"] = {
		["Name"] = "Jake",
		["Inventory"] = {
			["Money"] = 132,
			["Apples"] = 2
		}
	},
	["Guy2"] = {
		["Name"] = "John",
		["Inventory"] = {
			["Money"] = 12,
			["Apples"] = 19
		}
	}
}
local JakeMoney = TED.Edit(ExampleTable, "Money", {"Guy1"}, 0)
print(JakeMoney)  --[[ Prints the table with the edited value
JakeMoney = {
	["Guy1"] = {
		["Name"] = "Jake",
		["Inventory"] = {
			["Money"] = 0,
			["Apples"] = 2
		}
	},
	["Guy2"] = {
		["Name"] = "John",
		["Inventory"] = {
			["Money"] = 12,
			["Apples"] = 19
		}
	}
}]]
local JohnApples = TED.Edit(ExampleTable, "Apples", {"Guy2"}, function(Apples) return Apples + 1 end)
print(JohnApples) --[[ Prints the table with the edited value
JohnApples = {
	["Guy1"] = {
		["Name"] = "Jake",
		["Inventory"] = {
			["Money"] = 132,
			["Apples"] = 2
		}
	},
	["Guy2"] = {
		["Name"] = "John",
		["Inventory"] = {
			["Money"] = 12,
			["Apples"] = 20
		}
	}
}]]

--[[
arguments : Same as Read with an additional argument
Edit: can be a value or function with an argument(being the value that gets edited) so you can do things arithmetic functions on it.
//Returns a table
]]

3. Convert table to folder

4. Convert folder to table

example of #3 and #4:

local TED = require(17777629551)
local ExampleTable = {
	["Guy1"] = {
		["Name"] = "Jake",
		["Inventory"] = {
			["Money"] = 132,
			["Apples"] = 2
		}
	},
	["Guy2"] = {
		["Name"] = "John",
		["Inventory"] = {
			["Money"] = 12,
			["Apples"] = 19
		}
	}
}
local ExampleFolder = TED.TableToFolder(ExampleTable, "ExampleFolder1")
ExampleFolder.Parent = script -- parents the folder to the script
local ExampleFolderToTable = TED.FolderToTable(ExampleFolder)
print(ExampleFolderToTable) --[[returns the converted folder
ExampleFolderToTable = {
	["Guy1"] = {
		["Name"] = "Jake",
		["Inventory"] = {
			["Money"] = 132,
			["Apples"] = 2
		}
	},
	["Guy2"] = {
		["Name"] = "John",
		["Inventory"] = {
			["Money"] = 12,
			["Apples"] = 19
		}
	}
}
]]
--[[
- TableToFolder arguments:
Table: the table to convert
Name: the name of the table/folder
//Returns a folder

- FolderToTable arguments:
Folder: the folder to convert
//Returns a table
]]

5. Merge tables

local TED = require(17777629551)
local ExampleTable1 = {
	["Guy1"] = {
		["Name"] = "Jake",
		["Inventory"] = {
			["Money"] = 132,
			["Apples"] = 2
		}
	}
}
local ExampleTable2 = {
	["Guy1"] = {
		["Name"] = "Jake",
		["Inventory"] = {
			["Apples"] = 0,
			["Bananas"] = 4
		}
	},
	["Guy2"] = {
		["Name"] = "John",
		["Inventory"] = {
			["Money"] = 12,
			["Apples"] = 19
		}
	}
}
local MergedTable = TED.MergeTable(ExampleTable1, ExampleTable2)
print(MergedTable) --[[Prints The merged table
MergedTable = ["Guy1"] = {
		["Name"] = "Jake",
		["Inventory"] = {
			["Money"] = 132,
			["Apples"] = 2,
			["Bananas"] = 4
		}
	},
	["Guy2"] = {
		["Name"] = "John",
		["Inventory"] = {
			["Money"] = 12,
			["Apples"] = 19
		}
	}
]]
--[[
arguments:
Table: The base table to add values to
TemplateTable: The table to get values from
//Returns a Table
Note: any values already in Table won't get affected
]]
  • Leave any criticism or improvements for the module, and I might add it and credit you.

4 Likes