{"id":27946800,"url":"https://github.com/dmccuskey/lua-states-mixin","last_synced_at":"2025-05-07T13:58:00.227Z","repository":{"id":25773207,"uuid":"29211507","full_name":"dmccuskey/lua-states-mixin","owner":"dmccuskey","description":"Add State Machine capability to your Lua objects","archived":false,"fork":false,"pushed_at":"2015-03-05T07:08:54.000Z","size":228,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-07T13:57:55.479Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dmccuskey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-13T21:14:21.000Z","updated_at":"2020-11-08T15:28:16.000Z","dependencies_parsed_at":"2022-07-27T05:32:13.659Z","dependency_job_id":null,"html_url":"https://github.com/dmccuskey/lua-states-mixin","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmccuskey%2Flua-states-mixin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmccuskey%2Flua-states-mixin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmccuskey%2Flua-states-mixin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmccuskey%2Flua-states-mixin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dmccuskey","download_url":"https://codeload.github.com/dmccuskey/lua-states-mixin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252892523,"owners_count":21820647,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-07T13:57:59.391Z","updated_at":"2025-05-07T13:58:00.207Z","avatar_url":"https://github.com/dmccuskey.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"## lua-states-mixin ##\n\nAdd State Machine capability to your Lua objects\n\nThis module can add State Machine capability to any of your objects. It can be used either as a mixin class or by \"monkey-patching\" your object. It was designed to work with [lua-objects](https://github.com/dmccuskey/lua-objects) and has also been integrated in [dmc-objects](https://github.com/dmccuskey/dmc-objects) as a mixin.\n\n\n### Features ###\n\n* state methods\n\n  getState(), setState(), gotoState()\n  \n  getPreviousState(), gotoPreviousState()\n  \n  pushStateStack(), popStateStack()\n  \n  resetStates(), setDebug()\n\n\n### Examples ###\n\n#### Mixin Class ####\n\nThis module can be used as a mixin project [dmc-objects](https://github.com/dmccuskey/dmc-objects) contains the `ObjectBase` sub-class which shows how to use this module as a mixin with multiple inheritance.\n\nHere it is in a nutshell:\n\n```lua\n-- import the events mixin module (adjust path for your project)\nlocal StatesMixModule = require 'dmc_lua.lua_states_mix'\n\n-- create ref to mixin (optional)\nlocal StatesMix = StatesMixModule.StatesMix\n\n-- do multiple inheritance !\nNetStream = newClass( { ObjectBase, StatesMix } )\n\n-- Then call init method in your OO Framework construction phase\nObjectBase.__init__( self, ... )\nStatesMix.__init__( self, ... )\n\n\n-- When destroying, you can call __undoInit__\nObjectBase.__undoInit__( self )\nStatesMix.__undoInit__( self )\n\n```\n\n\n#### Monkey Patching ####\n\n\n```lua\n--== Import module\n\nlocal StatesMixModule = require 'dmc_lua.lua_states_mix'\n\n\n--== Setup ref to mixin (optional)\nlocal StatesMix = StatesMixModule.StatesMix\n\n\n--== Patch an object ==--\n\n-- create one for yourself (eg, with OOP library)\n\nlocal obj = {}  -- empty or create one from your OOP library\nobj = StatesMix.patch( obj ) -- returns object\n\n\n-- or have patch() create one for you\n\nlocal obj = StatesMix.patch()  -- returns a new object\n\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmccuskey%2Flua-states-mixin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmccuskey%2Flua-states-mixin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmccuskey%2Flua-states-mixin/lists"}