generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: How do I script a Tree?

Previous Thread :: Next Thread 
phoenix53124 is not online. phoenix53124
Joined: 25 Feb 2009
Total Posts: 4889
20 Jan 2016 04:42 PM
Now I know what you're thinking: /Christmas/ tree, right? No, I mean a tree like the explorer window kinda tree. If you don't know what I'm talking about, and you're on windows, type "tree" into the command prompt and that's what I'm talking about.

Thus far, I have this, but sometimes the Y axes are a little glitchy (not a big deal yet), and when I expand an object's children, it'll show up random places, under different objects, or not at all, on occasion. Any advice or help would be appreciated. Here's the whole thing:

p=script.Parent
script.Parent=game.ServerScriptService
p:ClearAllChildren()
script.Parent=p
Label = Instance.new("TextLabel")
Label.Size = UDim2.new(0,100,0,10)
Label.BackgroundTransparency = 1
Label.TextColor3 = Color3.new(1,1,1)
Label.Font = Enum.Font.Arial
Label.TextScaled = true
Label.TextXAlignment = "Left"
Label.ZIndex = 10
Button = Instance.new("TextButton",Label)
Button.Name = "Toggle"
Button.Size = UDim2.new(0,20,1,0)
Button.Position = UDim2.new(0,-20,0,0)
Button.BackgroundTransparency = 1
Button.TextColor3 = Color3.new(1,1,1)
Button.Font = Enum.Font.ArialBold
Button.TextScaled = true
Button.Text = "+"
Button.ZIndex = 10

index = game.ServerScriptService
indent = 0
line = 1
labels = {}

function Sort()
for i,v in pairs(labels) do
if v~=script then
local n, nline,nindent = v.Name
nindent,nline = tonumber(n:match('^%d+')),tonumber(n:match('%d+$'))
v.Position = UDim2.new(0,15*(nindent+1),0,10*(i-1))
end
end
end
function Override(number)
for i=number,#labels do
local ln = labels[i].Name
local lnl,lni=tonumber(ln:match('^%d+')),tonumber(ln:match('%d+$'))
labels[i].Name = tostring(lnl+1)..":"..tostring(lni+1)
end
end
function Make(obj,lin,tab)
if lin~=line then Override(lin) end
local l1 = Label:Clone()
table.insert(labels,l1)
l1.Name = tab..":"..lin
l1.Parent = p
if not pcall(function()l1.Text = obj.Name end) then
l1.Text = "#UNDEF"
end
l1.Position = UDim2.new(0,15*(tab-1),0,10*(lin-1))

indent,tab=indent+1,tab+1
l1.Toggle.MouseButton1Click:connect(function()
for _,v in pairs(obj:GetChildren()) do
line,lin=line+1,lin+1

local lc = Label:Clone()
table.insert(labels,lc)
lc.Name = tab..":"..lin
lc.Parent = p
if not pcall(function()lc.Text = v.Name end) then
lc.Text = "#UNDEF"
end
lc.Position = UDim2.new(0,15*(tab+1),0,10*(lin-1))
if not pcall(function()local _=#v:GetChildren()==0 end) or #v:GetChildren()==0 then
lc:ClearAllChildren()
else

Make(v,lin+1,tab+1)
Sort()
end
end
end)
end
Make(index,line,indent)
Sort()
Report Abuse
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
20 Jan 2016 04:48 PM
Anyone who knows how to easily do this doesn't want to explain it, look in free models for a explorer window gui and look how they work and use it to fix yours
Report Abuse
phoenix53124 is not online. phoenix53124
Joined: 25 Feb 2009
Total Posts: 4889
20 Jan 2016 08:38 PM
1) That's what I get for posting anything more than 10 lines.
2) If it's so easy...*irony*

Meh.
Report Abuse
phoenix53124 is not online. phoenix53124
Joined: 25 Feb 2009
Total Posts: 4889
20 Jan 2016 08:48 PM
Well, the only applicable FM is so comprehensive that even if I managed to make my way through nearly 2000 lines of code, the chances of me finding the three or four lines that matter are nearly zero. Not to mention the insane function infrastructure that's woven into everything.

That's also what I get for turning to an OG like Anaminus.
Report Abuse
DrHaximus is not online. DrHaximus
Joined: 22 Nov 2011
Total Posts: 8410
20 Jan 2016 08:49 PM
"That's also what I get for turning to an OG like Anaminus."

cringe
Report Abuse
phoenix53124 is not online. phoenix53124
Joined: 25 Feb 2009
Total Posts: 4889
20 Jan 2016 08:51 PM
^ This guy gets it.

Or not, I can't ever tell.
Report Abuse
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
20 Jan 2016 09:02 PM
I see no irony in me not making it for you just because I said it would be easy.
Because something easy doesn't mean it doesn't take a long time.
Heres a really terrible one I made by editing my old output gui so you can use it for an example even though like I said there are plenty in free models for you to look at.

http://www.roblox.com/item.aspx?id=345991281
Report Abuse
phoenix53124 is not online. phoenix53124
Joined: 25 Feb 2009
Total Posts: 4889
20 Jan 2016 09:52 PM
*Attempting clarity level 100%:*
I posted this here to maybe, MAYBE, get some advice on what my problems are. (And this is the part when you think terrible things to yourself because that's just how people are anymore) Since most of the time things can't be solved simply without the whole code, I gave you the whole thing. But instead of offering direct assistance, you redirected me. Ok, sure, that'll work. Then I find what you were talking about, but it turns out to be more convoluted than my own methods, in addition to being over 1900 lines long. I looked, found the "create" and "sort" functions, but alas I couldn't decipher them. Everything in that code was nearly proprietary in that I had no idea what I was reading. It just kept leading me to different functions with minimalistic variables assigned by other functions that were part of various libraries...And I got through about 4 sections like that but still had no idea what was actually going on.
All this code needs is ONE trained eye who might be able to suggest something to fix it. Anything really, in the context of /this/ code. I never asked you to make it. I mean, come on, it's literally RIGHT THERE, I'VE ALREADY DONE IT. It, like most things on this forum, just has problems (surprise? I hope not).
Sure, I'll have a look at /your/ GUI and hope I can actually draw lines between the methodologies that don't turn into a veritable spider web. But don't think I'm asking for something insane; I, like almost everyone here, just need a little help.
Now I'm going to go to bed and try not to feel so insignificant. (This is, again, the part where you start thinking poorly of others)
Report Abuse
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
20 Jan 2016 10:08 PM
Sure, I'll have a look at /your/ GUI

Are you implying I stole it?
Report Abuse
phoenix53124 is not online. phoenix53124
Joined: 25 Feb 2009
Total Posts: 4889
20 Jan 2016 10:11 PM
I'm implying that I've looked at more than just yours
Report Abuse
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
20 Jan 2016 10:12 PM
If you make a model of yours that I can test without having to set up much myself (Because I for obvious reasons don't want to have to recreate your gui myself)
I'll test it and see if I can help.
Report Abuse
checkplate is not online. checkplate
Joined: 05 Jan 2016
Total Posts: 1379
20 Jan 2016 10:13 PM
ok what tf is even happening in this thread?
Report Abuse
phoenix53124 is not online. phoenix53124
Joined: 25 Feb 2009
Total Posts: 4889
20 Jan 2016 10:16 PM
All you need is an empty Frame. I designed it so that I could drop it in the GUI I already had, which was basically just one frame (among other things, but for this aspect it was just a bare frame). The dimensions are like 40x100 or something like that, but it doesn't really matter because I should've used offset with the label generation anyway.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image