Template:Tree: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>JulienDethurens
No edit summary
>Anaminus
replacing with new template
 
(11 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<onlyinclude>
<ul style="list-style: none; margin: 0; padding: 0; font-family: Tahoma; font-size: 8pt"><!--
<ul style="list-style: none; margin: 0; padding: 0; font-family: Tahoma; font-size: 8pt"><!--
-->{{if|{{{t1 |}}}|{{tree/item|{{{t1 |}}}|{{{n1 |{{{t1 }}}}}}|{{{c1 |}}}}}}}<!--
-->{{{1}}}<!--
-->{{if|{{{t2 |}}}|{{tree/item|{{{t2 |}}}|{{{n2 |{{{t2 }}}}}}|{{{c2 |}}}}}}}<!--
--></ul><noinclude>{{documentation}}</noinclude>
-->{{if|{{{t3 |}}}|{{tree/item|{{{t3 |}}}|{{{n3 |{{{t3 }}}}}}|{{{c3 |}}}}}}}<!--
-->{{if|{{{t4 |}}}|{{tree/item|{{{t4 |}}}|{{{n4 |{{{t4 }}}}}}|{{{c4 |}}}}}}}<!--
-->{{if|{{{t5 |}}}|{{tree/item|{{{t5 |}}}|{{{n5 |{{{t5 }}}}}}|{{{c5 |}}}}}}}<!--
-->{{if|{{{t6 |}}}|{{tree/item|{{{t6 |}}}|{{{n6 |{{{t6 }}}}}}|{{{c6 |}}}}}}}<!--
-->{{if|{{{t7 |}}}|{{tree/item|{{{t7 |}}}|{{{n7 |{{{t7 }}}}}}|{{{c7 |}}}}}}}<!--
-->{{if|{{{t8 |}}}|{{tree/item|{{{t8 |}}}|{{{n8 |{{{t8 }}}}}}|{{{c8 |}}}}}}}<!--
-->{{if|{{{t9 |}}}|{{tree/item|{{{t9 |}}}|{{{n9 |{{{t9 }}}}}}|{{{c9 |}}}}}}}<!--
-->{{if|{{{t10|}}}|{{tree/item|{{{t10|}}}|{{{n10|{{{t10}}}}}}|{{{c10|}}}}}}}<!--
-->{{if|{{{t11|}}}|{{tree/item|{{{t11|}}}|{{{n11|{{{t11}}}}}}|{{{c11|}}}}}}}<!--
-->{{if|{{{t12|}}}|{{tree/item|{{{t12|}}}|{{{n12|{{{t12}}}}}}|{{{c12|}}}}}}}<!--
-->{{if|{{{t13|}}}|{{tree/item|{{{t13|}}}|{{{n13|{{{t13}}}}}}|{{{c13|}}}}}}}<!--
-->{{if|{{{t14|}}}|{{tree/item|{{{t14|}}}|{{{n14|{{{t14}}}}}}|{{{c14|}}}}}}}<!--
-->{{if|{{{t15|}}}|{{tree/item|{{{t15|}}}|{{{n15|{{{t15}}}}}}|{{{c15|}}}}}}}<!--
-->{{if|{{{t16|}}}|{{tree/item|{{{t16|}}}|{{{n16|{{{t16}}}}}}|{{{c16|}}}}}}}<!--
-->{{if|{{{t17|}}}|{{tree/item|{{{t17|}}}|{{{n17|{{{t17}}}}}}|{{{c17|}}}}}}}<!--
-->{{if|{{{t18|}}}|{{tree/item|{{{t18|}}}|{{{n18|{{{t18}}}}}}|{{{c18|}}}}}}}<!--
-->{{if|{{{t19|}}}|{{tree/item|{{{t19|}}}|{{{n19|{{{t19}}}}}}|{{{c19|}}}}}}}<!--
-->{{if|{{{t20|}}}|{{tree/item|{{{t20|}}}|{{{n20|{{{t20}}}}}}|{{{c20|}}}}}}}<!--
-->{{if|{{{t21|}}}|{{tree/item|{{{t21|}}}|{{{n21|{{{t21}}}}}}|{{{c21|}}}}}}}<!--
-->{{if|{{{t22|}}}|{{tree/item|{{{t22|}}}|{{{n22|{{{t22}}}}}}|{{{c22|}}}}}}}<!--
-->{{if|{{{t23|}}}|{{tree/item|{{{t23|}}}|{{{n23|{{{t23}}}}}}|{{{c23|}}}}}}}<!--
-->{{if|{{{t24|}}}|{{tree/item|{{{t24|}}}|{{{n24|{{{t24}}}}}}|{{{c24|}}}}}}}<!--
-->{{if|{{{t25|}}}|{{tree/item|{{{t25|}}}|{{{n25|{{{t25}}}}}}|{{{c25|}}}}}}}<!--
-->{{if|{{{t26|}}}|{{tree/item|{{{t26|}}}|{{{n26|{{{t26}}}}}}|{{{c26|}}}}}}}<!--
-->{{if|{{{t27|}}}|{{tree/item|{{{t27|}}}|{{{n27|{{{t27}}}}}}|{{{c27|}}}}}}}<!--
-->{{if|{{{t28|}}}|{{tree/item|{{{t28|}}}|{{{n28|{{{t28}}}}}}|{{{c28|}}}}}}}<!--
-->{{if|{{{t29|}}}|{{tree/item|{{{t29|}}}|{{{n29|{{{t29}}}}}}|{{{c29|}}}}}}}<!--
-->{{if|{{{t30|}}}|{{tree/item|{{{t30|}}}|{{{n30|{{{t30}}}}}}|{{{c30|}}}}}}}<!--
-->{{if|{{{t31|}}}|{{tree/item|{{{t31|}}}|{{{n31|{{{t31}}}}}}|{{{c31|}}}}}}}<!--
-->{{if|{{{t32|}}}|{{tree/item|{{{t32|}}}|{{{n32|{{{t32}}}}}}|{{{c32|}}}}}}}<!--
-->{{if|{{{t33|}}}|{{tree/item|{{{t33|}}}|{{{n33|{{{t33}}}}}}|{{{c33|}}}}}}}<!--
-->{{if|{{{t34|}}}|{{tree/item|{{{t34|}}}|{{{n34|{{{t34}}}}}}|{{{c34|}}}}}}}<!--
-->{{if|{{{t35|}}}|{{tree/item|{{{t35|}}}|{{{n35|{{{t35}}}}}}|{{{c35|}}}}}}}<!--
-->{{if|{{{t36|}}}|{{tree/item|{{{t36|}}}|{{{n36|{{{t36}}}}}}|{{{c36|}}}}}}}<!--
-->{{if|{{{t37|}}}|{{tree/item|{{{t37|}}}|{{{n37|{{{t37}}}}}}|{{{c37|}}}}}}}<!--
-->{{if|{{{t38|}}}|{{tree/item|{{{t38|}}}|{{{n38|{{{t38}}}}}}|{{{c38|}}}}}}}<!--
-->{{if|{{{t39|}}}|{{tree/item|{{{t39|}}}|{{{n39|{{{t39}}}}}}|{{{c39|}}}}}}}<!--
-->{{if|{{{t40|}}}|{{tree/item|{{{t40|}}}|{{{n40|{{{t40}}}}}}|{{{c40|}}}}}}}<!--
-->{{if|{{{t41|}}}|{{tree/item|{{{t41|}}}|{{{n41|{{{t41}}}}}}|{{{c41|}}}}}}}<!--
-->{{if|{{{t42|}}}|{{tree/item|{{{t42|}}}|{{{n42|{{{t42}}}}}}|{{{c42|}}}}}}}<!--
-->{{if|{{{t43|}}}|{{tree/item|{{{t43|}}}|{{{n43|{{{t43}}}}}}|{{{c43|}}}}}}}<!--
-->{{if|{{{t44|}}}|{{tree/item|{{{t44|}}}|{{{n44|{{{t44}}}}}}|{{{c44|}}}}}}}<!--
-->{{if|{{{t45|}}}|{{tree/item|{{{t45|}}}|{{{n45|{{{t45}}}}}}|{{{c45|}}}}}}}<!--
-->{{if|{{{t46|}}}|{{tree/item|{{{t46|}}}|{{{n46|{{{t46}}}}}}|{{{c46|}}}}}}}<!--
-->{{if|{{{t47|}}}|{{tree/item|{{{t47|}}}|{{{n47|{{{t47}}}}}}|{{{c47|}}}}}}}<!--
-->{{if|{{{t48|}}}|{{tree/item|{{{t48|}}}|{{{n48|{{{t48}}}}}}|{{{c48|}}}}}}}<!--
-->{{if|{{{t49|}}}|{{tree/item|{{{t49|}}}|{{{n49|{{{t49}}}}}}|{{{c49|}}}}}}}<!--
-->{{if|{{{t50|}}}|{{tree/item|{{{t50|}}}|{{{n50|{{{t50}}}}}}|{{{c50|}}}}}}}<!--
-->{{if|{{{t51|}}}|{{tree/item|{{{t51|}}}|{{{n51|{{{t51}}}}}}|{{{c51|}}}}}}}<!--
-->{{if|{{{t52|}}}|{{tree/item|{{{t52|}}}|{{{n52|{{{t52}}}}}}|{{{c52|}}}}}}}<!--
-->{{if|{{{t53|}}}|{{tree/item|{{{t53|}}}|{{{n53|{{{t53}}}}}}|{{{c53|}}}}}}}<!--
-->{{if|{{{t54|}}}|{{tree/item|{{{t54|}}}|{{{n54|{{{t54}}}}}}|{{{c54|}}}}}}}<!--
-->{{if|{{{t55|}}}|{{tree/item|{{{t55|}}}|{{{n55|{{{t55}}}}}}|{{{c55|}}}}}}}<!--
-->{{if|{{{t56|}}}|{{tree/item|{{{t56|}}}|{{{n56|{{{t56}}}}}}|{{{c56|}}}}}}}<!--
-->{{if|{{{t57|}}}|{{tree/item|{{{t57|}}}|{{{n57|{{{t57}}}}}}|{{{c57|}}}}}}}<!--
-->{{if|{{{t58|}}}|{{tree/item|{{{t58|}}}|{{{n58|{{{t58}}}}}}|{{{c58|}}}}}}}<!--
-->{{if|{{{t59|}}}|{{tree/item|{{{t59|}}}|{{{n59|{{{t59}}}}}}|{{{c59|}}}}}}}<!--
-->{{if|{{{t60|}}}|{{tree/item|{{{t60|}}}|{{{n60|{{{t60}}}}}}|{{{c60|}}}}}}}<!--
-->{{if|{{{t61|}}}|{{tree/item|{{{t61|}}}|{{{n61|{{{t61}}}}}}|{{{c61|}}}}}}}<!--
-->{{if|{{{t62|}}}|{{tree/item|{{{t62|}}}|{{{n62|{{{t62}}}}}}|{{{c62|}}}}}}}<!--
-->{{if|{{{t63|}}}|{{tree/item|{{{t63|}}}|{{{n63|{{{t63}}}}}}|{{{c63|}}}}}}}<!--
-->{{if|{{{t64|}}}|{{tree/item|{{{t64|}}}|{{{n64|{{{t64}}}}}}|{{{c64|}}}}}}}<!--
-->{{if|{{{t65|}}}|{{tree/item|{{{t65|}}}|{{{n65|{{{t65}}}}}}|{{{c65|}}}}}}}<!--
-->{{if|{{{t66|}}}|{{tree/item|{{{t66|}}}|{{{n66|{{{t66}}}}}}|{{{c66|}}}}}}}<!--
-->{{if|{{{t67|}}}|{{tree/item|{{{t67|}}}|{{{n67|{{{t67}}}}}}|{{{c67|}}}}}}}<!--
-->{{if|{{{t68|}}}|{{tree/item|{{{t68|}}}|{{{n68|{{{t68}}}}}}|{{{c68|}}}}}}}<!--
-->{{if|{{{t69|}}}|{{tree/item|{{{t69|}}}|{{{n69|{{{t69}}}}}}|{{{c69|}}}}}}}<!--
-->{{if|{{{t70|}}}|{{tree/item|{{{t70|}}}|{{{n70|{{{t70}}}}}}|{{{c70|}}}}}}}<!--
-->{{if|{{{t71|}}}|{{tree/item|{{{t71|}}}|{{{n71|{{{t71}}}}}}|{{{c71|}}}}}}}<!--
-->{{if|{{{t72|}}}|{{tree/item|{{{t72|}}}|{{{n72|{{{t72}}}}}}|{{{c72|}}}}}}}<!--
-->{{if|{{{t73|}}}|{{tree/item|{{{t73|}}}|{{{n73|{{{t73}}}}}}|{{{c73|}}}}}}}<!--
-->{{if|{{{t74|}}}|{{tree/item|{{{t74|}}}|{{{n74|{{{t74}}}}}}|{{{c74|}}}}}}}<!--
-->{{if|{{{t75|}}}|{{tree/item|{{{t75|}}}|{{{n75|{{{t75}}}}}}|{{{c75|}}}}}}}<!--
-->{{if|{{{t76|}}}|{{tree/item|{{{t76|}}}|{{{n76|{{{t76}}}}}}|{{{c76|}}}}}}}<!--
-->{{if|{{{t77|}}}|{{tree/item|{{{t77|}}}|{{{n77|{{{t77}}}}}}|{{{c77|}}}}}}}<!--
-->{{if|{{{t78|}}}|{{tree/item|{{{t78|}}}|{{{n78|{{{t78}}}}}}|{{{c78|}}}}}}}<!--
-->{{if|{{{t79|}}}|{{tree/item|{{{t79|}}}|{{{n79|{{{t79}}}}}}|{{{c79|}}}}}}}<!--
-->{{if|{{{t80|}}}|{{tree/item|{{{t80|}}}|{{{n80|{{{t80}}}}}}|{{{c80|}}}}}}}<!--
-->{{if|{{{t81|}}}|{{tree/item|{{{t81|}}}|{{{n81|{{{t81}}}}}}|{{{c81|}}}}}}}<!--
-->{{if|{{{t82|}}}|{{tree/item|{{{t82|}}}|{{{n82|{{{t82}}}}}}|{{{c82|}}}}}}}<!--
-->{{if|{{{t83|}}}|{{tree/item|{{{t83|}}}|{{{n83|{{{t83}}}}}}|{{{c83|}}}}}}}<!--
-->{{if|{{{t84|}}}|{{tree/item|{{{t84|}}}|{{{n84|{{{t84}}}}}}|{{{c84|}}}}}}}<!--
-->{{if|{{{t85|}}}|{{tree/item|{{{t85|}}}|{{{n85|{{{t85}}}}}}|{{{c85|}}}}}}}<!--
-->{{if|{{{t86|}}}|{{tree/item|{{{t86|}}}|{{{n86|{{{t86}}}}}}|{{{c86|}}}}}}}<!--
-->{{if|{{{t87|}}}|{{tree/item|{{{t87|}}}|{{{n87|{{{t87}}}}}}|{{{c87|}}}}}}}<!--
-->{{if|{{{t88|}}}|{{tree/item|{{{t88|}}}|{{{n88|{{{t88}}}}}}|{{{c88|}}}}}}}<!--
-->{{if|{{{t89|}}}|{{tree/item|{{{t89|}}}|{{{n89|{{{t89}}}}}}|{{{c89|}}}}}}}<!--
-->{{if|{{{t90|}}}|{{tree/item|{{{t90|}}}|{{{n90|{{{t90}}}}}}|{{{c90|}}}}}}}<!--
-->{{if|{{{t91|}}}|{{tree/item|{{{t91|}}}|{{{n91|{{{t91}}}}}}|{{{c91|}}}}}}}<!--
-->{{if|{{{t92|}}}|{{tree/item|{{{t92|}}}|{{{n92|{{{t92}}}}}}|{{{c92|}}}}}}}<!--
-->{{if|{{{t93|}}}|{{tree/item|{{{t93|}}}|{{{n93|{{{t93}}}}}}|{{{c93|}}}}}}}<!--
-->{{if|{{{t94|}}}|{{tree/item|{{{t94|}}}|{{{n94|{{{t94}}}}}}|{{{c94|}}}}}}}<!--
-->{{if|{{{t95|}}}|{{tree/item|{{{t95|}}}|{{{n95|{{{t95}}}}}}|{{{c95|}}}}}}}<!--
-->{{if|{{{t96|}}}|{{tree/item|{{{t96|}}}|{{{n96|{{{t96}}}}}}|{{{c96|}}}}}}}<!--
-->{{if|{{{t97|}}}|{{tree/item|{{{t97|}}}|{{{n97|{{{t97}}}}}}|{{{c97|}}}}}}}<!--
-->{{if|{{{t98|}}}|{{tree/item|{{{t98|}}}|{{{n98|{{{t98}}}}}}|{{{c98|}}}}}}}<!--
-->{{if|{{{c10|}}}|{{tree/item|{{{t99|}}}|{{{n99|{{{t99}}}}}}|{{{c99|}}}}}}}
</ul></onlyinclude>
 
== Examples ==
 
{{tree|t1=Workspace|c1={{tree
  |t1=Model|n1=MyModel|c1={{tree
    |t1=Part|n1=MyPart
    |t2=Part
  }}
  |t2=Model|n2=MyOtherModel
  }}
}}
 
{{tree|t1=Player|c1={{tree
  |t1=Humanoid
  |t2=Tool|c2={{tree
    |t1=Part|n1=Handle
  }}
  |t3=Part|n3=Head
  |t4=Part|n4=Left Arm
  |t5=Part|n5=Left Leg
  |t6=Part|n6=Right Arm|c6={{tree
    |t1=JointInstance|n1=Right Grip
  }}
  |t7=Part|n7=Right Leg
  |t8=Part|n8=Torso|c8={{tree
    |t1=JointInstance|n1=Left Hip
    |t2=JointInstance|n2=Left Shoulder
    |t3=JointInstance|n3=Neck
    |t4=JointInstance|n4=Right Hip
    |t5=JointInstance|n5=Right Shoulder
  }}
}}}}

Latest revision as of 19:36, 10 April 2012

    {{{1}}}
[purge] Template documentation
The Tree template is used to display the parent-child hierarchy of an Instance. This can be useful in tutorials for showing what a reader might see in the Explorer panel.

Usage

A tree is started with the {{Tree}} template. The first and only argument should consist of one or more {{Tree/node}} templates.

{{Tree/node}} is where the real magic happens. It has three options:

  1. The first option is the ClassName of the Instance to be displayed.
  2. The second option specifies the Name to display for the Instance. If unspecified, the ClassName will be used.
  3. The third option indicates children of the Instance. If specified, it should consist of more {{Tree/node}} templates. This option has three types of behavior:
    If specified with children, an "expanded node" will be displayed next to the Instance, indicating that it has children, and is displaying them.
    If specified, but left blank, an "unexpanded node" will be displayed instead, indicating that the Instance has children, but is not displaying them.
    If unspecified, then no node will be displayed.

Note that if the third option is specified, the second option must also be specified.

Examples

The following source would display a Player's character model:

{{tree|
	{{tree/node|Model|Player|                <!-- has children -->
		{{tree/node|Part|Head|}}         <!-- has children, but doesn't display them -->
		{{tree/node|Part|Torso|}}
		{{tree/node|Part|Left Arm}}      <!-- does not have children -->
		{{tree/node|Part|Right Arm}}
		{{tree/node|Part|Left Leg}}
		{{tree/node|Part|Right Leg}}
		{{tree/node|Humanoid|Humanoid|}}
	}}
}}

Generation script

A script can be used quickly generate wiki markup for this template from an object hierarchy.


Use Execute Script to run the following script, which generates wiki code from the current selection:

-- 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 = ""
local tree_name = "tree"
local node_name = "tree/node"
 
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}