formspec.lua 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. ---@meta
  2. ---Formspec
  3. -----------
  4. -- Show a formspec to a player.
  5. ---@param playername string Name of player to show formspec.
  6. ---@param formname string Passed to `on_player_receive_fields` callbacks, should follow the `"modname:<whatever>"` naming convention.
  7. ---@param formspec string Formspec to display.
  8. function minetest.show_formspec(playername, formname, formspec) end
  9. -- Close a formspec.
  10. --
  11. -- Calling `show_formspec(playername, formname, "")` is equal to this expression.
  12. --
  13. -- To close a formspec regardless of the formname, call `minetest.close_formspec(playername, "")`.
  14. --
  15. -- **USE THIS ONLY WHEN ABSOLUTELY NECESSARY!**
  16. ---@param playername string Name of player to close formspec
  17. ---@param formname string Has to exactly match the one given in `show_formspec`, or the formspec will not close
  18. function minetest.close_formspec(playername, formname) end
  19. -- Escapes the characters `"["`, `"]"`, `"\"`, `","` and `";"`,
  20. -- which can not be used in formspecs.
  21. ---@param string string
  22. ---@return string
  23. ---@nodiscard
  24. function minetest.formspec_escape(string) end
  25. -- Returns e.g. `{type="CHG", row=1, column=2}`
  26. --
  27. -- `type` is one of:
  28. -- * `"INV"`: no row selected
  29. -- * `"CHG"`: selected
  30. -- * `"DCL"`: double-click
  31. ---@param string string
  32. ---@return {type: '"INV"'|'"CHG"'|'"DCL"', row: integer, column: integer}
  33. ---@nodiscard
  34. function minetest.explode_table_event(string) end
  35. -- Returns e.g. `{type="CHG", index=1}`
  36. --
  37. -- `type` is one of:
  38. -- * `"INV"`: no row selected
  39. -- * `"CHG"`: selected
  40. -- * `"DCL"`: double-click
  41. ---@param string string
  42. ---@return {type: '"INV"'|'"CHG"'|'"DCL"', index: integer}
  43. ---@nodiscard
  44. function minetest.explode_textlist_event(string) end
  45. -- Returns e.g. `{type="CHG", value=500}`
  46. --
  47. -- `type` is one of:
  48. -- * `"INV"`: something failed
  49. -- * `"CHG"`: has been changed
  50. -- * `"VAL"`: not changed
  51. ---@param string string
  52. ---@return {type: '"INV"'|'"CHG"'|'"DCL"', value: integer}
  53. ---@nodiscard
  54. function minetest.explode_scrollbar_event(string) end