tidy code
This commit is contained in:
parent
bdf5286c6d
commit
cd6d86fa42
19
init.lua
19
init.lua
@ -1,9 +1,12 @@
|
|||||||
local S = minetest.get_translator("sfinv_home")
|
|
||||||
|
|
||||||
-- static spawn position
|
-- translation and static spawnpoint location
|
||||||
|
|
||||||
|
local S = minetest.get_translator("sfinv_home")
|
||||||
local statspawn = minetest.string_to_pos(
|
local statspawn = minetest.string_to_pos(
|
||||||
minetest.settings:get("static_spawnpoint")) or {x = 0, y = 12, z = 0}
|
minetest.settings:get("static_spawnpoint")) or {x = 0, y = 12, z = 0}
|
||||||
|
|
||||||
|
-- formspec
|
||||||
|
|
||||||
local get_formspec = function(name)
|
local get_formspec = function(name)
|
||||||
|
|
||||||
local formspec = "size[6,2]"
|
local formspec = "size[6,2]"
|
||||||
@ -14,6 +17,7 @@ local get_formspec = function(name)
|
|||||||
local home = sethome.get(name)
|
local home = sethome.get(name)
|
||||||
|
|
||||||
if home then
|
if home then
|
||||||
|
|
||||||
formspec = formspec
|
formspec = formspec
|
||||||
.. "label[2,1.5;" .. S("Home set to:") .. " "
|
.. "label[2,1.5;" .. S("Home set to:") .. " "
|
||||||
.. minetest.pos_to_string(vector.round(home)) .. "]"
|
.. minetest.pos_to_string(vector.round(home)) .. "]"
|
||||||
@ -25,8 +29,8 @@ local get_formspec = function(name)
|
|||||||
return formspec
|
return formspec
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- register homegui page
|
-- register homegui page
|
||||||
|
|
||||||
sfinv.register_page("sfinv_home:homegui", {
|
sfinv.register_page("sfinv_home:homegui", {
|
||||||
|
|
||||||
title = S("Home"),
|
title = S("Home"),
|
||||||
@ -53,9 +57,7 @@ sfinv.register_page("sfinv_home:homegui", {
|
|||||||
|
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
|
|
||||||
if not minetest.get_player_privs(name).home then
|
if not minetest.get_player_privs(name).home then return end
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if fields.home_gui_set then
|
if fields.home_gui_set then
|
||||||
|
|
||||||
@ -74,8 +76,8 @@ sfinv.register_page("sfinv_home:homegui", {
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
-- spawn command
|
-- spawn command
|
||||||
|
|
||||||
minetest.register_chatcommand("spawn", {
|
minetest.register_chatcommand("spawn", {
|
||||||
description = S("Go to Spawn"),
|
description = S("Go to Spawn"),
|
||||||
privs = {home = true},
|
privs = {home = true},
|
||||||
@ -83,9 +85,8 @@ minetest.register_chatcommand("spawn", {
|
|||||||
|
|
||||||
local player = minetest.get_player_by_name(name)
|
local player = minetest.get_player_by_name(name)
|
||||||
|
|
||||||
player:set_pos(statspawn)
|
if player then player:set_pos(statspawn) end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
print("[MOD] SFinv Home loaded")
|
print("[MOD] SFinv Home loaded")
|
||||||
|
4
mod.conf
4
mod.conf
@ -1,4 +1,4 @@
|
|||||||
name = sfinv_home
|
name = sfinv_home
|
||||||
|
description = Add a HOME tab to your inventory to bookmark location or go to spawn.
|
||||||
depends = sfinv
|
depends = sfinv
|
||||||
optional_depends =
|
min_minetest_version = 5.0
|
||||||
description = Adds HOME tab to inventory so that players can set a home point, go to home point or return to spawn.
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user