initial work, namespace goberning and provide killme only if mod its abstend

This commit is contained in:
mckaygerhard 2023-06-09 23:40:06 -04:00
commit 4d43d40eb2
5 changed files with 132 additions and 0 deletions

18
README.md Normal file
View File

@ -0,0 +1,18 @@
minetest mod goberning
======================
ADMIN mod, light version of various mods and extra tool for manage server
Information
-----------
This mod attempts to be an improvement administration combo, but minimized
as a light version of some other tools like geoip, names-per-ip, antigrif, antihack,
etc etc etc
## LICENSE
(c) 2023 Lenz McKAY Gerhard mckaygerhard
CC-BY-SA-NC 4.0

37
commands.lua Normal file
View File

@ -0,0 +1,37 @@
-- mod governor by mckaygerhard
-- Copyright 2020
----------------------------------------------------------------------------
-- this program can be used free but cannot be used commertially or
-- modified for, licenced CC-BY-SA-NC 4.0
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
----------------------------------------------------------------------------
minetest.register_chatcommand("killme", {
description = "Kill yourself to respawn",
func = function(name)
local player = minetest.get_player_by_name(name)
if player then
if minetest.settings:get_bool("enable_damage") and player:is_player() then
player:set_hp(0)
return true
else
for _, callback in pairs(core.registered_on_respawnplayers) do
if callback(player) then
return true
end
end
-- There doesn't seem to be a way to get a default spawn pos from the lua API
return false, "No static_spawnpoint defined"
end
else
-- Show error message if used when not logged in, eg: from IRC mod
return false, "You need to be online to be killed!"
end
end
})

2
depends.txt Normal file
View File

@ -0,0 +1,2 @@
default?
mail?

73
init.lua Normal file
View File

@ -0,0 +1,73 @@
-- mod governor by mckaygerhard
-- Copyright 2020
----------------------------------------------------------------------------
-- this program can be used free but cannot be used commertially or
-- modified for, licenced CC-BY-SA-NC 4.0
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
----------------------------------------------------------------------------
local modname = "governing"
local modpath = minetest.get_modpath(modname)
local modstor = minetest.get_mod_storage()
local worlddir = minetest.get_worldpath()
local modmail = minetest.get_modpath("mail")
local moddefault = minetest.get_modpath("default")
local modkillme = minetest.get_modpath("killme")
local modcommand = minetest.get_modpath("game_commands")
if not killme_mod or not command_mod
local S
if minetest.get_translator ~= nil then
S = minetest.get_translator(modname) -- 5.x translation function
else
if minetest.get_modpath("intllib") then
dofile(minetest.get_modpath("intllib") .. "/init.lua")
if intllib.make_gettext_pair then
gettext, ngettext = intllib.make_gettext_pair() -- new gettext method
else
gettext = intllib.Getter() -- old text file method
end
S = gettext
else -- boilerplate function
S = function(str, ...)
local args = {...}
return str:gsub("@%d+", function(match)
return args[tonumber(match:sub(2))]
end)
end
end
end
local creative_mode_cache = minetest.settings:get_bool("creative_mode")
governing = {}
governing.S = S
governing.modname = modname -- name of the mod
governing.modpath = modpath -- path of the mod
governing.modstor = modstor -- request of storage for the mod
governing.worlddir = worlddir -- path of the world were the mod is running
governing.modmail = modmail -- path of the mail mod if available for sending messages internaly on private
governing.moddefault = moddefault -- path of default mod if availalbe
governing.modkillme = modkillme -- if killme is present as mod if available
governing.modcommand = modcommand -- if same killme and commands is present as mod if available
function governing.is_creative(name)
return minetest.check_player_privs(name, {creative = true}) or creative_mode_cache
end
if not goberning.modkillme and not goberning.moddefault then
dofile(goberning.modpath.."/commands.lua")
end
print("[MOD] governor mod loaded" )

2
mod.conf Normal file
View File

@ -0,0 +1,2 @@
name = goberning
depends = default