added command /npc_talk_force_edit

This commit is contained in:
Sokomine 2023-07-01 18:48:00 +02:00
parent 70d81c2bd7
commit 7ac09d9057
3 changed files with 50 additions and 0 deletions

View File

@ -86,6 +86,13 @@ and set its name).
server will crash - so please test on a test server first!
Requires the privs priv.
#### `/npc_talk_force_edit` Toggles edit mode.
From now on (until you issue this command again), all NPC you
talk to will be in edit mode (provided you are allowed to
edit them). This is useful if something's wrong with your NPC
like i.e. you made it select a dialog automaticly and let
that dialog lead to d_end.
### 3. Terminology
<a name="terminology"></a>

View File

@ -513,6 +513,29 @@ yl_speak_up.check_for_disambigous_results = function(n_id, pname)
end
-- allow to enter force edit mode (useful when an NPC was broken)
yl_speak_up.force_edit_mode = {}
-- command to enter force edit mode
yl_speak_up.command_npc_talk_force_edit = function(pname, param)
if(not(pname)) then
return
end
if(yl_speak_up.force_edit_mode[pname]) then
yl_speak_up.force_edit_mode[pname] = nil
minetest.chat_send_player(pname,
"Ending force edit mode for NPC. From now on talks "..
"will no longer start in edit mode.")
else
yl_speak_up.force_edit_mode[pname] = true
minetest.chat_send_player(pname,
"STARTING force edit mode for NPC. From now on talks "..
"with NPC will always start in edit mode provided "..
"you are allowed to edit this NPC.\n"..
"In order to end force edit mode, give the command "..
"/npc_talk_force_edit a second time.")
end
end
-- Make the NPC talk
function yl_speak_up.talk(self, clicker)
@ -608,6 +631,12 @@ function yl_speak_up.talk(self, clicker)
yl_speak_up.speak_to[pname].may_edit_this_npc = true
end
-- are we in force edit mode, and can the player edit this NPC?
if(yl_speak_up.force_edit_mode[pname]
and yl_speak_up.may_edit_npc(clicker, n_id)) then
yl_speak_up.edit_mode[pname] = n_id
end
local dialog = yl_speak_up.speak_to[pname].dialog
if(not(dialog.trades)) then
dialog.trades = {}

View File

@ -150,6 +150,20 @@ minetest.register_chatcommand( 'npc_talk_reload', {
end
})
-- most of the files of this mod can be reloaded without the server having to
-- be restarted;
-- handled in init.lua
minetest.register_chatcommand( 'npc_talk_force_edit', {
description = "Toggles force edit mode. This is helpful if you cut yourself out "..
"of editing an NPC by breaking it. From now on all NPC you will talk to "..
"will already be in edit mode (provided you are allowed to edit them)."..
"\nIssuing the command again ends force edit mode.",
privs = {npc_talk_owner = true},
func = function(pname, param)
return yl_speak_up.command_npc_talk_force_edit(pname, param)
end,
})
-----------------------------------------------------------------------------
-- some node positions can be set by punching a node
-----------------------------------------------------------------------------