Pressing spacebar in formspecs bug

4aiman
Member
 
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

Pressing spacebar in formspecs bug

by 4aiman » Thu Nov 13, 2014 02:27

If there's a formspec with an button_exit
and a click on that button is supposed to trigger minetest.show_formspec
and one presses spacebar instead of clicking on that very button
then the button gets visually activated and runs on_receive_fields
but minetest.show_formspec fails to show a formspec although no errors or exceptions raise.

AN "EXAMPLED" EXPLANATION:

First of all - some code:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
04:44:26: ACTION[ServerThread]: server was instantly killed.
running on death function
04:44:27: ACTION[ServerThread]: Moving server to static spawnpoint at (0,0,0)
04:44:27: ACTION[ServerThread]: server respawns at (0,0,0)
04:44:47: ACTION[ServerThread]: CHAT: <server> I've pressed a spacebar
04:44:55: ACTION[ServerThread]: server was instantly killed.
running on death function
04:44:57: ACTION[ServerThread]: Moving server to static spawnpoint at (0,0,0)
04:44:57: ACTION[ServerThread]: server respawns at (0,0,0)
{
   g_reinc = "Reincarnation",
   yng = "You're still dead!\
As a ghost you can do something you previously can't.\
Flying is just an example.\
On the other hand now you must do some semi-difficult\
tasks to restore your previous state as it was.\
Actually, you can press the 'Reincarnation' button,\
but are you ready to lose everything you have?\
If you are NOT concerned about it then bravely\
reincarnate. Otherwise you should undergo the ritual\
of rebirth.\
But how are you supposed to warn others about your death?",
   quit = "true"
}
ghosts:unlocked
04:45:29: ACTION[ServerThread]: CHAT: <server> Now I've clicked it with LMB


Now onto explanation:
At 04:44:26 server issues "/kill" chat command and gets killed: ACTION[ServerThread]: server was instantly killed.
Minetest running on death function, which actually looks like this:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_on_dieplayer(function(player)
        if player then
           local pll=player:get_player_name()
           if not deaths_count[pll] then deaths_count[pll] = 0 end
           if isghost[pll] then
              deaths_count[pll] = deaths_count[pll] + 1
           end
           local pos = player:getpos()
           bdeathpos[pll]=pos
           ghosts[pll]=1
        end
end)

*Note the line with ghosts[pll]=1 - we'll return to it later.
A formspec with the button 'Respawn' appears and server presses spacebar in order to not to have to click that button with LMB.
As a result, server respawns: ACTION[ServerThread]: server respawns at (0,0,0).
The function, registered with minetest.register_on_respawnplayer(function(player)) gets executed. I've checked that with various debug messages.
That function is supposed to show a formspec to a player with the announce he's a ghost and bla-bla-bla:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_on_respawnplayer(function(player)
        local pll=player:get_player_name()
        if (ghosts[pll]) then
           if rus == 1 then       -- russian
              localized_announce = announce_rus
              localized_close = close_rus
              localized_reinc = reinc_rus
              localized_welcome = welcome_rus
              localized_remin = remin_rus
           else                      -- english
              localized_announce = announce_not_rus
              localized_close = close_not_rus
              localized_reinc = reinc_not_rus
              localized_welcome =welcome_not_rus
              localized_remin = remin_not_rus
           end
              local formspec = ''
              if (not ghosts4[pll]) then
              formspec = "size[9,9]"..
                    "bgcolor[#bbbbbb;false]"..
                    "listcolors[#777777;#cccccc;#333333;#555555;#dddddd]"..
                    "label[0.25,0.2;" .. localized_welcome .."]"..
                    "textarea[0.25,0.5;9,7.8;yng; ;"..localized_announce.."]"..
                    "checkbox[0.25,7.2;g_rem;" .. localized_remin .. ";false]"..
                    "button_exit[1.5,8.0;2.5,1;g_close;" .. localized_close .."]"..
                    "button_exit[5,8.0;2.5,1;g_reinc;" .. localized_reinc .."]"
              else
              formspec = "size[9,2]"..
                    "bgcolor[#bbbbbb;false]"..
                    "listcolors[#777777;#cccccc;#333333;#555555;#dddddd]"..
                    "label[0.25,0.2;" .. localized_welcome .."]"..
                    "button_exit[1.5,1.0;2.5,1;g_close;" .. localized_close .."]"..
                    "button_exit[5,1;2.5,1;g_reinc;" .. localized_reinc .."]"
              end
              -- if a player is NOT a ghost
              if pll and formspec and not isghost[pll] then
                 minetest.show_formspec(pll,"ghosts:unlocked",formspec)
              end
        else
        end
      return true
end)

Remember that first 'note'?
Here, ghosts[pll] has a flag that a player is dead and ghosts4[pll] a flag that there's no need to repeat the whole announce - player wants only buttons.
Now note the line with the minetest.show_formspec(pll,"ghosts:unlocked",formspec), as the desired formspec won't show up!

