clean up after players who left
This commit is contained in:
parent
bc9040d551
commit
3ee54fb685
21
init.lua
21
init.lua
@ -1,4 +1,3 @@
|
|||||||
local player_waypoints = {}
|
|
||||||
local update_interval = 1.31415
|
local update_interval = 1.31415
|
||||||
local compass_precision = 10 -- set to 1 to show whole number or 10 for 1 decimal
|
local compass_precision = 10 -- set to 1 to show whole number or 10 for 1 decimal
|
||||||
local default_waypoint_color = 0xFFFFFF
|
local default_waypoint_color = 0xFFFFFF
|
||||||
@ -7,10 +6,10 @@ local point_to_objects = false -- unimplemented
|
|||||||
local point_to_liquids = true
|
local point_to_liquids = true
|
||||||
local compass_range = 180
|
local compass_range = 180
|
||||||
|
|
||||||
-- lua metatables? what is that? :P
|
|
||||||
-- local function get_compass_meta_id(meta)
|
-- internal mod state
|
||||||
-- return meta:get_string("waypoint_compass:id") ~= "" or "default_id"
|
local player_waypoints = {} -- store a current player waypoint to see if it needs to be updated
|
||||||
-- end
|
local compass_dialog_context = {} -- store a compass item that player is editing via dialog
|
||||||
|
|
||||||
|
|
||||||
local function set_compass_meta_label(meta, label)
|
local function set_compass_meta_label(meta, label)
|
||||||
@ -188,6 +187,16 @@ minetest.register_globalstep(function(dtime)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
minetest.register_on_leaveplayer(function(player, timed_out)
|
||||||
|
local player_name = player:get_player_name()
|
||||||
|
if player_name ~= "" then
|
||||||
|
-- delete info about players that are left
|
||||||
|
player_waypoints[player_name] = nil
|
||||||
|
compass_dialog_context[player_name] = nil
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
|
||||||
local function coords_to_string(pos)
|
local function coords_to_string(pos)
|
||||||
-- strip "()"
|
-- strip "()"
|
||||||
if not pos then
|
if not pos then
|
||||||
@ -210,8 +219,6 @@ local function coords_from_string(str)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local compass_dialog_context = {}
|
|
||||||
|
|
||||||
local function show_basic_dialog(itemstack, player)
|
local function show_basic_dialog(itemstack, player)
|
||||||
local meta = itemstack:get_meta()
|
local meta = itemstack:get_meta()
|
||||||
-- set focus to "close" button to preven accidental edting
|
-- set focus to "close" button to preven accidental edting
|
||||||
|
Loading…
Reference in New Issue
Block a user