Included home_gui formspec and added support for sethome (my latest pull)
This commit is contained in:
parent
ee06364468
commit
80e91f711f
@ -1,2 +1,3 @@
|
||||
default?
|
||||
default
|
||||
sethome?
|
||||
creative?
|
||||
|
55
home_gui.lua
Normal file
55
home_gui.lua
Normal file
@ -0,0 +1,55 @@
|
||||
|
||||
-- static spawn position
|
||||
local statspawn = (minetest.setting_get_pos("static_spawnpoint") or {x = 0, y = 2, z = 0})
|
||||
local home_gui = {}
|
||||
|
||||
-- get_formspec
|
||||
home_gui.get_formspec = function(player)
|
||||
|
||||
local formspec = "size[6,2]"
|
||||
.. default.gui_bg
|
||||
.. default.gui_bg_img
|
||||
.. default.gui_slots
|
||||
.. "button[0,0;2,0.5;main;Back]"
|
||||
.. "button_exit[0,1.5;2,0.5;home_gui_set;Set Home]"
|
||||
.. "button_exit[2,1.5;2,0.5;home_gui_go;Go Home]"
|
||||
.. "button_exit[4,1.5;2,0.5;home_gui_spawn;Spawn]"
|
||||
|
||||
local home = sethome.get( player:get_player_name() )
|
||||
|
||||
if home then
|
||||
formspec = formspec
|
||||
.."label[2.5,-0.2;Home set to:]"
|
||||
.."label[2.5,0.4;".. minetest.pos_to_string(vector.round(home)) .. "]"
|
||||
end
|
||||
|
||||
return formspec
|
||||
end
|
||||
|
||||
-- add inventory_plus page when player joins
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
inventory_plus.register_button(player,"home_gui","Home Pos")
|
||||
end)
|
||||
|
||||
-- what to do when we press da buttons
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if fields.home_gui_set then
|
||||
sethome.set( player:get_player_name(), player:getpos() )
|
||||
end
|
||||
if fields.home_gui_go then
|
||||
sethome.go( player:get_player_name() )
|
||||
end
|
||||
if fields.home_gui_spawn then
|
||||
player:setpos(statspawn)
|
||||
end
|
||||
end)
|
||||
|
||||
-- spawn command
|
||||
minetest.register_chatcommand("spawn", {
|
||||
description = "Go to Spawn",
|
||||
privs = {home = true},
|
||||
func = function(name)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
player:setpos(statspawn)
|
||||
end,
|
||||
})
|
Loading…
x
Reference in New Issue
Block a user