Fix bugs introduced by Minetest 5.0
This commit is contained in:
parent
5daefadc7e
commit
947715fbe8
120 changed files with 3874 additions and 1011 deletions
13
mods/mtg/sfinv/README.txt
Normal file
13
mods/mtg/sfinv/README.txt
Normal file
|
@ -0,0 +1,13 @@
|
|||
Minetest Game mod: sfinv
|
||||
========================
|
||||
See license.txt for license information.
|
||||
|
||||
Simple Fast Inventory.
|
||||
A cleaner, simpler, solution to having an advanced inventory in Minetest.
|
||||
See game_api.txt for this mod's API.
|
||||
Available for use outside of MTG here:
|
||||
https://forum.minetest.net/viewtopic.php?t=19765
|
||||
|
||||
Authors of source code
|
||||
----------------------
|
||||
rubenwardy (MIT)
|
|
@ -29,16 +29,14 @@ end
|
|||
function sfinv.get_nav_fs(player, context, nav, current_idx)
|
||||
-- Only show tabs if there is more than one page
|
||||
if #nav > 1 then
|
||||
return "tabheader[0,0;tabs;" .. table.concat(nav, ",") .. ";" .. current_idx .. ";true;false]"
|
||||
return "tabheader[0,0;sfinv_nav_tabs;" .. table.concat(nav, ",") ..
|
||||
";" .. current_idx .. ";true;false]"
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end
|
||||
|
||||
local theme_main = "bgcolor[#080808BB;true]" .. default.gui_bg ..
|
||||
default.gui_bg_img
|
||||
|
||||
local theme_inv = default.gui_slots .. [[
|
||||
local theme_inv = [[
|
||||
list[current_player;main;0,4.7;8,1;]
|
||||
list[current_player;main;0,5.85;8,3;8]
|
||||
]]
|
||||
|
@ -46,7 +44,6 @@ local theme_inv = default.gui_slots .. [[
|
|||
function sfinv.make_formspec(player, context, content, show_inv, size)
|
||||
local tmp = {
|
||||
size or "size[8,8.6]",
|
||||
theme_main,
|
||||
sfinv.get_nav_fs(player, context, context.nav_titles, context.nav_idx),
|
||||
content
|
||||
}
|
||||
|
@ -84,9 +81,20 @@ function sfinv.get_formspec(player, context)
|
|||
return page:get(player, context)
|
||||
else
|
||||
local old_page = context.page
|
||||
context.page = sfinv.get_homepage_name(player)
|
||||
local home_page = sfinv.get_homepage_name(player)
|
||||
|
||||
if old_page == home_page then
|
||||
minetest.log("error", "[sfinv] Couldn't find " .. dump(old_page) ..
|
||||
", which is also the old page")
|
||||
|
||||
return ""
|
||||
end
|
||||
|
||||
context.page = home_page
|
||||
assert(sfinv.pages[context.page], "[sfinv] Invalid homepage")
|
||||
minetest.log("warning", "[sfinv] Couldn't find " .. dump(old_page) .. " so using switching to homepage")
|
||||
minetest.log("warning", "[sfinv] Couldn't find " .. dump(old_page) ..
|
||||
" so switching to homepage")
|
||||
|
||||
return sfinv.get_formspec(player, context)
|
||||
end
|
||||
end
|
||||
|
@ -127,6 +135,11 @@ function sfinv.set_page(player, pagename)
|
|||
sfinv.set_player_inventory_formspec(player, context)
|
||||
end
|
||||
|
||||
function sfinv.get_page(player)
|
||||
local context = sfinv.contexts[player:get_player_name()]
|
||||
return context and context.page or sfinv.get_homepage_name(player)
|
||||
end
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
if sfinv.enabled then
|
||||
sfinv.set_player_inventory_formspec(player)
|
||||
|
@ -151,8 +164,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||
end
|
||||
|
||||
-- Was a tab selected?
|
||||
if fields.tabs and context.nav then
|
||||
local tid = tonumber(fields.tabs)
|
||||
if fields.sfinv_nav_tabs and context.nav then
|
||||
local tid = tonumber(fields.sfinv_nav_tabs)
|
||||
if tid and tid > 0 then
|
||||
local id = context.nav[tid]
|
||||
local page = sfinv.pages[id]
|
||||
|
|
24
mods/mtg/sfinv/license.txt
Normal file
24
mods/mtg/sfinv/license.txt
Normal file
|
@ -0,0 +1,24 @@
|
|||
License of source code
|
||||
----------------------
|
||||
|
||||
The MIT License (MIT)
|
||||
Copyright (C) 2016-2018 rubenwardy <rubenwardy@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
software and associated documentation files (the "Software"), to deal in the Software
|
||||
without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or
|
||||
substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more details:
|
||||
https://opensource.org/licenses/MIT
|
Loading…
Add table
Add a link
Reference in a new issue