{"id":13569400,"url":"https://github.com/SolarLune/routine","last_synced_at":"2025-04-04T05:32:33.391Z","repository":{"id":203653731,"uuid":"710048947","full_name":"SolarLune/routine","owner":"SolarLune","description":"Routine is a Go package for running routines, primarily for game development.","archived":false,"fork":false,"pushed_at":"2024-04-01T16:19:55.000Z","size":25,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-08-03T05:46:11.450Z","etag":null,"topics":["coroutine","ebiten","events","gamedev","golang","routine","scheduling"],"latest_commit_sha":null,"homepage":"","language":"Go","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/SolarLune.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-10-25T23:04:45.000Z","updated_at":"2024-02-15T08:22:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"3b1f01c7-50b1-4150-9f76-9bcb6adb841e","html_url":"https://github.com/SolarLune/routine","commit_stats":null,"previous_names":["solarlune/routine"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SolarLune%2Froutine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SolarLune%2Froutine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SolarLune%2Froutine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SolarLune%2Froutine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SolarLune","download_url":"https://codeload.github.com/SolarLune/routine/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223100122,"owners_count":17087387,"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":["coroutine","ebiten","events","gamedev","golang","routine","scheduling"],"created_at":"2024-08-01T14:00:39.553Z","updated_at":"2024-11-05T01:32:21.625Z","avatar_url":"https://github.com/SolarLune.png","language":"Go","readme":"# routine 🐱 ➡️ 😺💬\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/SolarLune/routine.svg)](https://pkg.go.dev/github.com/SolarLune/routine)\n\nroutine is a package for handling and executing routines, written in Go. The primary reason I made this was for creating cutscenes or running routines for gamedev with Go.\n\nThe general idea is that you create a Routine, and then define a Block. Blocks are \"modes of execution\". They contain groups of Actions, which are objects that are \"units of execution\" - they perform actions or manipulate the execution of a Block. Multiple Blocks can be active at any given time.\n\nBy utilizing Actions and Blocks, you can make up complex behaviors, or sequences of events.\n\n_Note: This package supercedes [gocoro](github.com/solarlune/gocoro), which was my previous attempt at coroutines. If you want something with a more functional design and that is more traditionally coroutine-y, check out stealthrocket's [coroutine](https://github.com/stealthrocket/coroutine)._\n\n## How do I get it?\n\n`go get github.com/solarlune/routine`\n\n## Example\n\n```go\n\nimport \"github.com/solarlune/routine\"\nimport \"github.com/solarlune/routine/actions\"\n\nfunc main() {\n\n    // Create a new Routine.\n    routine := routine.New()\n\n    // And now we begin to define our Blocks, which consist of Actions \n    // that execute in sequence.\n    // A Block has an ID (in this case, a string set to \"first block\"), \n    // but the ID can be anything.\n    routine.DefineBlock(\"first block\", \n    \n        // actions.NewFunction() returns a Function action. \n        // You provide it with a customizeable function.\n        // Depending on the Flow object returned, the Block \n        // will either idle on this Action, or move on to another one.\n        actions.NewFunction(func(block *routine.Block) routine.Flow { \n            fmt.Println(\"Hi!\")\n            return routine.FlowNext // FlowNext means to move to the next Action.\n        }),\n\n        actions.NewWait(time.Second * 2),\n\n        actions.NewFunction(func() routine.Flow { \n            fmt.Println(\"OK, that's it. Goodbye!\")\n            return routine.FlowFinish \n        })\n    \n    )\n\n    // And now we begin running the Routine. By default, the first defined Block\n    // is activated when we run the Routine.\n    routine.Run()\n    \n    for routine.Running() {\n\n        // While the routine runs, we call Routine.Update(). This allows\n        // the routine to execute, but also gives action back to the main\n        // thread when it's idling so we can do other stuff, like take input\n        // or update a game's screen.\n        routine.Update()\n\n    }\n\n    // After Running() is over, we're done with the Routine.\n\n}\n\n```\n\nCheck out the `examples` directory for more in-depth examples.\n\n## Anything else?\n\nNot really, that's it. Peace~","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSolarLune%2Froutine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSolarLune%2Froutine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSolarLune%2Froutine/lists"}