Tablefy | Object Tree Converter

Tablefy

Tablefy is a simple module that converts an entire object tree into a table.
This module is really simple and I don’t plan on updating it, I don’t even know if people will use it, but I just want to but it out there for y’all. Probably won’t update unless something breaks, I really like one of your ideas, or I want to add something.

Ways to get the Module

Requiring the Module

local Tablefy = require(6802183519)

From an Object
Tablefy.rbxm (975 Bytes)

local Tablefy = require(location_of_Tablefy)
-- for example
local Tablefy = require(workspace.Tablefy)

From the Source

Source
local runService = game:GetService("RunService")
local function treeToTable(obj)
	local success,err = pcall(function()
		local tree = {["Object"] = obj}
	end)
	if success then
		local tree = {["Object"] = obj}
		for i,a in pairs(obj:GetChildren()) do
			success,err = pcall(function()
				tree[a.Name] = {["Object"] = a}
			end)
			if success then
				if #a:GetChildren() > 0 then
					local additionalTree = treeToTable(a)
					tree[a.Name] = {["Object"] = a}
					for i,b in pairs(additionalTree) do
						if typeof(b) ~= "Instance" then
							tree[a.Name][b["Object"].Name] = b
						end
						runService.Heartbeat:Wait()
					end
				end 
			end
			runService.Heartbeat:Wait()
		end
		print("Scanned " .. tostring(obj))
		return tree
	else
		return {}
	end
end
return treeToTable

Usage

Extremely simple:

local Tablefy = require(6802183519)
Tablefy(workspace)

Which in my game would spit out the following:

lots of stuff
 {
   ["Base"] =  {
      ["Object"] = Base
   },
   ["Baseplate"] =  {
      ["Object"] = Baseplate
   },
   ["Camera"] =  {
      ["Object"] = Camera
   },
   ["Horse Lift"] =  {
      ["Base"] =  {
         ["Object"] = Base,
         ["Part"] =  {
            ["Object"] = Part
         },
         ["Union"] =  {
            ["Object"] = Union
         }
      },
      ["Control"] =  {
         ["Object"] = Control
      },
      ["Lever"] =  {
         ["ClickDetector"] =  {
            ["Object"] = ClickDetector
         },
         ["Object"] = Lever
      },
      ["Lever2"] =  {
         ["ClickDetector"] =  {
            ["Object"] = ClickDetector
         },
         ["Object"] = Lever2
      },
      ["Lift"] =  {
         ["Object"] = Lift,
         ["Rope1"] =  {
            ["Object"] = Rope1
         },
         ["Rope2"] =  {
            ["Object"] = Rope2
         },
         ["Union"] =  {
            ["Object"] = Union
         },
         ["UpperAnchor1"] =  {
            ["Object"] = UpperAnchor1
         },
         ["UpperAnchor2"] =  {
            ["Object"] = UpperAnchor2
         }
      },
      ["Object"] = Horse Lift,
      ["RemoteEvent"] =  {
         ["Object"] = RemoteEvent
      }
   },
   ["KronosEvolved - Initalizer"] =  {
      ["Object"] = KronosEvolved - Initalizer,
      ["Settings"] =  {
         ["Object"] = Settings
      },
      ["Startup"] =  {
         ["Object"] = Startup
      }
   },
   ["Model"] =  {
      ["Object"] = Model,
      ["Part"] =  {
         ["Object"] = Part
      }
   },
   ["Object"] = Workspace,
   ["SpawnLocation"] =  {
      ["Decal"] =  {
         ["Object"] = Decal
      },
      ["Object"] = SpawnLocation
   },
   ["Speedboat"] =  {
      ["Main"] =  {
         ["Floating"] =  {
            ["Object"] = Floating
         },
         ["Object"] = Main,
         ["Source"] =  {
            ["Object"] = Source,
            ["VehicleSeat"] =  {
               ["Object"] = VehicleSeat
            },
            ["Welds"] =  {
               ["Meshes/Speed-boat_Cube"] =  {
                  ["Object"] = Meshes/Speed-boat_Cube
               },
               ["Meshes/Speed-boat_Cube.001"] =  {
                  ["Object"] = Meshes/Speed-boat_Cube.001
               },
               ["Meshes/Speed-boat_Cube.002"] =  {
                  ["Object"] = Meshes/Speed-boat_Cube.002
               },
               ["Object"] = Welds,
               ["Part"] =  {
                  ["Object"] = Part
               },
               ["Source"] =  {
                  ["Object"] = Source
               },
               ["SteeringWheel"] =  {
                  ["Object"] = SteeringWheel
               }
            }
         }
      },
      ["Model"] =  {
         ["Meshes/Speed-boat_Cube"] =  {
            ["Object"] = Meshes/Speed-boat_Cube
         },
         ["Meshes/Speed-boat_Cube.001"] =  {
            ["Object"] = Meshes/Speed-boat_Cube.001
         },
         ["Meshes/Speed-boat_Cube.002"] =  {
            ["Object"] = Meshes/Speed-boat_Cube.002
         },
         ["Object"] = Model,
         ["Part"] =  {
            ["Object"] = Part
         }
      },
      ["Object"] = Speedboat,
      ["PassengerSeats"] =  {
         ["Object"] = PassengerSeats
      },
      ["SteeringWheel"] =  {
         ["Object"] = SteeringWheel
      }
   },
   ["Terrain"] =  {
      ["Object"] = Terrain
   }
} 

Updates

Versions
1.1
  • Added support for core objects, if it does come across an unreadable object, it skips over it.

Short Poll:

  • Interesting and useful
  • Interesting but not useful
  • Not interesting but useful
  • Not interesting and not useful

0 voters

3 Likes

Why do you have to create a variable “Object” to each? Why dont just assign the object imidiately

1 Like

Why it contains “Object” in every table

If the objects have children they have to be parented to it.
Example:
KronosEvolved - Initalizer has 2 children, startup and object, so they are then put into a table parented to KronosEvolved - Initalizer.

["KronosEvolved - Initalizer"] =  { -- the table that contains the children
      ["Object"] = KronosEvolved - Initalizer, -- the actual instance of the initializer
      ["Settings"] =  { -- the Settings table that would contain children if it had any
         ["Object"] = Settings -- the actual settings object
      },
      ["Startup"] =  { -- the table that would contain startups children
         ["Object"] = Startup -- the actual object
      }
   },

for visualization
image

Cool. I made my own Virtual Tree for handling and managing aspects for the Gui.
Looks awesome though! :smiley:

1 Like

Do you have a link to this? I would like to check it out.

Also, a virtualizer wouldn’t work in my use case because it is not the user accessing it, it is the code.
It’s not for client side peering, simply converting it into a table.

Updated to Version 1.1

  • Added support for core objects, if it does come across an unreadable object, it will skip over it.

Not out yet; Would love to release it though, Add me on discord and I can show you what I did if you want

1 Like

Updated post for a little poll to see what people think on it.