How to make a table inside a script by using command bar?

What I want to achieve?

I want to create such a table inside my script by using command bar, because it takes too much time to do it manually.

local waves = {
	[1] = {

	},
	
	[2] = {

	},
	
	[3] = {

	},
	
	[4] = {

	},
	
	[5] = {

	},
	
	[6] = {

	},
	
	[7] = {

	},
	
	[8] = {

	},
	
	[9] = {

	},
	
	[10] = {

	}
}

Like so, but I don’t know how to use it in command bar:

for i = 1, 40 do
	waves[i] = {

	}
end
4 Likes

if the table are empty, why use the command bar buddy, when you can just generate a stack of empty table and then create a a function to furnish them …

I wanna fill it manually with various info but I don’t want to do repeatable actions again and again

1 Like

are the various info random ?.. i mean if you can generate it, do it… otherwise your only solution is CTRL-C/CTRL-V my friend

1 Like

This table is tower defense config. Number are waves. I want to create wave numbers with {} (Like templates) and then fill it manually (not random)

if you don’t have a precise algorithm for your tower defense wave management, I’m afraid you’ll need to do that manually.

1 Like

But now that I think of it, If you used Rojo, you could do it in a windows Terminal to fill the file and automatically sync with roblox Studio

link to Rojo Doc

I work in Roblox studio, not Rojo. Seems like only Ctrl+C, Ctrl+V will help

1 Like

Do you mean automatically writing your table in Lua(u) format? You will have to write something up to generate that for you. Here is an example that allows you to copy-paste a generated template directly from the Roblox Studio output window:

--!strict

local function generate<T>(amount: number, value: T): string
	assert(typeof(value) == "table")
	
	local s: string = `\{`
	
	for index: number = 1, amount do
		s ..= `\n\t[{index}] = \{`
		
		for key: any, value: any in value do
			s ..= `\n\t\t["{key}"] = {if typeof(value) ~= "string" then value else `"{value}"`},`
		end
		
		s ..= "\n\t},"
	end
	
	return s .. "\n}"
end

print("\n", generate(3, {
	Name = "Name",
	Description = "Description",
	Cost = 100
}))

{E1B1F926-00F0-4AD3-8C54-AC1AFDD9ECE3}

Pasting this entire table inside Studio’s script editor should automatically indent for you, so in reality, you don’t need to add indentations. I just did for visualization purposes.

1 Like

I mean, you could try using HTTPService:JSONEncode() and HTTPService:JSONDecode() to change the value of a StringValue. Can’t change a table in a ModuleScript.