{"id":16026965,"url":"https://github.com/maxiy01/tstl-tiny-ecs","last_synced_at":"2025-10-12T17:22:06.765Z","repository":{"id":57381853,"uuid":"429387965","full_name":"maxiy01/tstl-tiny-ecs","owner":"maxiy01","description":"Declarations for tiny-ecs, Entity Component System for Lua that's simple, flexible, and useful.","archived":false,"fork":false,"pushed_at":"2021-11-18T13:32:35.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T11:01:39.118Z","etag":null,"topics":["ecs","lua","tstl","typescript","typescript-to-lua"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maxiy01.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-18T10:33:36.000Z","updated_at":"2021-12-01T09:46:14.000Z","dependencies_parsed_at":"2022-09-13T11:20:52.529Z","dependency_job_id":null,"html_url":"https://github.com/maxiy01/tstl-tiny-ecs","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/maxiy01%2Ftstl-tiny-ecs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxiy01%2Ftstl-tiny-ecs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxiy01%2Ftstl-tiny-ecs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxiy01%2Ftstl-tiny-ecs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxiy01","download_url":"https://codeload.github.com/maxiy01/tstl-tiny-ecs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246802624,"owners_count":20836373,"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":["ecs","lua","tstl","typescript","typescript-to-lua"],"created_at":"2024-10-08T20:04:21.506Z","updated_at":"2025-10-12T17:22:01.714Z","avatar_url":"https://github.com/maxiy01.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# TSTL tiny-ecs\n\nDeclarations for [tiny-ecs](https://github.com/bakpakin/tiny-ecs), Entity Component System for Lua that's simple, flexible, and useful.\n\n\n| Command | Description |\n|-|-|\n| `yarn add -D tstl-tiny-ecs` | Install these declarations |\n| `yarn add bakpakin/tiny-ecs` | Install tiny-ecs |\n\n\nUpon installation these declarations can be linked to a _tsconfig.json_ file.\n\n```json\n{\n    \"compilerOptions\": {\n        \"types\": [\n            \"tstl-tiny-ecs\"\n        ]\n    }\n}\n```\n\nAnd used within any _.ts_ file.\n\n```ts\nimport * as tiny from \"tiny\";\ndeclare let world: tiny.World;\n\nclass Vec2\n{\n    constructor(public x: number = 0, public y: number = 0)\n    {\n    }\n}\n\ninterface HasPositionComponent\n{\n    position: Vec2;\n}\n\ninterface HasVelocityComponent\n{\n    velocity: Vec2;\n}\n\nclass Unit implements HasPositionComponent, HasVelocityComponent\n{\n    position: Vec2;\n    velocity: Vec2;\n    constructor(pos_x: number = 0, pos_y: number = 0, vx: number = 0, vy: number = 0)\n    {\n        this.position = new Vec2(pos_x,pos_y);\n        this.velocity = new Vec2(vx,vy);\n    }\n}\n\ndeclare let unit: Unit;\n\nlove.load = () =\u003e {\n    world = tiny.world();\n    \n    unit = new Unit(0,0,10,5);\n\n    world.addEntity(unit);\n\n    let physicsSystem = tiny.processingSystem();\n    \n    physicsSystem.filter = tiny.requireAll('position','velocity');\n    \n    physicsSystem.process = (e: HasPositionComponent \u0026 HasVelocityComponent, dt: number) =\u003e {\n        e.position.x += e.velocity.x*dt;\n        e.position.y += e.velocity.y*dt;\n    };\n\n    world.addSystem(physicsSystem);\n};\n\nlove.update = (dt: number) =\u003e {\n    world.update(dt);\n    print(\"unit.x =\",unit.position.x,\"; unit.y =\",unit.position.y);\n}\n```\n\nMake sure to append `\";./node_modules/tiny-ecs/?.lua\"` to your `package.path` in a _conf.ts_ file (this is run first) to assist where Lua looks for modules.\n\n```ts\npackage.path += \";./node_modules/tiny-ecs/?.lua\";\n```\n\nAlso you need to add `\"typescript-to-lua/language-extensions\"` to _tsconfig.json_ file.\n```json\n{\n    \"compilerOptions\": {\n        \"types\": [\n            \"typescript-to-lua/language-extensions\"\n        ]\n    }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxiy01%2Ftstl-tiny-ecs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxiy01%2Ftstl-tiny-ecs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxiy01%2Ftstl-tiny-ecs/lists"}