You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It looks like modules are not correctly initialized for derived classes where the module is used in the base class.
I have a base class TlsBuildingDefinition that uses a module called UnitDefinitionInitModule and a derived class called CannonTowerDefinition.
In the compiled lua you can see that the TlsBuildingDefinition create function initializes all the module fields, but the CannonTowerDefinition create function does not.
So, when constructing CannonTowerDefinition instance, all the module fields are nil and ultimately break a lot of dependent code.
The text was updated successfully, but these errors were encountered:
Module init should only be for the class that uses it. If it's not inited for you then the issue in your case is not missing module init, but The CannonTower constructor not calling the super constructor and thus the module init correctly.
In your example the important code should be in the CannonTowerDefinition_construct_CannonTowerDefinition function, which you did not include.
I tried to reproduce this with a small example:
module M
protected var mi = 1
interface I
class A
var ai = 2
use M
class B extends A implements I
var bi = 3
class C extends B
var ci = 4
init
doAfter(0.7) ->
let c = new C()
print("b test")
print(c.mi)
print(c.ai)
print(c.bi)
print(c.ci)
But this works fine, the super constructor call is added. @jlfarris91 If you still have this issue please post a complete, reproducible example.
Perhaps the issue in your case is simply trying to access the module's values, before they are inited?
It looks like modules are not correctly initialized for derived classes where the module is used in the base class.
I have a base class TlsBuildingDefinition that uses a module called UnitDefinitionInitModule and a derived class called CannonTowerDefinition.
In the compiled lua you can see that the TlsBuildingDefinition create function initializes all the module fields, but the CannonTowerDefinition create function does not.
So, when constructing CannonTowerDefinition instance, all the module fields are nil and ultimately break a lot of dependent code.
The text was updated successfully, but these errors were encountered: