|
|
(One intermediate revision by the same user not shown) |
Line 1: |
Line 1: |
| This script generates a tree based on a certain instance in the game. The tree uses the {{tl|tree}} template.
| | #redirect [[User:JulienDethurens/Scripts/Tree generator]] |
| | |
| To use, change the argument on line 20 from 'Workspace.JulienDethurens' to the object you want to make a tree of. The code resulting will be formatted with tabs and newlines and will be put in a
| |
| script which will be created.
| |
| | |
| This code will not work in a Script or a LocalScript, as it uses the Source property to output the code.
| |
| | |
| <div style="-moz-tab-size:3; -o-tab-size:3; -webkit-tab-size:3; tab-size:3;">
| |
| <code lua n>
| |
| local output = "{{tree"
| |
| | |
| function generate(object, tabs, num)
| |
| if object.ClassName ~= "" then
| |
| output = output .. "\n" .. ("\t"):rep(tabs)
| |
| output = output .. "|t" .. num .. "=" .. object.ClassName
| |
| if object.Name ~= object.ClassName then
| |
| output = output .. "|n" .. num .. "=" .. object.Name
| |
| end
| |
| if #object:GetChildren() ~= 0 then
| |
| output = output .. "|c" .. num .. "={{tree"
| |
| recurse(object, tabs + 1)
| |
| output = output .. "\n" .. ("\t"):rep(tabs) .. "}}"
| |
| end
| |
| end
| |
| end
| |
| | |
| function recurse(object, tabs)
| |
| for num, child in next, object:GetChildren() do
| |
| generate(child, tabs, num)
| |
| end
| |
| end
| |
| | |
| generate(Workspace.JulienDethurens, 1, 1)
| |
| | |
| output = output .. "\n}}"
| |
| | |
| Instance.new('Script', Workspace).Source = output
| |
| </code>
| |
| </div>
| |
| | |
| Here is the code outputed by it when using my character:
| |
| <div style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
| |
| <pre>
| |
| {{tree
| |
| |t1=Model|n1=JulienDethurens|c1={{tree
| |
| |t1=Part|n1=Head|c1={{tree
| |
| |t1=SpecialMesh|n1=Mesh
| |
| |t2=Sound
| |
| |t3=Sound
| |
| |t4=Sound
| |
| |t5=Sound
| |
| |t6=Sound
| |
| |t7=Sound
| |
| |t8=Decal|n8=face
| |
| }}
| |
| |t2=Part|n2=Torso|c2={{tree
| |
| |t1=Decal|n1=roblox
| |
| |t2=Motor6D|n2=Right Shoulder
| |
| |t3=Motor6D|n3=Left Shoulder
| |
| |t4=Motor6D|n4=Right Hip
| |
| |t5=Motor6D|n5=Left Hip
| |
| |t6=Motor6D|n6=Neck
| |
| }}
| |
| |t3=Part|n3=Left Arm
| |
| |t4=Part|n4=Right Arm
| |
| |t5=Part|n5=Left Leg
| |
| |t6=Part|n6=Right Leg
| |
| |t7=Humanoid|c7={{tree
| |
| |t1=Status
| |
| }}
| |
| |t8=Script|n8=Sound
| |
| |t9=LocalScript|n9=Animate
| |
| |t10=Script|n10=RobloxTeam
| |
| |t11=BodyColors|n11=Body Colors
| |
| |t12=Script|n12=Health
| |
| |t13=Script|n13=HealthScript v3.1
| |
| |t14=ShirtGraphic|n14=Shirt Graphic
| |
| }}
| |
| }}
| |
| </pre>
| |
| </div>
| |
| | |
| And here is the result:
| |
| | |
| {{tree
| |
| |t1=Model|n1=JulienDethurens|c1={{tree
| |
| |t1=Part|n1=Head|c1={{tree
| |
| |t1=SpecialMesh|n1=Mesh
| |
| |t2=Sound
| |
| |t3=Sound
| |
| |t4=Sound
| |
| |t5=Sound
| |
| |t6=Sound
| |
| |t7=Sound
| |
| |t8=Decal|n8=face
| |
| }}
| |
| |t2=Part|n2=Torso|c2={{tree
| |
| |t1=Decal|n1=roblox
| |
| |t2=Motor6D|n2=Right Shoulder
| |
| |t3=Motor6D|n3=Left Shoulder
| |
| |t4=Motor6D|n4=Right Hip
| |
| |t5=Motor6D|n5=Left Hip
| |
| |t6=Motor6D|n6=Neck
| |
| }}
| |
| |t3=Part|n3=Left Arm
| |
| |t4=Part|n4=Right Arm
| |
| |t5=Part|n5=Left Leg
| |
| |t6=Part|n6=Right Leg
| |
| |t7=Humanoid|c7={{tree
| |
| |t1=Status
| |
| }}
| |
| |t8=Script|n8=Sound
| |
| |t9=LocalScript|n9=Animate
| |
| |t10=Script|n10=RobloxTeam
| |
| |t11=BodyColors|n11=Body Colors
| |
| |t12=Script|n12=Health
| |
| |t13=Script|n13=HealthScript v3.1
| |
| |t14=ShirtGraphic|n14=Shirt Graphic
| |
| }}
| |
| }}
| |
| | |
| Amazing, right?
| |