Noah2610 / deathfloor

Work-in-progress Mega Man inspired game.
MIT License
2 stars 0 forks source link

Entity config functions #25

Closed Noah2610 closed 4 years ago

Noah2610 commented 4 years ago

Extend events/actions system with functions, for reusable config. Add field functions with key/value pairs of function names and action configs. Function actions can be called from any action by its function name.

Example config:

events: {
    OnSpawn: Call("GreetPlayer"),
},
functions: {
    "GreetPlayer": Echo("Hello Player!"),
},
Noah2610 commented 4 years ago

Don't have functions be defined in separate field, instead just make functions be events.

Config example:

(
    events: {
        // Function definition is simply an event.
        Function("Greet"): Echo("Hello!"),

        // Call function with `Call` action.
        Interval(1000): Call("Greet"),
    },
)
Noah2610 commented 4 years ago

Example usage with custom entity HealthConsumable and Player: https://github.com/Noah2610/deathfloor/commit/7ab2bba8db1acdb7a368885bdaae7b0d0d36335b