Reputation: 13
Okay, so i come down to a dilemma that I can't seem to solve in LUA.
Basically I am trying to insert values into a table, and i am trying to insert it like this:
activeContracts = {
[user_id] = {
[1] = {
source = src
}
}
}
But not in that style but instead of this style:
activeContracts = {}
activeContracts[user_id][1]["source"] = src
But the last example doesn't work. I've googled around and I can't seem to find any documentation that displays my dilemma.
If anyone experienced in LUA can comment on this it would mean alot.
Regards.
Upvotes: 0
Views: 321
Reputation: 28958
activeContracts = {}
creates an empty global table.
activeContracts[user_id][1]["source"] = src
attempts to assign scr
to activeContracts[user_id][1]["source"]
But you may not index activeContracts[user_id][1]
because it does not exist.
You may also not index activeContracts[user_id]
for the same reason.
So you're trying to assign values to a nested tables that do not exist. You have to create that nested structure first. You're basically trying to enter a room in the third floor of a house you never built.
activeContracts = {[user_id] = {{}}}
Upvotes: 1