{"id":13525409,"url":"https://github.com/paltze/scenery","last_synced_at":"2025-04-01T04:32:04.221Z","repository":{"id":215193019,"uuid":"487735457","full_name":"paltze/scenery","owner":"paltze","description":"A dead simple Love2D SceneManager","archived":false,"fork":false,"pushed_at":"2025-01-13T15:30:36.000Z","size":37,"stargazers_count":24,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-13T16:35:30.933Z","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/paltze.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-02T06:10:01.000Z","updated_at":"2025-01-13T15:30:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"63d13ca5-b749-44f2-b7d0-10ea5ded9163","html_url":"https://github.com/paltze/scenery","commit_stats":null,"previous_names":["paltze/scenery"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paltze%2Fscenery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paltze%2Fscenery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paltze%2Fscenery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paltze%2Fscenery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paltze","download_url":"https://codeload.github.com/paltze/scenery/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246586087,"owners_count":20801025,"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":"2024-08-01T06:01:18.493Z","updated_at":"2025-04-01T04:32:04.209Z","avatar_url":"https://github.com/paltze.png","language":"Lua","funding_links":[],"categories":["Helpers"],"sub_categories":[],"readme":"# Scenery - A dead simple Love2D Scene/State Manager\n\n![image](https://img.shields.io/static/v1?label=L%C3%B6ve2D\u0026message=11.5\u0026labelColor=e64998\u0026color=28abe3\u0026style=for-the-badge)\n\nScenery is a dead simple Scene/State Manager for Love2D.\n\nScenes (or States) are a very popular organising system for games. Scenery is a simple to use and lightweight implementation of the system for Love2D.\n\n## Installation\n\nJust grab the `scenery.lua` from this repository and `require` it in you `main.lua` file.\n\n## Usage\n\nAfter initialization of Scenery (described in detail below) just call the used callbacks in corresponding Love2D callbacks.\n\nFor example:\n```lua\nlocal SceneryInit = require(\"path.to.scenery\")\nlocal scenery = SceneryInit(...)\n\nfunction love.load()\n    scenery:load()\nend\n\nfunction love.draw()\n    scenery:draw()\nend\n\nfunction love.update(dt)\n    scenery:update(dt)\nend\n```\nAlso, the `scenery` instance has a `hook` method on it, which will do the boilerplate for you. The above example can be shortened as:\n```lua\nlocal SceneryInit = require(\"path.to.scenery\")\nlocal scenery = SceneryInit(...)\nscenery:hook(love)\n```\n\n\u003e Scenery supports all [Love2D 11.5 callbacks](https://love2d.org/wiki/Category:Callbacks).\n\n\u003e The `hook` method optionally accepts a second argument, a table, with the callbacks which will be hooked. eg `{ \"load\", \"draw\", \"update\" }`\n\n### Scenes\n\nScenes are, in Scenery, just tables returned by a file. Each scene must have a separate file for itself and return a table containing all the callback methods. Scene callbacks methods are exactly the same as Love callback methods, except `load`, which has an optional argument containing data transferred by other scenes.\n\nAn Example Scene:\n```lua\nlocal game = {}\n\nfunction game:load()\n    print(\"Scenery is awesome\")\nend\n\nfunction game:draw()\n    love.graphics.print(\"Scenery makes life easier\", 200, 300)\nend\n\nfunction game:update(dt)\n    print(\"You agree, don't you?\")\nend\n\nreturn game\n```\n\n### Loading the Scenes\n\n#### Automatic Loading\nScenery can automatically load your scenes for you. `scenery.lua` returns a function that accepts a default scene as first parameter and path to the folder containing scenes as an optional second parameter. If no path is supplied Scenery will look into `scenes` folder from the folder containing your `main.lua` file for scenes.\n\nExample:\n```lua\nlocal SceneryInit = require(\"path.to.scenery\")\nlocal scenery = SceneryInit(\"scene\", \"path/to/scenes\")\n```\n\n\u003e The filename of the file (without the extension) containing scene will be considered the scene key.\n\n\u003e ⚠️ If your file name has periods (.) before the file extension (eg `game.scene.lua`) then only the string before the first period (ie `game` in the above case) will be considered the scene key.\n\n#### Manual Loading\n\nScenery can also manually load you scenes. The function returned by `scenery.lua` can accept multiple tables, each for one scene.\nYou can have the following properties in the table:\n\nProperty | Description\n---------|------------\n`path`   | The path to the file returning a table structured in the form a scene table.\n`key`    | A unique string identifying the scene.\n`default` (optional)| A boolean value representing the default scene. Must not be `true` on more than one scene. If omitted the first scene in the arguments will be considered default.\n\nExample:\n```lua\nlocal SceneryInit = require(\"path.to.scenery\")\nlocal scenery = SceneryInit(\n    { path = \"path.to.scene1\"; key = \"scene1\"; default = \"true\" },\n    { path = \"path.to.scene2\"; key = \"scene2\"; }\n)\n```\n\n### Changing Scenes\n\nChanging scenes in Scenery is very simple. Scenery creates a `setScene` method on the scene table to change scenes. The function accepts scene key as first parameter and an optional argument which will be passed to the `load` callback of the new scene. It is as simple as:\n\n```lua\nfunction scene1:load()\n    self.setScene(\"scene2\", { score = 52 })\nend\n```\n\nThen you can access the score in menu scene by:\n```lua\nfunction scene2:load(args)\n    print(args.score) -- prints 52\nend\n```\n\n## Contributing\n\nIf you have found a bug or have any suggestion, feel free to open an issue. If you fixed a bug or added a new feature, add a pull request.\n\n## License\n\nThe project is licensed under the MIT License. A copy of the license can be found in the repository by the name of LICENSE.txt\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaltze%2Fscenery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaltze%2Fscenery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaltze%2Fscenery/lists"}