diff --git a/chatcommand_admin.lua b/chatcommand_admin.lua new file mode 100644 index 0000000..fbc90e3 --- /dev/null +++ b/chatcommand_admin.lua @@ -0,0 +1,19 @@ +local chatcommand_cmd = "admin_example" +local chatcommand_definition = { + params = " ", -- Short parameter description + description = "Example description", -- Full description + privs = {[yl_template.admin_priv] = true}, -- Require the "privs" privilege to run + func = function(name, param) + local success = true + if success then + return true, "Sucess message" + else + return false, "Fail message" + end + end + -- Called when command is run. Returns boolean success and text output. + -- Special case: The help message is shown to the player if `func` + -- returns false without a text output. +} + +minetest.register_chatcommand(chatcommand_cmd, chatcommand_definition) diff --git a/chatcommand_player.lua b/chatcommand_player.lua new file mode 100644 index 0000000..90a426a --- /dev/null +++ b/chatcommand_player.lua @@ -0,0 +1,19 @@ +local chatcommand_cmd = "player_example" +local chatcommand_definition = { + params = " ", -- Short parameter description + description = "Example description", -- Full description + privs = {privs = true}, -- Require the "privs" privilege to run + func = function(name, param) + local success = true + if success then + return true, "Sucess message" + else + return false, "Fail message" + end + end + -- Called when command is run. Returns boolean success and text output. + -- Special case: The help message is shown to the player if `func` + -- returns false without a text output. +} + +minetest.register_chatcommand(chatcommand_cmd, chatcommand_definition) diff --git a/chatcommands.lua b/chatcommands.lua index 85a09b2..89cd404 100644 --- a/chatcommands.lua +++ b/chatcommands.lua @@ -1,19 +1,2 @@ -local chatcommand_cmd = "example" -local chatcommand_definition = { - params = " ", -- Short parameter description - description = "Example description", -- Full description - privs = {privs = true}, -- Require the "privs" privilege to run - func = function(name, param) - local success = true - if success then - return true, "Sucess message" - else - return false, "Fail message" - end - end - -- Called when command is run. Returns boolean success and text output. - -- Special case: The help message is shown to the player if `func` - -- returns false without a text output. -} - -minetest.register_chatcommand(chatcommand_cmd, chatcommand_definition) +dofile(yl_template.modpath .. "chatcommand_admin.lua") +dofile(yl_template.modpath .. "chatcommand_player.lua") \ No newline at end of file