Pressing spacebar submits formspecs?

User avatar
sorcerykid
Member
 
Posts: 219
Joined: Fri Aug 26, 2016 15:36
In-game: Nemo

Pressing spacebar submits formspecs?

by sorcerykid » Wed Jan 04, 2017 18:47

I designed custom formspecs on two of my servers for chests, bookshelves, and mailboxes with global macros to move and remove inventory within these containers. To my knowledge, the implementation was secure and stable -- that is until I was alerted by two trusted players that their inventories were being routinely deleted.

Admittedly I was in disbelief how this could even be possible, that is until I discovered that they were hitting the spacebar within the formspec by accident. So I tested it out for myself. And indeed, the spacebar automatically passes "Del Items" to the on_player_receive_fields( ) callback function without any forewarning to the user.

Image

This feature doesn't appear to be documented, and apparently it cannot be disabled either. Are there any workarounds aside from removing the Del Items button completely?
 

User avatar
sorcerykid
Member
 
Posts: 219
Joined: Fri Aug 26, 2016 15:36
In-game: Nemo

Re: Pressing spacebar submits formspecs?

by sorcerykid » Thu Jan 05, 2017 17:48

After some more trial and error, I discovered that formspec buttons are context sensitive, and the last button declared in the formspec is automatically given a "default" context (until the user clicks another button, which changes the context). So the solution is simply to declare the buttons in a different order. The positions themselves, of course, needn't be altered.

I really think this behavior should be documented somewhere since it can have dramatic implications, as shown above.
 


Return to Minetest Problems

Who is online

Users browsing this forum: No registered users and 42 guests

cron