sfinv - upgrade sethome and integrated sfinv_home to sfinv
This commit is contained in:
parent
3b7bcb357e
commit
861dc596fd
@ -48,6 +48,7 @@ To download you can play this game with the following minetest engines:
|
||||
* regrow as `regrow` [mods/regrow](mods/regrow) from https://codeberg.org/minenux/minetest-mod-regrow
|
||||
* ethereal as `ethereal` [mods/ethereal](mods/ethereal) from https://codeberg.org/minenux/minetest-mod-ethereal
|
||||
* toolranks as `toolranks` [mods/toolranks](mods/toolranks) from https://codeberg.org/minenux/minetest-mod-toolranks
|
||||
* sfinv_home as `sfinv` we already integrated the `sfinv_home` mod into the default `sfinv` mod
|
||||
* armors and stuff mods
|
||||
* 3d_armor and shields [mods/3d_armor](mods/3d_armor) https://codeberg.org/minenux/minetest-mod-3d_armor
|
||||
* player stuffs:
|
||||
|
@ -1 +0,0 @@
|
||||
sfinv?
|
1
mods/sethome/description.txt
Normal file
1
mods/sethome/description.txt
Normal file
@ -0,0 +1 @@
|
||||
HOME manager support in game
|
@ -8,9 +8,7 @@ local S
|
||||
|
||||
local homes_file = minetest.get_worldpath() .. "/homes"
|
||||
local homepos = {}
|
||||
local is_50 = minetest.has_feature("object_use_texture_alpha")
|
||||
local sfinvhome = minetest.get_modpath("sfinv")
|
||||
|
||||
local is_50 = minetest.has_feature("object_use_texture_alpha") or false
|
||||
|
||||
if minetest.get_translator ~= nil then
|
||||
S = minetest.get_translator("sethome") -- 5.x translation function
|
||||
|
@ -1,3 +1,2 @@
|
||||
name = sethome
|
||||
optional_depends = sfinv
|
||||
description = Minetest Game mod: sethome
|
||||
|
@ -1 +1,2 @@
|
||||
default
|
||||
sethome?
|
@ -20,3 +20,59 @@ sfinv.register_page("sfinv:crafting", {
|
||||
]], true)
|
||||
end
|
||||
})
|
||||
|
||||
local home = minetest.get_modpath("sethome") or false
|
||||
local sfinvhome = minetest.get_modpath("sfinv_home") or false
|
||||
|
||||
if home and not sfinvhome then
|
||||
local get_formspec = function(name)
|
||||
|
||||
local formspec = "size[6,2]"
|
||||
.. "button_exit[2,2.5;4,1;home_gui_go;" .. "-> Home" .. "]"
|
||||
.. "button_exit[2,4.5;4,1;home_gui_set;" .. "!! Home <-" .. "]"
|
||||
-- .. "button_exit[2,6.5;4,1;home_gui_spawn;" .. S("Spawn") .. "]"
|
||||
|
||||
local home = sethome.get(name)
|
||||
|
||||
if home then
|
||||
formspec = formspec
|
||||
.. "label[2,1.5;" .. "Home:" .. " "
|
||||
.. minetest.pos_to_string(vector.round(home)) .. "]"
|
||||
else
|
||||
formspec = formspec
|
||||
.. "label[2,1.5;" .. "Invalid: no home!" .. "]"
|
||||
end
|
||||
|
||||
return formspec
|
||||
end
|
||||
|
||||
sfinv.register_page("sfinv:home", {
|
||||
title = "Home",
|
||||
get = function(self, player, context)
|
||||
local name = player:get_player_name()
|
||||
return sfinv.make_formspec(player, context, get_formspec(name))
|
||||
end,
|
||||
is_in_nav = function(self, player, context)
|
||||
local name = player:get_player_name()
|
||||
return minetest.get_player_privs(name).home
|
||||
end,
|
||||
on_enter = function(self, player, context) end,
|
||||
on_leave = function(self, player, context) end,
|
||||
on_player_receive_fields = function(self, player, context, fields)
|
||||
local name = player:get_player_name()
|
||||
if not minetest.get_player_privs(name).home then
|
||||
return
|
||||
end
|
||||
if fields.home_gui_set then
|
||||
sethome.set(name, player:get_pos())
|
||||
sfinv.set_player_inventory_formspec(player)
|
||||
elseif fields.home_gui_go then
|
||||
sethome.go(name)
|
||||
-- elseif fields.home_gui_spawn then
|
||||
-- player:set_pos(statspawn)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
|
2
mods/sfinv/mod.conf
Normal file
2
mods/sfinv/mod.conf
Normal file
@ -0,0 +1,2 @@
|
||||
name = sfinv
|
||||
optional_depends = sethome
|
Loading…
x
Reference in New Issue
Block a user