--lets say i have some strings.
local table1 = {"A","B","C","D"}
--So i have some variables
local A
local B
local C
local D
for Number, letter in pairs(table1) do
--letter = A
--How can i make A = true, because i got A? (automaticly)
--What i don't want is to write everything myself
--so i don't want to write:
if letter == "A" then
A = true
end
end
Does everybody understand what i am after? i just want a way to change a variable automaticly, because i am going to add some more letters to table1 and i don’t want my script to me “unreadeble”
local letters = {
["A"] = false,
["B"] = false,
["C"] = false,
["D"] = false,
}
local function reset_letters()
for k, _ in pairs(letters) do
letters[k] = false
end
end
for Number, letter in pairs(table1) do
--letter = A
--How can i make A = true, because i got A? (automaticly)
--What i don't want is to write everything myself
--so i don't want to write:
reset_letters()
letters[letter] = true
end
You can use the table (dictionary) to access these variable instead of making each one its own individual, which would require tons of if statements.
Note: This reset letters function is optional, as I don’t really understand if you wanted to switch the active letter or toggle them.