I’m currently working on a Party system for my game - However, for the life of me I cannot figure out how to swap the placements of two tables.
i.e. Party Slot1 > Storage Box1 Slot1 and vice versa.
I’ve attached a code I’ve been working on – However, even with that for some reason it doesn’t return to required table? However it does print it?
I don’t understand. Been struggling with this for close to 3 days now.
local Core = { ... }
local Server, Script = game, script
local Bloxiimo = {
Party = {
[1] = {{'Flare'}},
[2] = {{'Flambit'}},
},
Storage = {
[1] = {
[1] = {},
[2] = {},
[3] = {}
},
[2] = {
[1] = {},
[2] = {},
[3] = {}
}
}
}
function Filter(t, req)
for a, b in (t) do
if type(b) == 'table' then
if b == req then
return b
else
Filter(b, req)
end
end
end
end
function Core:Move(From, ...)
print(Filter(Bloxiimo, From))
end
Core:Move(Bloxiimo.Party[1])
return Core
Indexing the table you wanna move and then set the MovedTable to the Position of the initial table, here is an example
local SuperCoolTable = {
{
"I am super cool"
},
{
"I lied"
}
}
local InitialTable = SuperCoolTable[1]
local MovedTable = SuperCoolTable[2]
print(SuperCoolTable)
SuperCoolTable[1] = MovedTable
SuperCoolTable[2] = InitialTable
print(SuperCoolTable)
If it it is one-sided communication on the server, yea
However if the changes are happening on the client, nothing really happens on the server
Server will change the table of lets say a modulescript, clients dont really, they will just change the table locally and if then taken from the server, the table is normal like it was.
Uhhh this has to do with some methamethods, specifically __newindex, which fires when a table of something does not equal to the table anymore (basically when something changed). Not sure how Metamethods work on that (i still have to learn them too). You can probably do something with that
Just want to say Thank you! - That throwing of ideas around earlier really helped ; I’ve successfully done it through cloning the Table, editing it and returning it!