RhenaudTheLukark / CreateYourFrisk

Rhenaud The Lukark's Unitale fork
GNU General Public License v3.0
132 stars 56 forks source link

Custom States #92

Closed elytrafae closed 3 years ago

elytrafae commented 3 years ago

In this PR I suggest a change being made to how states work.

Until now, states were just values in an enum, which on runtime is not really changeable . . . However, I rewrote parts of the engine to make states into a List of strings instead, so that the addition of actual states can be done inside a mod without workarounds.

These states can be added using the lua function CreateState, which only takes the name of the state you want to create. After creation, one can simply just go to their custom state using the State function. These custom states are all like the NONE state internally, in the sense that they have no default behavior and the mod has to things with it using the events EnteringState and Update.

States can be theoretically be added from any script and with any string as a name, as long as there is no other state with the same name. However, as a best practice, it is advised to add the states in EncounterStarting and to keep the names uppercase with no spaces between words.

I hope this addition will be of use in the future. Thank you for reading!

RhenaudTheLukark commented 3 years ago

Tried it myself and it seems good now! Merge incoming!