BUT!!!
At 04:44:55 server kills himself with the "/kill" command once again: ACTION[ServerThread]: server was instantly killed.
A formspec with the button 'Respawn' appears but this time server CLICKS the button with LMB.
As a result, server respawns and a formspec, that should've been shown, gets shown.

One can repeat it with ANY formspecs which apply to the following conditions:
- have a button, registered as "button_exit";
- call another formspec within on_receive_fields (either that of node or one registered with the minetest.register_on_player_receive_fields() function call).

For example:
The formspec:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
"size[9,8.2]" ..
            "bgcolor[#bbbbbb;false]"..
            "listcolors[#777777;#cccccc;#333333;#555555;#dddddd]"..

            "image_button[9.0,-0.3;0.80,1.7;b_bg2.png;just_bg;Z;true;false]"..
            "image_button[9.2,-0.2;0.5,0.5;b_bg.png;sort_horz;=;true;true]"..
            "image_button[9.2,0.3;0.5,0.5;b_bg.png;sort_vert;||;true;true]"..
            "image_button[9.2,0.8;0.5,0.5;b_bg.png;sort_norm;Z;true;true]"..
            "label[1.2,1;".. txt .."]"..
            "label[1.2,1.5;".. txt2 .."]"..
            "label[1.2,2;".. txt3 .."]"..
            "list[context;gb_place;6,1;1,1;]"..
            "label[7,1; +".. meta:get_string("stored") .."]"..
            "button[5,2;3,1;g_chk;"..txt5.."]"..
            "button_exit[5,3;3,1;g_rei;".. txt4 .."]"..
            "list[current_player;helm;0,0;1,1;]"..
            "list[current_player;torso;0,1;1,1;]"..
            "list[current_player;pants;0,2;1,1;]"..
            "list[current_player;boots;0,3;1,1;]"..

            "list[current_player;main;0,4.2;9,3;9]"..
            "list[current_player;main;0,7.4;9,1;]"


The on_receive_fields function extracts:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
    on_receive_fields = function(pos, formname, fields, sender)
       local meta = minetest.get_meta(pos)
       if fields.g_chk then
        ..................................... -  skipped
       end
       if fields.g_rei then
          local player=sender
          if player and player:is_player() then
               local pll = player:get_player_name()
               if not isghost[pll] then
                  minetest.show_formspec(pll, pll..'_is_not_a_ghost', 'size[5,1]bgcolor[#bbbbbb;false]label[1.3,0;You\'re not a ghost!]button_exit[1.5,0.5;2,1;g_proceed;Proceed]')
                  return
               end
        ..................................... -  skipped


Again, pressing spacebar in the first formspec will guarantee with the precision of 99% that minetest.show_formspec() won't show anything
 

4aiman
Member
 
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

Re: Pressing spacebar in formspecs bug

by 4aiman » Sat Nov 22, 2014 11:44

So... am I the only one who can reproduce this?
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

Re: Pressing spacebar in formspecs bug

by Krock » Sat Nov 22, 2014 12:01

Would
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.show_formspec(pll, "mymod:"..pll.."_is_not_a_ghost",
work?
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
jogag
Member
 
Posts: 106
Joined: Wed Aug 12, 2015 18:32
GitHub: jogag
IRC: jogag
In-game: jogag

Re: Pressing spacebar in formspecs bug

by jogag » Sun Aug 16, 2015 13:27

Here's a simpler example:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
-- By jogag

minetest.register_on_dieplayer(function(player)
 pn = player:get_player_name()
 dt = pn .. " died at " .. minetest.pos_to_string(player:getpos())
 minetest.chat_send_all(dt) -- only for debug
 minetest.show_formspec(pn, "mymod:dummy", "size[5,2]label[0,0;" .. dt .. "]button_exit[0,1;5,1;close;Close]")
end)


If you die and you press spacebar the formspec WON'T SHOW.
If you click respawn, you can see the formspec.
 

4aiman
Member
 
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

Re: Pressing spacebar in formspecs bug

by 4aiman » Mon Aug 17, 2015 06:08

I've found it to be dependent on WHEN formspec should be shown.
If there's some formspec that is already going to be shown, then you'll get nothing pressing spacebar.
I've removed death screen from Magichet (not by a setting, but permanently) and now even spacebar works perfect.

I guess, I don't really care about this bug now.
Anyway, it's a good thing there's someone who DO care about such small issues.
It's even better that the one who DO care was able to reproduce the bug in question.

Maybe it'll be fixed in a year or so...

I'm not going to accuse anyone, but I doubt the issues I post are getting the needed attention @github.
So...

Jogag, if that won't be to much of a burden to do that, would you please create an issue @guthub?
 

User avatar
jogag
Member
 
Posts: 106
Joined: Wed Aug 12, 2015 18:32
GitHub: jogag
IRC: jogag
In-game: jogag

Re: Pressing spacebar in formspecs bug

by jogag » Thu Aug 20, 2015 16:58

4aiman wrote:Jogag, if that won't be to much of a burden to do that, would you please create an issue @guthub

I posted the issue on github.
Link to the issue
 


Return to Minetest Problems

Who is online

Users browsing this forum: No registered users and 3 guests

cron