Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Reliable way of fetching a tables full path.. help??

To begin, I am creating a really ugly table that looks like this:

local things = {["1"] = {['1.1'] = {},['1.2'] = {['1.2.1'] = {}}}}

Basically if there was infinite values going up to 1.1.1.1.1.1.1.1.1................ etc...

I would have to use recursion... I don't exactly see how to do it.. On top of that getting its full path like this:

1-->1.2-->1.2.1

seems really impossible. Is there a reliable and efficient method of doing this without memory loss?

What I tried:

new.ImageLabel.MouseButton1Click:Connect(function()
			if t == false then t = true
				new.ImageLabel.Rotation = 0
				local children = things[v]
				if #children > 0 then
					
				end
			end
		end)

I assumed something like this would work but I'd constantly be adding MouseButton1Click up to 100000

2 comments

0

Just thought of an idea, feel free to reply if you can help... I'll tell you guys how it goes.

0

Didn't work T_T

1 answer

✓ Accepted answer

i gotchu.

this adds MAX_KEYS_PER_DEPTH keys at each depth in the table until the table is MAX_TABLE_DEPTH levels deep.

local MAX_KEYS_PER_DEPTH = 2
local MAX_TABLE_DEPTH = 2;

function createTable(currentDepth, previousLevel, previousIndex)
	if currentDepth == MAX_TABLE_DEPTH then 
		return 
	end 
	
	local  numIndecies = 0
	
	for i = 1, MAX_KEYS_PER_DEPTH do
		local index =  currentDepth ~= 0 and previousIndex .. "." .. i or tostring(i) 
		previousLevel[index] = {}
		
		createTable(currentDepth+1, previousLevel[index], index)
	end
end

local myTable = {}
createTable(0, myTable, "1", 1)

2 comments

0

That's not the issue, it is returning the whole section in the list but I managed to figure it out

0

Take the free rep I figured it out >XD

This discussion is preserved as it was. New answers, comments, and votes are closed.