How would I do this? I need to get the variables with the table, so pretty much I need to see what tables there are and their values.
[1] = {
IconID = 0,
MinRank = 0,
BadgeId = 0, -- Set to the badgeID if you want badges
},
How would I do this? I need to get the variables with the table, so pretty much I need to see what tables there are and their values.
[1] = {
IconID = 0,
MinRank = 0,
BadgeId = 0, -- Set to the badgeID if you want badges
},
Forgot to say, I want it to be a function returning all the info, i.e
return info
{
ico1 = {
iconid = 0,
minrank = 0,
badgeid = 0,
},
ico2 = {
iconid = 0,
minrank = 0,
badgeid = 0,
},
}
What are you trying to get?
What are you trying to do, I don’t qui to understand.
Aight.
I’ll cut to the chase, you need to create a function that iterates over your table and constructs a new table with the desired structure. Should look something like this:
-- ok so over here define your original table
local originalTable = {
[1] = {
IconID = 0,
MinRank = 0,
BadgeId = 0, -- set to the badgeID if you want badges
},
[2] = {
IconID = 1,
MinRank = 1,
BadgeId = 123, -- ur badgeID!1!1!!1
},
-- and then u can add more entries as needed
}
-- this is a function to convert the original table to the desired format
local function convertTable(originalTable)
local result = {} -- this will initialize the result table
-- this will iterate over the original table
for key, value in ipairs(originalTable) do
local newKey = "ico" .. key -- this will construct the new key
result[newKey] = { -- and this will create a new table for each entry
iconid = value.IconID,
minrank = value.MinRank,
badgeid = value.BadgeId,
}
end
return result -- returns the result table lol
end
-- this is to call the function and store the result
local info = convertTable(originalTable)
-- and then return the resulting table
return info
So this, all-in-all, defines your original table and a function convertTable
to transform it into the format you want, and the function iterates over each entry in the original table, constructs a new key (ico1
, ico2
, etc.), and creates a new table with the desired structure. Then, it returns the resulting table.
hope this helped lmk if you have any more questions
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.