OWScript icon indicating copy to clipboard operation
OWScript copied to clipboard

Add support for static class methods

Open adapap opened this issue 6 years ago • 2 comments

In the following example, Success can be a static method allowing usage as Sound.Success():

class Sound:
    %PlaySound(type)
        Play Effect
            Visible_To: Event Player
            Type: type
            Color: White
            Position: Event Player
            Radius: 50
    %Success()
        this.PlaySound(Buff Explosion Sound)

adapap avatar Aug 22 '19 00:08 adapap

Will there be a way to differentiate a static method from a class method? Nobody would want, e.g., Sound.play() to behave weirdly because it's not tied to an instance which defines what sound should play.

netux avatar Aug 22 '19 01:08 netux

If you mean semantically, yes. The above is just an example of a scenario where a static method could be used. Adapting Python's grammar of @staticmethod is one option of a noticeable difference. Right now I am leaning toward a static keyword in front of method definitions.

adapap avatar Aug 22 '19 01:08 adapap