Description
I’ve tried to make a simple ability system with works with manager system.
but when i print out the value from 2 different places,each skillname is different.
formation
Manager.lua has a global value that contains a table of each skill_parent object.
skill_parent.lua is a parent of all of skill.
skill_parent has name value and update function and skill_parent.update function which just prints out the name of the object.
I made 3 skill_parent objects with a different name(TEST_SKILL, TEST_SKILL2, TEST_SKILL3) and copied into Manager.lua.
Problem
When I launch the game, firstly Ability.script makes 3 different Skill_parent objects and stores into Manager.lua.
then call update function something like this
--Ability.script
function update(self, dt)
for i,skill_parent in ipairs(Manager.SkillTable) do
print("called from Ability.script :i am "..skill_parent.skill_name .. " and called at number " .. i)
skill_parent.update(dt,i)
end
end
--Skill_parent.lua
function instance.update(dt,bn)
print("called from Skill_parent:i am "..instance.skill_name .. " and called at number " .. bn)
end
but skill_name value is different between Ability.script update and skill_parent update.
DEBUG:SCRIPT: called from Ability.script :i am TEST_SKILL and called at number 1 DEBUG:SCRIPT: called from Ability.script :i am TEST_SKILL2 and called at number 2 DEBUG:SCRIPT: called from Ability.script :i am TEST_SKILL3 and called at number 3 DEBUG:SCRIPT: called from Skill_parent:i am TEST_SKILL3 and called at number 1 DEBUG:SCRIPT: called from Skill_parent:i am TEST_SKILL3 and called at number 2 DEBUG:SCRIPT: called from Skill_parent:i am TEST_SKILL3 and called at number 3
Am I doing wrong? or is this just an another bug?
Version
Defold Editor 2.0 with 64bit windows 10.