Hello, I’m trying to move the position of an object in a table to a different index in the table
Is there a way that I can move the position of a single object and the table automatically manages the moved index
Here is what it would look like
Hello, I’m trying to move the position of an object in a table to a different index in the table
Is there a way that I can move the position of a single object and the table automatically manages the moved index
Here is what it would look like
function switchTableValue(table, firstKey, secondKey)
local switchVar = table[firstKey]
table[firstKey] = table[secondKey]
table[secondKey] = switchVar
return table
I am not replacing them to each other, I am moving the position of a Single one
Just curious is this for an inventory slot system
What do you mean?
I am not replacing them to each other
is the same thing as “I am not moving them”
I am moving the position of a Single one
Yes, but doing that would leave a duplicate.
This is what I mean
Well I did that.
Do you mean copying?
This is mine
This is yours
Are you joking or did you select the wrong image?
Both are the same.
local index = -- index of the item
local item = table.remove(t, index)
table.insert(t, newIndex, item)
Is this what you mean?
You are a troll bro. I’m reporting you. Use your eyes to observe both images are different.
They’re different. But they resolve to the same thing. How are you not banned from the DevForum already? I saw you spamming a bunch of obvious/non-sense topics a while ago.
Your incessant disruption is, well, incessant. @msix29 has provided the correct solution. Your antics are finally over. People have reasons for doing things specific ways. Just because you are ignorant in coding doesnt mean I have to change my style. I suggest you educate yourself more and stop trying to solve devforum scripting problems when you yourself need help.
local index = -- index of the item
local item = table.remove(t, index)
table.insert(t, newIndex, item)
is the same thing as
function switchTableValue(table, firstKey, secondKey)
local switchVar = table[firstKey]
table[firstKey] = table[secondKey]
table[secondKey] = switchVar
return table
Why did you suddendly start to accuse me of being a troll out of nowhere? And why did your english suddenly get good?
This is ridiculous and I won’t answer to you anymore. Goodbye
This is theirs
This is yours
there is clearly a difference. Theirs is more aesthetically pleasing and also what I asked for
@KrimsonWoIf and @GenericsAccount. Guys, chill out, GenericsAccount didn’t understand and that’s completely fine, yes his replies came off with attitude but a mature and good response would be to completely ignore such things or explain. For Generics, the 2 images are different (look at bottom row) but I will say, the images are actually wrong. You can’t blame Krimson though, it isn’t easy to visualize such thing.
They are not, yours switches the value at the first key with that of the second key while mine moves the item at a key to another key while keeping the item at that other key in the table.
Make my post as a solution for future comers.
I… know? That’s my whole point…
Oh okay! I didn’t know he meant copying the value.
Goodbye
Glad this argument settled. Ba bye.
no, I’m not copying the value, I’m moving a single value to the other value position. I am not swapping them either, I am merely moving a singular one.