mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-12-12 04:33:15 +01:00
basic API setup
This commit is contained in:
parent
528f1cb81f
commit
84900b39ad
@ -1,30 +1,7 @@
|
|||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
mcl_commands.alias_command("?", "help", false)
|
||||||
|
mcl_commands.alias_command("pardon", "unban", false)
|
||||||
local function register_chatcommand_alias(alias, cmd)
|
mcl_commands.rename_command("stop", "shutdown", false)
|
||||||
local def = minetest.chatcommands[cmd]
|
mcl_commands.alias_command("tell", "msg", false)
|
||||||
minetest.register_chatcommand(alias, def)
|
mcl_commands.alias_command("w", "msg", false)
|
||||||
end
|
mcl_commands.alias_command("tp", "teleport", false)
|
||||||
|
mcl_commands.rename_command("clear", "clearinv", false)
|
||||||
local function rename_chatcommand(newname, cmd)
|
|
||||||
local def = minetest.chatcommands[cmd]
|
|
||||||
minetest.register_chatcommand(newname, def)
|
|
||||||
minetest.unregister_chatcommand(cmd)
|
|
||||||
end
|
|
||||||
|
|
||||||
if minetest.settings:get_bool("mcl_builtin_commands_overide", true) then
|
|
||||||
register_chatcommand_alias("?", "help")
|
|
||||||
register_chatcommand_alias("pardon", "unban")
|
|
||||||
rename_chatcommand("stop", "shutdown")
|
|
||||||
register_chatcommand_alias("tell", "msg")
|
|
||||||
register_chatcommand_alias("w", "msg")
|
|
||||||
register_chatcommand_alias("tp", "teleport")
|
|
||||||
rename_chatcommand("clear", "clearinv")
|
|
||||||
|
|
||||||
minetest.register_chatcommand("banlist", {
|
|
||||||
description = S("List bans"),
|
|
||||||
privs = minetest.chatcommands["ban"].privs,
|
|
||||||
func = function(name)
|
|
||||||
return true, S("Ban list: @1", minetest.get_ban_list())
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
end
|
|
40
mods/CORE/mcl_commands/api.lua
Normal file
40
mods/CORE/mcl_commands/api.lua
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
mcl_commands.types = {
|
||||||
|
bool = {},
|
||||||
|
int = {},
|
||||||
|
float = {},
|
||||||
|
word = {},
|
||||||
|
text = {},
|
||||||
|
pos = {},
|
||||||
|
target = {},
|
||||||
|
playername = {},
|
||||||
|
}
|
||||||
|
|
||||||
|
function mcl_commands.register_complex_command()
|
||||||
|
end
|
||||||
|
|
||||||
|
function mcl_commands.register_basic_command()
|
||||||
|
end
|
||||||
|
|
||||||
|
function mcl_commands.alias_command(alias, original_name, bypass_setting)
|
||||||
|
if minetest.settings:get_bool("mcl_builtin_commands_overide", true) or bypass_setting then
|
||||||
|
local def = minetest.registered_chatcommands[cmd]
|
||||||
|
minetest.register_chatcommand(alias, def)
|
||||||
|
minetest.log("action", string.format("[mcl_commands] Aliasing [%s] command to [%s]", original_name, alias))
|
||||||
|
else
|
||||||
|
minetest.log("action", string.format("[mcl_commands] Aliasing [%s] command to [%s] skipped according to setting", original_name, alias))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function mcl_commands.rename_command(new_name, original_name, bypass_setting)
|
||||||
|
if minetest.settings:get_bool("mcl_builtin_commands_overide", true) or bypass_setting then
|
||||||
|
local def = minetest.registered_chatcommands[cmd]
|
||||||
|
minetest.register_chatcommand(newname, def)
|
||||||
|
minetest.unregister_chatcommand(cmd)
|
||||||
|
minetest.log("action", string.format("[mcl_commands] Renaming [%s] command to [%s]", original_name, new_name))
|
||||||
|
else
|
||||||
|
minetest.log("action", string.format("[mcl_commands] Renaming [%s] command to [%s] skipped according to setting", original_name, new_name))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function mcl_commands.get_target_selector(target_selector)
|
||||||
|
end
|
@ -1,5 +1,9 @@
|
|||||||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||||
|
|
||||||
|
mcl_commands = {}
|
||||||
|
|
||||||
|
dofile(modpath.."/api.lua")
|
||||||
|
|
||||||
dofile(modpath.."/register/kill.lua")
|
dofile(modpath.."/register/kill.lua")
|
||||||
dofile(modpath.."/register/setblock.lua")
|
dofile(modpath.."/register/setblock.lua")
|
||||||
dofile(modpath.."/register/seed.lua")
|
dofile(modpath.."/register/seed.lua")
|
||||||
@ -7,5 +11,6 @@ dofile(modpath.."/register/summon.lua")
|
|||||||
dofile(modpath.."/register/say.lua")
|
dofile(modpath.."/register/say.lua")
|
||||||
dofile(modpath.."/register/list.lua")
|
dofile(modpath.."/register/list.lua")
|
||||||
dofile(modpath.."/register/sound.lua")
|
dofile(modpath.."/register/sound.lua")
|
||||||
|
dofile(modpath.."/register/banlist.lua")
|
||||||
|
|
||||||
dofile(modpath.."/alias.lua")
|
dofile(modpath.."/alias.lua")
|
9
mods/CORE/mcl_commands/register/banlist.lua
Normal file
9
mods/CORE/mcl_commands/register/banlist.lua
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
local S = minetest.get_translator(minetest.get_current_modname())
|
||||||
|
|
||||||
|
minetest.register_chatcommand("banlist", {
|
||||||
|
description = S("List bans"),
|
||||||
|
privs = minetest.registered_chatcommands["ban"].privs,
|
||||||
|
func = function(name)
|
||||||
|
return true, S("Ban list: @1", minetest.get_ban_list())
|
||||||
|
end,
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user