trigger on formspec close

Post Reply
zeuner
Member
Posts: 43
Joined: Fri Dec 01, 2017 20:09
GitHub: zeuner

trigger on formspec close

by zeuner » Post

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).

User avatar
rubenwardy
Moderator
Posts: 6387
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: United Kingdom
Contact:

Re: trigger on formspec close

by rubenwardy » Post

The formspec will be submitted with a quit field set to "true" when ESC or a button exit is pressed

User avatar
sorcerykid
Member
Posts: 1507
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: trigger on formspec close

by sorcerykid » Post

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]

zeuner
Member
Posts: 43
Joined: Fri Dec 01, 2017 20:09
GitHub: zeuner

Re: trigger on formspec close

by zeuner » Post

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

zeuner
Member
Posts: 43
Joined: Fri Dec 01, 2017 20:09
GitHub: zeuner

Re: trigger on formspec close

by zeuner » Post

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.

User avatar
sorcerykid
Member
Posts: 1507
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: trigger on formspec close

by sorcerykid » Post

Ah okay. Well in fairness you did originally specify "all cases of the formspec closing" ;D

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests