Fix duplicate background in formspec prepend (#2524)
authorluk3yx <luk3yx@users.noreply.github.com>
Mon, 14 Oct 2019 20:53:57 +0000 (09:53 +1300)
committersfan5 <sfan5@live.de>
Mon, 14 Oct 2019 20:53:57 +0000 (22:53 +0200)
mods/default/init.lua

index a48738341eb550a8820fd71c1f242fac5793752a..0e2b259f5e2de8146bc14e823cadf2253ef0149b 100644 (file)
@@ -14,11 +14,18 @@ default.get_translator = S
 
 -- GUI related stuff
 minetest.register_on_joinplayer(function(player)
-       player:set_formspec_prepend([[
+       local formspec = [[
                        bgcolor[#080808BB;true]
-                       background[5,5;1,1;gui_formbg.png;true]
-                       background9[5,5;1,1;gui_formbg.png;true;10]
-                       listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF] ]])
+                       listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF] ]]
+
+       local name = player:get_player_name()
+       local info = minetest.get_player_information(name)
+       if info.formspec_version > 1 then
+               formspec = formspec .. "background9[5,5;1,1;gui_formbg.png;true;10]"
+       else
+               formspec = formspec .. "background[5,5;1,1;gui_formbg.png;true]"
+       end
+       player:set_formspec_prepend(formspec)
 end)
 
 function default.get_hotbar_bg(x,y)