I encountered a very strange problem. I defined a class that loads actors, but when I use it in another file, I get the “actor warning”. What is the reason?
Ah, the problem, I believe, is that while your class constructs and stores an Actor–which is likely fine–it also sub-classes Actor, meaning that it is itself an Actor, too. This is technically fine–but when your class constructs itself, and in particular when it constructs its super-class (i.e. Actor), it doesn’t pass in a valid model as Actor expects.
Specifically, your call to “super().__init__(self)” is more or less the same as constructing an Actor like this: myActor = Actor(). Since no valid model is passed in, you get a warning to inform you of that potential issue.
It’s true that no valid model is passed in, but I’d like to give my own interpretation of what I think is going on, if you don’t mind .
Actually, it’s more like writing myActor = Actor(self). When using super() to call a base class method, self is not required as the first argument to be passed into it. But since it is passed into super().__init__ in the given code, it is treated as the models argument of Actor.__init__, and that’s what really causes the warning.
Also, creating an Actor without specifying a model does not seem to lead to a warning or error (probably because models and animations can be loaded afterwards using load_model and load_anims).
Anyway, I hope you’re not annoyed by my meddling in this topic .
Not at all! You clarified the matter, and that’s a welcome thing, for my part.
In any case, I own no claim on this thread! It’s public, open for people to comment on.
Ah, that’s interesting–I didn’t know that “self” was superfluous when using “super”–I don’t usually employ that approach myself, generally preferring “<superclass>.__init__(self …)”. So, yes, as you say, it would seem that the super-constructor was presumably attempting to construct an Actor using the instance-reference as its “model”.