WurstScript icon indicating copy to clipboard operation
WurstScript copied to clipboard

Module: call constructor via `new thistype()`

Open muzzel opened this issue 11 years ago • 1 comments

Add the possibility to call the constructor of the underlying class of a module using new thistype(). Example:

module MyModule
    static function getNew() returns thistype
        return new thistype()

class MyClass
    use MyModule

init
    MyClass obj = MyClass.getNew()

Please dont ask what i need this for, its complicated :/

muzzel avatar Mar 23 '14 20:03 muzzel

Modules currently do not know which constructors the using class provides. So this feature would require some more features.

You could just add an abstract method to the module for creating a new instance. Then the user of the module has to write two more lines.

Is this for the buff system object generation?

peq avatar Mar 23 '14 21:03 peq