added npc_talk command
This commit is contained in:
parent
9d8bff11b2
commit
3e9591eee8
59
chat_commands.lua
Normal file
59
chat_commands.lua
Normal file
@ -0,0 +1,59 @@
|
||||
-- Implementation of chat commands that were registered in register_once
|
||||
|
||||
-- general function for handling talking to the NPC
|
||||
yl_speak_up.command_npc_talk = function(pname, param)
|
||||
if(not(pname)) then
|
||||
return
|
||||
end
|
||||
local parts = string.split(param or "", " ", false, 1)
|
||||
local cmd = parts[1] or ""
|
||||
local rest = parts[2] or ""
|
||||
-- setting talk style is available for all
|
||||
if( cmd and cmd == "style") then
|
||||
-- implemented in fs_decorated.lua:
|
||||
return yl_speak_up.command_npc_talk_style(pname, rest)
|
||||
-- debug mode only makes sense if the player can edit that NPC; the command checks for this
|
||||
elseif(cmd and cmd == "debug") then
|
||||
-- implemented in npc_talk_debug.lua:
|
||||
return yl_speak_up.command_npc_talk_debug(pname, rest)
|
||||
-- activates edit mode when talking to an NPC; but only if the player can edit that NPC
|
||||
elseif(cmd and cmd == "force_edit") then
|
||||
-- implemented in functions.lua:
|
||||
return yl_speak_up.command_npc_talk_force_edit(pname, rest)
|
||||
|
||||
-- managing generic NPC requires npc_talk_admin priv
|
||||
elseif(cmd and cmd == "generic") then
|
||||
if(not(minetest.check_player_privs(pname, {npc_talk_admin = true}))) then
|
||||
minetest.chat_send_player(pname, "This command is used for managing "..
|
||||
"generic NPC. You lack the \"npc_talk_admin\" priv required to "..
|
||||
"run this command.")
|
||||
return
|
||||
end
|
||||
-- implemented in add_generic_dialogs.lua:
|
||||
return yl_speak_up.command_npc_talk_generic(pname, rest)
|
||||
elseif(cmd and cmd == "privs") then
|
||||
-- TODO: make this available for npc_talk_admin?
|
||||
if(not(minetest.check_player_privs(pname, {privs = true}))) then
|
||||
minetest.chat_send_player(pname, "This command is used for managing "..
|
||||
"privs (like execute lua, teleportation, giving items...) for NPC. "..
|
||||
"You lack the \"privs\" priv required to "..
|
||||
"run this command.")
|
||||
return
|
||||
end
|
||||
-- implemented in npc_privs.lua:
|
||||
return yl_speak_up.command_npc_talk_privs(pname, rest)
|
||||
end
|
||||
minetest.chat_send_player(pname,
|
||||
"The /npc_talk command is used for managing the yl_speak_up mod and "..
|
||||
"any NPC that use it.\n"..
|
||||
"Usage: \"/npc_talk <command>\" with <command> beeing:\n"..
|
||||
" help this help here\n"..
|
||||
" style display talk menu in a way better suited for very old versions of MT\n"..
|
||||
" debug debug a particular NPC\n"..
|
||||
" force_edit forces edit mode for any NPC you talk to\n"..
|
||||
" generic [requores npc_talk_admin priv] list, add or remove NPC as generic NPC\n"..
|
||||
" privs [requires privs priv] list, grant or revoke privs for an NPC\n"..
|
||||
-- reload is fully handled in register_once
|
||||
"Note: /npc_talk_reload [requires privs priv] reloads the code of the mod without server "..
|
||||
"restart.")
|
||||
end
|
2
init.lua
2
init.lua
@ -222,6 +222,8 @@ yl_speak_up.reload = function(modpath, log_entry)
|
||||
dofile(modpath .. "fs_properties.lua")
|
||||
-- the main functionality of the mod
|
||||
dofile(modpath .. "functions.lua")
|
||||
-- implementation of the chat commands registered in register_once.lua:
|
||||
dofile(modpath .. "chat_commands.lua")
|
||||
-- creating and maintaining quests
|
||||
dofile(modpath .. "fs_quest_gui.lua")
|
||||
|
||||
|
@ -171,6 +171,16 @@ minetest.register_chatcommand( 'npc_talk_force_edit', {
|
||||
end,
|
||||
})
|
||||
|
||||
-- a general command that may branch off and/or offer help
|
||||
minetest.register_chatcommand( 'npc_talk', {
|
||||
description = "Manage NPC based on yl_speak_up.\n"..
|
||||
"Usage: \"/npc_talk <command>\" i.e. \"/npc_talk help\".",
|
||||
privs = {},
|
||||
func = function(pname, param)
|
||||
return yl_speak_up.command_npc_talk(pname, param)
|
||||
end,
|
||||
})
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- some node positions can be set by punching a node
|
||||
-----------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user