Page 1 of 1

Formspec exit_button submitting twice

PostPosted: Thu Dec 05, 2013 19:42
by stu
For some reason when I click a formspec button_exit the on_player_receive_fields callback is being
called twice, first as an ordinary button and then again including fields["quit"] == "true"

This anomally must have been introduced recently as it has broken a previously working mod of mine
Should I fix my mod to work with this new behavior or would this be considered a formspec bug?

PostPosted: Thu Dec 05, 2013 21:58
by kaeza
stu wrote:For some reason when I click a formspec button_exit the on_player_receive_fields callback is being
called twice, first as an ordinary button and then again including fields["quit"] == "true"

This anomally must have been introduced recently as it has broken a previously working mod of mine
Should I fix my mod to work with this new behavior or would this be considered a formspec bug?

That was intended IIRC. You should check for fields.quit first on your callback, and if it's not set, check other fields.

PostPosted: Thu Dec 05, 2013 22:40
by addi
stu wrote:For some reason when I click a formspec button_exit the on_player_receive_fields callback is being
called twice, first as an ordinary button and then again including fields["quit"] == "true"

This anomally must have been introduced recently as it has broken a previously working mod of mine
Should I fix my mod to work with this new behavior or would this be considered a formspec bug?


it also happens if you hit the ESC key thats a bit ugly

PostPosted: Fri Dec 06, 2013 04:55
by kaeza
addi wrote:it also happens if you hit the ESC key thats a bit ugly

ESC counts as "quit", so it's good that it sends a quit event. That's the whole point of this feature; so mods can check when the formspec is closed.

PostPosted: Fri Dec 06, 2013 14:53
by addi
kaeza wrote:
addi wrote:it also happens if you hit the ESC key thats a bit ugly

ESC counts as "quit", so it's good that it sends a quit event. That's the whole point of this feature; so mods can check when the formspec is closed.

but the most of mod gets broken through this feature

PostPosted: Fri Dec 06, 2013 18:49
by stu
kaeza wrote:That was intended IIRC. You should check for fields.quit first on your callback, and if it's not set, check other fields.


The 'quit' field will indeed be useful but I fail to see why the exit button needs to submit twice.