1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Formspec: Show a player inventory using core.show_formspec (#15963)

'core.show_formspec' now shows and updates the inventory formspec as if
it was opened using the hotkey on client-side.
This commit is contained in:
SmallJoker 2025-06-22 22:06:47 +02:00 committed by GitHub
parent d41de3da79
commit fdc149f316
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 59 additions and 23 deletions

View file

@ -6872,10 +6872,15 @@ Formspec
* `core.show_formspec(playername, formname, formspec)`
* `playername`: name of player to show formspec
* `formname`: name passed to `on_player_receive_fields` callbacks.
It should follow the `"modname:<whatever>"` naming convention.
* `formname` must not be empty, unless you want to reshow
the inventory formspec without updating it for future opens.
* It should follow the `"modname:<whatever>"` naming convention.
* If empty: Shows a custom, temporary inventory formspec.
* An inventory formspec shown this way will also be updated if
`ObjectRef:set_inventory_formspec` is called.
* Use `ObjectRef:set_inventory_formspec` to change the player's
inventory formspec for future opens.
* Supported if server AND client are both of version >= 5.13.0.
* `formspec`: formspec to display
* See also: `core.register_on_player_receive_fields`
* `core.close_formspec(playername, formname)`
* `playername`: name of player to close formspec
* `formname`: has to exactly match the one given in `show_formspec`, or the
@ -8653,9 +8658,12 @@ child will follow movement and rotation of that bone.
* Returns `nil` if no attribute found.
* `get_meta()`: Returns metadata associated with the player (a PlayerMetaRef).
* `set_inventory_formspec(formspec)`
* Redefine player's inventory form
* Should usually be called in `on_joinplayer`
* Redefines the player's inventory formspec.
* Should usually be called at least once in the `on_joinplayer` callback.
* If `formspec` is `""`, the player's inventory is disabled.
* If the inventory formspec is currently open on the client, it is
updated immediately.
* See also: `core.register_on_player_receive_fields`
* `get_inventory_formspec()`: returns a formspec string
* `set_formspec_prepend(formspec)`:
* the formspec string will be added to every formspec shown to the user,