You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
So i couldn’t clearly explain this in topic, i need help with detecting different parameters with one function of a table, but this parameter could be on different table levels. So like, here is example
local args = "Currencies:Photons:Current:5"
local tabl = {
Currencies = {
["Photons"] = {
Current = 0,
Base = 1,
Auto = {
Enabled = false,
Percentage = 0
}
}
}
}
function decodeargs()
local args = string.split(args, ":")
local len = rawlen(args)
tabl[args[1]][args[2]][args[3]] = args[4]
print(tabl["Currencies"]["Photons"]["Current"])
end
decodeargs()
Output
5 - Server - Script:21
–so here is top args which contains path to parameter level, in this example changing that exact parameter would look like this and will eventually output 5. But, what if in same function i would have different arg for parameter on different level
local args = "Currencies:Photons:Auto:Percentage:5"
local tabl = {
Currencies = {
["Photons"] = {
Current = 0,
Base = 1,
Auto = {
Enabled = false,
Percentage = 0
}
}
}
}
function decodeargs()
local args = string.split(args, ":")
local len = rawlen(args)
tabl[args[1]][args[2]][args[3]] = args[4]
print(tabl["Currencies"]["Photons"])
end
decodeargs()
Output
▼ {
["Auto"] = "Percentage",
["Base"] = 1,
["Current"] = 0
} - Server - Script:21
so there it won’t work and will just change Auto parameter data to “Percentage”. I couldn’t figure a way to make it build universal path to table data
I tryed using some loop for len of table, but stuck with no more ideas, so i’m asking for help