Table storing several unique tables: how would I achieve? [REPOST, read for clarification]

  1. What do you want to achieve?
    I am currently making a ‘Wire Families’ script that I want to contains a main table. This table will hold multiple other tables, the new tables holding parts like ingame wires and all the devices they are linked to.
  2. What is the issue?
    How would I make tables that can be uniquely made (and destroyed) every time I need a new table to hold a new circuit ingame, and then store those tables in a table??

here is a diagram i made to clarify what i mean further incase the explanation is as bad as i think it is

THIS IS A REPOST. my last post was admittedly not explained very well and therefore everyone who read it had 1 go at trying to understand it and then immediately left it for someone else. the most i got was from one guy who referred me to something called OOP and then did the same thing, but I still have no clue where I would look from there so I’m crossing my fingers hoping this is allowed now I have the hindsight and better understanding of explaining it hopefully more clearly.

main[#main+1] = {attributes} for each table
it can work

a tad bit more explanation please…? :skull:

local WireTable = {}

--when adding an new table
WireTable[#WireTable + 1] = {
    ["Wires"] = {},
    ["Components"] = {}
} 

--for adding wire
table.insert(WireTable[index]["Wires"],Wire)

--for adding components
table.insert(WireTable[index]["Components"],Component)
1 Like

this works for one circuit, but is there a way i can replicate this for multiple seperate circuits?

table.insert(WireTable,{ --this creates an new table
    ["Wires"] = {},
    ["Components"] = {}
})
1 Like

thanks! i’ll check on roblox studio if this works right and will put this as the solution if so!

IT IS! thanks so much!!! only took a better programmer & explanation to get the answer apparently

1 Like

@fantastikan13 i know this is no longer really related to the post but you were helpful last time and this isnt really worth making another whole new post over so i’ll try asking here

how would refer to the wire table inside of the table? i cant really explain it but heres what i mean
image
image
for the last two lines, shouldnt atleast one have printed ‘newwirenodegroup’? or am i writing it wrong?

2 Likes

Use “Wires” or “Components” in wire.

but is it not already in the Wires table? or what else do you mean? again im not really good at understanding short sentences

table.insert(WireTable,{ --this creates an new table
    ["Wires"] = {},
    ["Components"] = {}
})

we used strings instead index numbers. Thats why we cant index it with numbers. Instead of numbers use CircuitGroups[1]["Wires"]!

1 Like

ohhhhhhh, that makes more sense! thanks dude!
2 in a row lol

1 Like