User talk:Anaminus/tree: Difference between revisions
From Legacy Roblox Wiki
Jump to navigationJump to search
>Anaminus |
>Anaminus |
(No difference)
|
Latest revision as of 07:04, 10 April 2012
Moving?
I was just going to replace a tree made with a list I saw on a page by a tree using the {{tree}} template, and then I remembered about this... It looks fine, and it certainly creates more beautiful source than the current {{tree}} template, so should we move it? --JulienDethurens 02:48, 10 April 2012 (EDT)
- Sure. Here's the script that can generate the source:
-- use Execute Script... -- Outputs tree of selected object, or entire game if nothing is selected -- Outputs to Script in Workspace named "Tree Output" local namespace = "User:Anaminus/" local tree_name = "tree" local node_name = "treenode" local exclude_children = { Stats = true; CoreGui = true; [""] = true; } ---------------------------------------------------------------- ---------------------------------------------------------------- ---------------------------------------------------------------- ---------------------------------------------------------------- local output = "" local tab = 0 local function recurse(object) tab = tab + 1 local has_children = #object:GetChildren() > 0 local expand = not exclude_children[object.ClassName] output = output .. string.rep("\t",tab).."{{"..namespace..node_name.."|"..object.ClassName.."|"..object.Name if has_children then if expand then output = output .. "|\n" for i,v in pairs(object:GetChildren()) do recurse(v) end output = output .. string.rep("\t",tab) else output = output .. "|" end end output = output .. "}}\n" tab = tab - 1 end output = "{{"..namespace..tree_name.."|\n" recurse(Game:GetService("Selection"):Get()[1] or Game) output = output .. "}}" local s = Workspace:FindFirstChild("Tree Output") or Instance.new("Script",Workspace) s.Name = "Tree Output" s.Archivable = false s.Source = output Game:GetService("Selection"):Set{s}
--Anaminus 03:04, 10 April 2012 (EDT)