{"id":16266897,"url":"https://github.com/rameshvarun/hump.timer.actions","last_synced_at":"2025-04-08T14:53:48.972Z","repository":{"id":70661750,"uuid":"49753719","full_name":"rameshvarun/hump.timer.actions","owner":"rameshvarun","description":"Composable actions, powered by Hump.Timer.","archived":false,"fork":false,"pushed_at":"2023-04-21T17:42:41.000Z","size":14,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T01:35:47.618Z","etag":null,"topics":["love2d","lua"],"latest_commit_sha":null,"homepage":"https://blog.varunramesh.net/posts/composable-animations/","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/rameshvarun.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":"2016-01-16T01:19:22.000Z","updated_at":"2023-04-21T17:31:02.000Z","dependencies_parsed_at":"2023-02-26T08:15:16.355Z","dependency_job_id":null,"html_url":"https://github.com/rameshvarun/hump.timer.actions","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rameshvarun%2Fhump.timer.actions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rameshvarun%2Fhump.timer.actions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rameshvarun%2Fhump.timer.actions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rameshvarun%2Fhump.timer.actions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rameshvarun","download_url":"https://codeload.github.com/rameshvarun/hump.timer.actions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247866138,"owners_count":21009239,"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":["love2d","lua"],"created_at":"2024-10-10T17:43:18.800Z","updated_at":"2025-04-08T14:53:48.936Z","avatar_url":"https://github.com/rameshvarun.png","language":"Lua","readme":"# hump.timer.actions\n\n[![Lua](https://github.com/rameshvarun/hump.timer.actions/actions/workflows/lua.yml/badge.svg)](https://github.com/rameshvarun/hump.timer.actions/actions/workflows/lua.yml)\n\nComposable actions, powered by [hump.timer](https://hump.readthedocs.org/en/latest/timer.html). Inspired by [LibGDX actions](https://github.com/libgdx/libgdx/wiki/Scene2d#actions). Represents a `monoid`. This approach also lends itself to manipulation by higher order functions (similar to parser combinators).\n\n## Example\n```lua\nlocal Actions = require \"actions\"\nlocal Timer = require \"hump.timer\"\n\nlocal objectA = {val = 0}, objectB = {val = 0}\nlocal action = Actions.Sequence(\n\tActions.Print(\"Started action...\"),\n\tActions.Wait(3),\n\tActions.Print(\"3 seconds passed...\"),\n\tActions.Parallel(\n\t\tActions.Tween(3.0, objectA, {val=10}, 'linear'),\n\t\tActions.Tween(2.0, objectB, {val=10}, 'linear')\n\t)\n)\n\n--[[ Play the action by calling it as a function.\nThe first argument is the Hump.Timer object used to run\nevents, and the second argument is a continuation to\nbe run on the completion of the action. ]]--\naction(Timer, function()\n\tprint(\"Continuation...\")\nend)\n```\n\n## Documentation\n### Action Primitives\nThese functions return actions that, when played, will do something.\n#### `Actions.Empty()`\nAn empty 'identity' action which does nothing.\n#### `Actions.Wait(duration)`\nAn action which waits for the provided amount of seconds.\n#### `Actions.Do(func)`\nAn action which invokes the provided function, then continues.\n#### `Actions.Print(func)`\nAn action which prints to the console.\n#### `Actions.Tween(duration, subject, target, method, ...)`\nTweens an object. See [Timer.tween](https://hump.readthedocs.org/en/latest/timer.html#Timer.tween) for more details.\n\n### Combinators\nCombinators take in actions, compose them, and return new actions that can be further composed.\n#### `Actions.Sequence(...)`\nTakes in a variable number of actions, and returns a new action which plays them all in sequence.\n#### `Actions.Parallel(...)`\nTakes in a variable number of actions, and returns a new action which plays them all in parallel. The continuation is invoked when\n\n### Creating a Custom Action Primitive\nPart of what makes this approach effective is that you can create your own Action primitives. Here are some examples.\n\n```lua\nfunction Actions.PlaySource(source)\n  return function(timer, cont)\n    love.audio.play(source)\n    cont()\n  end\nend\n\nfunction Actions.DestroyEntity(entity)\n  return function(timer, cont)\n    entity:destroy()\n    cont()\n  end\nend\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frameshvarun%2Fhump.timer.actions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frameshvarun%2Fhump.timer.actions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frameshvarun%2Fhump.timer.actions/lists"}