Subtables in Lua
Posted: Sat Aug 09, 2014 3:31 am
well i tried to create multiple sub tables at all in the same level but kept getting this error saying that the very 1st one should have a bracket to close it off even though it already has one.
sorry if the top explanation is a bit confusing. this isnt at all easy for me to explain. all i want is to find a way to make the player change to one of the weapons above. so using sub tables to extend the player table is what i thought would be the best idea. any help would be appreciated.
Code: Select all
player = {
x = 15,
y = 15,
x_velocity = 0,
y_velocity = 0,
speed = 500,
health = 500,
shotgun = {
damage = 450,
}
pistol = {
damage = 50,
}
sword = {
damage = 500,
}
smg = {
damage = 100,
}
assault = {
damage = 200,
}
sniper = {
damage = 550,
}
}