{"id":17925791,"url":"https://github.com/appgurueu/fslib","last_synced_at":"2026-06-28T05:31:55.680Z","repository":{"id":91645199,"uuid":"503766643","full_name":"appgurueu/fslib","owner":"appgurueu","description":"Minetest mod: Simple formspec library","archived":false,"fork":false,"pushed_at":"2022-11-12T18:29:40.000Z","size":6,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-15T13:41:07.442Z","etag":null,"topics":["forms","formspec","library","minetest","mod"],"latest_commit_sha":null,"homepage":"","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/appgurueu.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,"zenodo":null}},"created_at":"2022-06-15T12:59:51.000Z","updated_at":"2024-07-03T18:32:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"0756a58c-fdda-433c-8963-a0d50dcb02a4","html_url":"https://github.com/appgurueu/fslib","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/appgurueu/fslib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appgurueu%2Ffslib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appgurueu%2Ffslib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appgurueu%2Ffslib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appgurueu%2Ffslib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/appgurueu","download_url":"https://codeload.github.com/appgurueu/fslib/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appgurueu%2Ffslib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34878963,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-28T02:00:05.809Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["forms","formspec","library","minetest","mod"],"created_at":"2024-10-28T20:57:59.259Z","updated_at":"2026-06-28T05:31:55.675Z","avatar_url":"https://github.com/appgurueu.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Formspec Library (`fslib`)\n\nA tiny Minetest library mod to facilitate managing formspecs.\n\nWritten by Lars Müller alias [appgurueu](https://github.com/appgurueu) and licensed under the terms of the MIT license.\n\nLinks:\n\n* [GitHub](https://github.com/appgurueu/fslib)\n* [ContentDB](https://content.minetest.net/packages/LMD/fslib/)\n* [Minetest Forums](https://forum.minetest.net/viewtopic.php?f=9\u0026t=28261)\n\n## API\n\n### `fslib.build_formspec(formspec_table)`\n\nBuilds a formspec string out of a table of S-expressions; purely a string building helper\nentirely unaware of formspec semantics: Everything must properly use the table formats no matter the context.\n\nSubtables of formspec tables take the form `{\"element_name\", ...}`, where `...` may consist of:\n\n* Strings to be escaped;\n* Numbers to be formatted using `%d` (integers) or `%f` (floats);\n* Booleans to be formatted as `true` or `false`;\n* A subtable:\n\t* An options table `{[option] = value}`\n\t* A sublist to which the same formatting rules apply but which will use `,` instead of `;` as delimiter (e.g. coordinates);\n\t* A hypertext table created by through the use of `fslib.hypertext_root{fslib.hypertext_tags.tag{attr = value, child_1, child_2, \"text\", ...}}`\n\t\t* **Tip:** Localize `local tags = fslib.hypertext_tags`\n\n### `formspec_name = fslib.show_formspec(player, formspec, handler)`\n\n* `player`: PlayerRef (ObjectRef)\n* `formspec`: Formspec in string or table format (see `fslib.build_formspec`)\n* `handler`: `function(fields) return next_formspec` which is called as the form is submitted\n\t* `fields`: Submitted formspec fields as provided by the engine\n\t* `next_formspec`: If returned, the formspec will be reshown by sending the `next_formspec`; `player` \u0026 `handler` stay the same\n\t* **Tip:** Use upvalues of `handler` - including the `player` - as context!\n* Returns an ID `formspec_name` which can be used to reshow the formspec\n\t* **Tip:** If you don't need to reshow the formspec with the same name or can reshow it by returning a new formspec inside the handler you should not use this.\n\n### `fslib.reshow_formspec(player, formspec_name, formspec)`\n\nReshows (\"updates\") the formspec reusing the name. `formspec` may be a `formspec_table`.\n\n### `fslib.close_formspec(player)`\n\nCloses whichever formspec was last shown to `player` using `fslib`.\n\n**Tip:** If possible use `exit` elements in the formspec instead for a better user experience and to [work around a bug](https://github.com/minetest/minetest/issues/11907).\n\n### Example\n\n```lua\nlocal delete_confirmation_fs = fslib.build_formspec{\n\t{\"size\", {6, 1, false}},\n\t{\"real_coordinates\", true},\n\t{\"label\", {0.25, 0.5}; \"Irreversably delete paintable?\"},\n\t{\"image_button_exit\", {4.75, 0.25}; {0.5, 0.5}; \"epidermis_check.png\"; \"confirm\"; \"\"},\n\t{\"tooltip\", \"confirm\", \"Confirm\"},\n\t{\"image_button_exit\", {5.25, 0.25}; {0.5, 0.5}; \"epidermis_cross.png\"; \"close\"; \"\"},\n\t{\"tooltip\", \"close\", \"Close\"},\n}\nfunction entity_def:_show_delete_formspec(player)\n\tfslib.show_formspec(player, delete_confirmation_fs, function(fields)\n\t\tif fields.confirm then\n\t\t\tself:_delete()\n\t\tend\n\tend)\nend\n```\n\n(from [`epidermis`](https://github.com/appgurueu/epidermis), slightly modified)\n\nNote:\n\n* The (static) formspec is built at load time to improve performance\n* The formspec field handler obtains `self` - in this case an entity - as context\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappgurueu%2Ffslib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappgurueu%2Ffslib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappgurueu%2Ffslib/lists"}