mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-25 16:53:46 +01:00
Remove deprecated modlib.player module
This commit is contained in:
parent
e0a6406566
commit
8a8f30f2aa
4
init.lua
4
init.lua
@ -100,8 +100,8 @@ local function load_module(self, module_name_or_alias)
|
|||||||
local module_name = modules[module_name_or_alias]
|
local module_name = modules[module_name_or_alias]
|
||||||
if not module_name then
|
if not module_name then
|
||||||
-- Handle modlib.[log|player] aliases for the minetest.[log|player] modules
|
-- Handle modlib.[log|player] aliases for the minetest.[log|player] modules
|
||||||
if module_name_or_alias == "log" or module_name_or_alias == "player" then
|
if module_name_or_alias == "log" then
|
||||||
return modlib.minetest[module_name_or_alias]
|
return modlib.minetest.log
|
||||||
end
|
end
|
||||||
-- no such module
|
-- no such module
|
||||||
return
|
return
|
||||||
|
@ -4,7 +4,6 @@ local components = {}
|
|||||||
for _, value in pairs{
|
for _, value in pairs{
|
||||||
"mod",
|
"mod",
|
||||||
"log",
|
"log",
|
||||||
"player",
|
|
||||||
"conf", -- deprecated
|
"conf", -- deprecated
|
||||||
"luon",
|
"luon",
|
||||||
"raycast",
|
"raycast",
|
||||||
|
@ -1,81 +0,0 @@
|
|||||||
-- Localize globals
|
|
||||||
local ipairs, minetest, modlib, table = ipairs, minetest, modlib, table
|
|
||||||
|
|
||||||
-- Set environment
|
|
||||||
local _ENV = {}
|
|
||||||
setfenv(1, _ENV)
|
|
||||||
|
|
||||||
--! deprecated
|
|
||||||
|
|
||||||
forbidden_names = {}
|
|
||||||
|
|
||||||
function register_forbidden_name(name) forbidden_names[name] = true end
|
|
||||||
|
|
||||||
function unregister_forbidden_name(name) forbidden_names[name] = nil end
|
|
||||||
|
|
||||||
minetest.register_on_prejoinplayer(function(name)
|
|
||||||
if forbidden_names[name] then
|
|
||||||
return 'The name "' .. name .. '" is not allowed as a player name'
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
playerdata = {}
|
|
||||||
defaults = {}
|
|
||||||
playerdata_functions = {}
|
|
||||||
|
|
||||||
function delete_player_data(playername) playerdata[playername] = nil end
|
|
||||||
|
|
||||||
function create_player_data(playername) playerdata[playername] = {} end
|
|
||||||
|
|
||||||
function init_player_data(playername)
|
|
||||||
modlib.table.add_all(playerdata[playername], defaults)
|
|
||||||
for _, callback in ipairs(playerdata_functions) do callback(playerdata[playername]) end
|
|
||||||
end
|
|
||||||
|
|
||||||
function get_player_data(playername) return playerdata[playername] end
|
|
||||||
|
|
||||||
function get_property(playername, propertyname) return get_player_data(playername)[propertyname] end
|
|
||||||
|
|
||||||
function set_property(playername, propertyname, propertyvalue) get_player_data(playername)[propertyname] = propertyvalue end
|
|
||||||
|
|
||||||
function get_property_default(propertyname) return defaults[propertyname] end
|
|
||||||
|
|
||||||
function set_property_default(propertyname, defaultvalue) defaults[propertyname] = defaultvalue end
|
|
||||||
|
|
||||||
function add_playerdata_function(callback) table.insert(playerdata_functions, callback) end
|
|
||||||
|
|
||||||
function get_color(player)
|
|
||||||
local sender_color = player:get_properties().nametag_color
|
|
||||||
if sender_color then
|
|
||||||
sender_color = minetest.rgba(sender_color.r, sender_color.g, sender_color.b)
|
|
||||||
else sender_color = "#FFFFFF" end
|
|
||||||
return sender_color
|
|
||||||
end
|
|
||||||
|
|
||||||
function get_color_table(player)
|
|
||||||
local sender_color = player:get_properties().nametag_color
|
|
||||||
return sender_color or { r = 255, g = 255, b = 255 }
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
|
||||||
local playername = player:get_player_name()
|
|
||||||
create_player_data(playername)
|
|
||||||
init_player_data(playername)
|
|
||||||
end)
|
|
||||||
minetest.register_on_leaveplayer(function(player)
|
|
||||||
local playername = player:get_player_name()
|
|
||||||
delete_player_data(playername)
|
|
||||||
end)
|
|
||||||
|
|
||||||
function datatable(table, default)
|
|
||||||
table = table or {}
|
|
||||||
default = default or {}
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
|
||||||
local name = player:get_player_name()
|
|
||||||
table[name] = table[name] or default
|
|
||||||
end)
|
|
||||||
minetest.register_on_leaveplayer(function(player) table[player:get_player_name()] = nil end)
|
|
||||||
return table
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Export environment
|
|
||||||
return _ENV
|
|
Loading…
Reference in New Issue
Block a user