Subclassing Projectile
Posted: Thu Jul 25, 2013 2:12 am
Subclassing Projectile doesn't seem to work as intended.
If I do the following:
From what I can tell, this is because engine.Projectile:makeProject calls _M.new, which creates an instance of engine.Projectile instead of my mod.class.Projectile.
It seems to me that makeProject and makeHoming should instead call self.new to make it possible to properly subclass Projectile.
Am I understanding this correctly?
As a side question, is there an easy way to test engine modifications of this sort, short of building the entire ToME project from scratch?
If I do the following:
- In Actor.lua, set _M.projectile_class = "mod.class.Projectile"
- Create a Projectile.lua file in the class directory that inherits from engine.Projectile
- Define a makeProjectile method that invoke engine.projectile.makeProjectile and then does a bit of its own processing.
- Define an act method
From what I can tell, this is because engine.Projectile:makeProject calls _M.new, which creates an instance of engine.Projectile instead of my mod.class.Projectile.
It seems to me that makeProject and makeHoming should instead call self.new to make it possible to properly subclass Projectile.
Am I understanding this correctly?
As a side question, is there an easy way to test engine modifications of this sort, short of building the entire ToME project from scratch?