Hello,
Simple lua game with simple class like so:
creature = class({
name = "MONSTER BADDY!",
stats = { power = 10, agility = 10, endurance = 10, filters = {} },
other_things = ...
})
creatureA = creature.new()
creatureB = creature.new()
creatureA.name = "Frank"
creatureB.name = "Zappa"
creatureA.stats.agility = 20
creatureB.stats.power = 12
-- blah blah blah
Non table values are individual to each instance, but table values are
shared among all instances and if I modify a stats.X value in one instance,
all other instances see the same stats table.
Q1: Is my OO implementation flawed? I tried LOOP and the same result occured,
is there a fundamental flaw in my logic?
Q2: How would you have each instance of creature have it's own stats table (and sub tables)?
PS. I cannot flatten my class table as it's a bit more complicated than the example and other parts of the code are simplified with this nested table implementation.
Thanks a bunch.