Ok, so basically im having this problem where I need to take a value from the same table the variable that needs the value is in? Its hard to explain but heres the code and hopefully a decent explanation.
Character_Info = {
Name = "Zooble",
Character_ID = 3,
AI_Strength = gameFunctions.ai_Levels[Character_Info.Character_ID], -- need to get the character_id variable inside this table
Time_Frame = 2
}
So I want to take the character id from the table and use it for the AI_Strength variable, problem is that whenever I try to do this i get hit with the attempt to index nil with 'Character_ID' error. Ive tried finding a solution online but I just can’t find the right words to describe it. Is this possible?
Character_Info = {
Name = "Zooble",
Character_ID = 3,
AI_Strength = nil, -- need to get the character_id variable inside this table
Time_Frame = 2
}
Character_Info.AI_Strength = gameFunctions.ai_Levels[Character_Info.Character_ID]
or as @DeEchteBelg says do, you can create a variable, since you cant read a table, value when the table itself hasnt been initialised.
local char_id = 3
Character_Info = {
Name = "Zooble",
Character_ID = char_id ,
AI_Strength = char_id, -- need to get the character_id variable inside this table
Time_Frame = 2
}