A tiny double-stacked state manging library for Lua/LÖVE
Concept
St8 keeps two Stacks of States:
Code: Select all
Movement `^`
Input State `Isecondary stack`
Menu - Game `I` - Pause Menu Overlay
`--------------primary stack--------------->`
Usage
You can add and remove Stacks (elements on the primary stack) using `pause` and `resume`.
You can add and remove States (elements on the secondary stack) using `push` and `pop`.
All methods accept a variable number of arguments, these arguments will be passed on both to the last State/Stack and the new ones.
`init` and `pause` accept lists or single States as arguments.
Events
St8 covers all of LÖVE's callbacks (as of 0.9.2). Event callback methods receive one additional parameter (as the first one).
This is the return value of the State above the one receiving the event currently; For the topmost State it will always be `nil`.
The return value of the last State of the current Stack will be returned. This happens regardless of whether the LÖVE callback expects a return value and can be used to pass messages between States of a Stack.
View & Star on Github: https://github.com/S0lll0s/st8.lua
tbh I didn't even check if there already is a library with this concept (I'm on a bus and the network is really slow); but I did look for the name and it doesn't seem to be taken.
Feedback ofc appreciated!