Page 1 of 1

trigger on formspec close

Posted: Wed Aug 29, 2018 10:21
by zeuner
Is it possible to have some function called when a particular formspec is closed?

Obviously, I can call a function before calling minetest:close_formspec, but this would not catch all cases of the formspec closing (for example, the player pressing Escape).

Re: trigger on formspec close

Posted: Wed Aug 29, 2018 10:39
by rubenwardy
The formspec will be submitted with a quit field set to "true" when ESC or a button exit is pressed

Re: trigger on formspec close

Posted: Wed Aug 29, 2018 15:53
by sorcerykid
The ActiveFormspecs mod provides notification via callback of all conditions in which a formspec is closed (whether it be server shutdown, player killed, player logged off, etc.) through the use of signal events.

[Mod] ActiveFormspecs [formspecs]

Re: trigger on formspec close

Posted: Sun Sep 09, 2018 06:01
by zeuner
rubenwardy wrote:The formspec will be submitted with a quit field set to "true" when ESC or a button exit is pressed
Thanks! It seems that documentation is missing for this feature, though: https://github.com/minetest/minetest/pull/7717

Re: trigger on formspec close

Posted: Sun Sep 09, 2018 06:04
by zeuner
sorcerykid wrote:The ActiveFormspecs mod provides notification via callback of all conditions in which a formspec is closed (whether it be server shutdown, player killed, player logged off, etc.) through the use of signal events.

[Mod] ActiveFormspecs [formspecs]
I was aware of ActiveFormspecs, which seems interesting. I was looking for something more lightweight, though. Basically, I want to be able to detect when player interactions are not limited by the formspec anymore, and if the player logs off, for example, the ActiveFormspecs logic might force me to do another check since the logoff would "limit" player interactions, too.

Re: trigger on formspec close

Posted: Sun Sep 09, 2018 20:31
by sorcerykid
Ah okay. Well in fairness you did originally specify "all cases of the formspec closing" ;D