adapap / OWScript

Python-like scripting language which transpiles into Overwatch Workshop script rulesets.
MIT License
37 stars 2 forks source link

Add support for static class methods #41

Open adapap opened 4 years ago

adapap commented 4 years ago

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)
netux commented 4 years ago

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.

adapap commented 4 years ago

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.