Formspec exit_button submitting twice

User avatar
stu
Member
 
Posts: 737
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11

Formspec exit_button submitting twice

by stu » Thu Dec 05, 2013 19:42

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?
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

by kaeza » Thu Dec 05, 2013 21:58

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.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
addi
Member
 
Posts: 605
Joined: Thu Sep 20, 2012 03:16

by addi » Thu Dec 05, 2013 22:40

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
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

by kaeza » Fri Dec 06, 2013 04:55

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.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
addi
Member
 
Posts: 605
Joined: Thu Sep 20, 2012 03:16

by addi » Fri Dec 06, 2013 14:53

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
 

User avatar
stu
Member
 
Posts: 737
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11

by stu » Fri Dec 06, 2013 18:49

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.
Last edited by stu on Fri Dec 06, 2013 18:49, edited 1 time in total.
 


Return to Minetest Problems

Who is online

Users browsing this forum: No registered users and 12 guests