diff --git a/README.md b/README.md
index 3286b11..96b0af3 100644
--- a/README.md
+++ b/README.md
@@ -140,12 +140,8 @@ special meaning:
### 5. How to configure NPC and add dialogs
-There are two ways:
-1. Just talk to them and click on the "I am your owner"-Dialog. This opens up
- a menu where you can edit most things.
-2. Use /giveme to get the staff you want, wield the staff and point it at the
- NPC you want to change. This is much more powerful. Lua code can be
- entered and later executed by the NPC.
+Just talk to them and click on the "I am your owner"-Dialog. This opens up
+a menu where you can edit most things.
hint: The command `/npc_talk debug ` allows you to get debug
information regarding preconditions and effects. You can turn it
@@ -157,11 +153,9 @@ hint: The command `/npc_talk debug ` allows you to get debug
`npc_talk_owner` will allow players to edit their *own* NPC by talking to them.
- Does *not* include usage of the staffs!
Ought to be given to all players.
`npc_talk_master` allows players to edit *any* NPC supported by this mod.
- Does *not* include usage of the staffs!
Ought to be given to selected trusted players who want to
help others with their NPC configuration and/or support
NPCs owned by the server.
@@ -173,7 +167,7 @@ hint: The command `/npc_talk debug ` allows you to get debug
the prefix "server".
`npc_master` allows players to edit *any* NPC supported by this mod.
- *Does* include usage of the staffs.
+ *Does* include usage of the staffs (now part of `yl_npc`).
This is very powerful and allows to enter and execute lua
code without restrictions.
Only grant this to staff members you really trust.
@@ -198,17 +192,8 @@ NPC can have privs as well. The NPC...
### 7. Tools
-There are diffrent staffs for diffrent functionality:
-Staff of.. does:
-..I-said-so edit what the NPC says (extremly powerful)
-..shut-up mute the NPC
-..dawai-dawai un-mute the NPC
-..game-over remove the NPC (but not its data)
-..fashion change skin etc.
-
-Be careful: With the staffs, you can add more than one result of the type
-"dialog" - which will confuse the NPC and lead to unexpected results. Use
-the staffs only with care!
+There are no more tools (=staffs) provided. You can do all you could do
+with them by just talking to the NPC.
### 8. Mute
@@ -217,9 +202,9 @@ the staffs only with care!
When you edit an NPC, you might want to stop it from talking to other players
and spoiling unifinished texts/options to the player.
-For this case, the NPC can be muted. This works either with the staff or by
-selecting the appropriate option in the talk menu after having started edit
-mode by claiming to be the NPC's owner.
+For this case, the NPC can be muted. This works by selecting the appropriate
+option in the talk menu after having started edit mode by claiming to be the
+NPC's owner.
### 9. Skin
@@ -271,8 +256,6 @@ Trades can either be attached to dialog options (and show up as results there)
via the edit options dialog or just be trades that are shown in a trade list.
The trade list can be accessed from the NPC's inventory.
-Trades cannot be added with the staffs.
-
If there are trades that ought to show up in the general trade list (i.e. not
only be attached to dialog options), then a button "Let's trade" will be shown
as option for the first dialog.
diff --git a/config.lua b/config.lua
index 39ce289..c452e89 100644
--- a/config.lua
+++ b/config.lua
@@ -9,11 +9,6 @@
--
-- So please use a seperate config mod!
--- enable/disable the original staff-based editing
--- Note: The staffs can only edit part of what the NPC can do. They can even break the NPC.
--- Set this only if you need to force-mute an NPC or something like that.
-yl_speak_up.enable_staff_based_editing = true
-
-- Do the NPCs talk right after they spawned?
yl_speak_up.talk_after_spawn = true
diff --git a/init.lua b/init.lua
index 1a3c45d..580d644 100644
--- a/init.lua
+++ b/init.lua
@@ -264,17 +264,3 @@ yl_speak_up_execute_if_file_exists("startup")
-- load all those files that can also be reloaded without a server restart
-- load here for the first time:
yl_speak_up.reload(modpath, "loaded")
-
-
--- these functions here mostly cannot be reloaded without a server restart
--- because they register tools and entities
---
--- the staffs (requires npc_master priv)
-if(yl_speak_up.enable_staff_based_editing) then
- -- editing the npc with the staff:
- dofile(modpath .. "staff_based_editing.lua")
- -- defining the staffs:
- dofile(modpath .. "tools.lua")
-end
-
-minetest.log("action","[MOD] yl_speak_up loaded tools and mobs")
diff --git a/staff_based_editing.lua b/staff_based_editing.lua
deleted file mode 100644
index 8ba0dea..0000000
--- a/staff_based_editing.lua
+++ /dev/null
@@ -1,767 +0,0 @@
------------------------------------------------------------------------------
--- these functions are used/needed for staff based editing
------------------------------------------------------------------------------
--- this was created by AliasAlreadyTaken and the original edit mechanism
-
-local function options_to_dialog(pname)
- local dialog = yl_speak_up.speak_to[pname].dialog
-
- local n_id = yl_speak_up.speak_to[pname].n_id
- local d_id = yl_speak_up.speak_to[pname].d_id
- local o_id = yl_speak_up.speak_to[pname].o_id
- local p_id = yl_speak_up.speak_to[pname].p_id
- local r_id = yl_speak_up.speak_to[pname].r_id
-
- if yl_speak_up.speak_to[pname].d_text then
- dialog.n_dialogs[d_id].d_text = yl_speak_up.speak_to[pname].d_text
- end
-
- --Find the o_id to save to
- local future_o_id = ""
- if yl_speak_up.speak_to[pname].o_id ~= nil and yl_speak_up.speak_to[pname].o_id ~= yl_speak_up.text_new_option_id then
- future_o_id = yl_speak_up.speak_to[pname].o_id
- else
- future_o_id = "o_" .. yl_speak_up.find_next_id(dialog.n_dialogs[d_id].d_options)
-
- if dialog.n_dialogs[d_id].d_options == nil then
- dialog.n_dialogs[d_id].d_options = {}
- end
-
- dialog.n_dialogs[d_id].d_options[future_o_id] = {}
- end
-
- --Find the p_id to save to
- local future_p_id = ""
- if
- yl_speak_up.speak_to[pname].p_id ~= nil and
- yl_speak_up.speak_to[pname].p_id ~= yl_speak_up.text_new_prerequisite_id
- then
- future_p_id = yl_speak_up.speak_to[pname].p_id
- else
- future_p_id = "p_" .. yl_speak_up.find_next_id(dialog.n_dialogs[d_id].d_options[future_o_id].o_prerequisites)
- if future_p_id == "p_1" then
- dialog.n_dialogs[d_id].d_options[future_o_id].o_prerequisites = {}
- end
- dialog.n_dialogs[d_id].d_options[future_o_id].o_prerequisites[future_p_id] = {}
- end
-
- --Find the r_id to save to
- local future_r_id = ""
- if yl_speak_up.speak_to[pname].r_id ~= nil and yl_speak_up.speak_to[pname].r_id ~= yl_speak_up.text_new_result_id then
- future_r_id = yl_speak_up.speak_to[pname].r_id
- else
- future_r_id = yl_speak_up.add_new_result(dialog, d_id, future_o_id)
- end
-
- --Edit options
- dialog.n_dialogs[d_id].d_options[future_o_id].o_id = future_o_id
- dialog.n_dialogs[d_id].d_options[future_o_id].o_hide_when_prerequisites_not_met =
- yl_speak_up.speak_to[pname].o_hide or "false"
- dialog.n_dialogs[d_id].d_options[future_o_id].o_grey_when_prerequisites_not_met =
- yl_speak_up.speak_to[pname].o_grey or "false"
- local s = yl_speak_up.sanitize_sort(dialog.n_dialogs[d_id].d_options, yl_speak_up.speak_to[pname].o_sort)
- dialog.n_dialogs[d_id].d_options[future_o_id].o_sort = s
- dialog.n_dialogs[d_id].d_options[future_o_id].o_text_when_prerequisites_not_met =
- yl_speak_up.speak_to[pname].o_not_met or ""
- dialog.n_dialogs[d_id].d_options[future_o_id].o_text_when_prerequisites_met =
- yl_speak_up.speak_to[pname].o_met or ""
-
- --Edit prerequisites
-
- --Do we delete the prerequisite?
- if
- yl_speak_up.speak_to[pname].p_type == "delete" and yl_speak_up.speak_to[pname].p_id ~= nil and
- yl_speak_up.speak_to[pname].p_id ~= yl_speak_up.text_new_prerequisite_id
- then
- dialog.n_dialogs[d_id].d_options[future_o_id].o_prerequisites[future_p_id] = nil
- else
- if yl_speak_up.speak_to[pname].p_value ~= nil and yl_speak_up.speak_to[pname].p_value ~= "" then
- dialog.n_dialogs[d_id].d_options[future_o_id].o_prerequisites[future_p_id].p_id = future_p_id
- dialog.n_dialogs[d_id].d_options[future_o_id].o_prerequisites[future_p_id].p_type =
- yl_speak_up.speak_to[pname].p_type
- dialog.n_dialogs[d_id].d_options[future_o_id].o_prerequisites[future_p_id].p_value =
- yl_speak_up.speak_to[pname].p_value
- end
- end
-
- --Do we delete the result?
- if
- yl_speak_up.speak_to[pname].r_type == "delete" and yl_speak_up.speak_to[pname].r_id ~= nil and
- yl_speak_up.speak_to[pname].r_id ~= yl_speak_up.text_new_result_id
- then
- dialog.n_dialogs[d_id].d_options[future_o_id].o_results[future_r_id] = nil
- else
- if yl_speak_up.speak_to[pname].r_value ~= nil and yl_speak_up.speak_to[pname].r_value ~= "" then
- dialog.n_dialogs[d_id].d_options[future_o_id].o_results[future_r_id].r_id = future_r_id
- dialog.n_dialogs[d_id].d_options[future_o_id].o_results[future_r_id].r_type =
- yl_speak_up.speak_to[pname].r_type
- dialog.n_dialogs[d_id].d_options[future_o_id].o_results[future_r_id].r_value =
- yl_speak_up.speak_to[pname].r_value
- end
- end
-
- return dialog
-end
-
---###
--- Helpers
---###
-
-local function get_prerequisite_types()
- --local t_gpt = {"item", "quest", "function", "auto", "delete"}
- local t_gpt = {"item", "function", "delete"}
- local s_gpt = ""
- for _, v in pairs(t_gpt) do
- s_gpt = s_gpt .. v .. ","
- end
-
- s_gpt = s_gpt:sub(1, -2) -- cut last comma
-
- return s_gpt, t_gpt
-end
-
-local function get_result_types()
- --local t_grt = {"dialog", "give_item", "quest", "function", "auto", "delete"}
- local t_grt = {"dialog","give_item","take_item","move","function","trade","delete"}
- local s_grt = ""
- for _, v in pairs(t_grt) do
- s_grt = s_grt .. v .. ","
- end
-
- s_grt = s_grt:sub(1, -2) -- cut last comma
-
- return s_grt, t_grt
-end
-
-
-local function delete_option(n_id, d_id, o_id)
- if d_id == yl_speak_up.text_new_dialog_id then
- return false
- end -- We don't delete "New dialog" Also, something might have gone wrong here.
- if o_id == yl_speak_up.text_new_option_id then
- return false
- end -- We don't delete "New option"
-
- local dialog = yl_speak_up.load_dialog(n_id, false)
-
- dialog.n_dialogs[d_id].d_options[o_id] = nil
-
- yl_speak_up.save_dialog(n_id, dialog)
-end
-
-
---###
---Formspecs
---###
-
--- get formspecs
-
--- dialog
-
-yl_speak_up.get_fs_setdialog = function(clicker, n_id, d_id)
- local dialog = yl_speak_up.load_dialog(n_id, false)
-
- local items = yl_speak_up.text_new_dialog_id
- local count = 1
- local d_sort = ""
- local text = ""
-
- if next(dialog) == nil then -- file does not exist
- dialog.n_id = n_id
- dialog.n_npc = ""
- dialog.n_description = ""
- elseif dialog.n_dialogs == nil then -- file does exist, but no dialogs are set
- dialog.n_id = n_id
- text = ""
- else -- file exists and there's already content
- local n = 1
- for k, v in pairs(dialog.n_dialogs) do
- n = n + 1
- if k == d_id then
- count = n
- d_sort = v.d_sort or ""
- text = v.d_text or ""
- end
- items = items .. "," .. v.d_id
- end
-
- text = minetest.formspec_escape(text)
- end
-
- local formspec = {
- "size[13.4,8.5]",
- "label[0.2,0.35;",
- dialog.n_id,
- "]",
- "field[1.3,0.1;3.7,0.5;n_npc;;",
- dialog.n_npc,
- "]",
- "field[5.2,0.1;8,0.5;n_description;;",
- dialog.n_description,
- "]",
- "dropdown[5.2,0.75;5,0.75;d_id;",
- items,
- ";",
- count,
- "]",
- -- allow to change the owner of the npc
- "label[0.2,1;Owner]",
- "field[1.3,0.75;3.7,0.5;npc_owner;;",
- (yl_speak_up.npc_owner[ n_id ] or "- nobody -"),
- "]",
- "label[10.9,1;Sort]",
- "field[11.7,0.75;1.5,0.5;d_sort;;",
- d_sort,
- "]",
- "textarea[0.2,1.6;13,6;d_text;;",
- text,
- "]",
- "button_exit[0.2,7.7;3,0.75;button_cancel;Cancel]",
- "button[4,7.7;3,0.75;button_delete;Delete]",
- "button[7.1,7.7;3,0.75;button_option;Options]",
- "button[10.2,7.7;3,0.75;button_save;Save]",
- -- tooltips
-
- "tooltip[npc_owner;npc_owner: The name of the owner of the NPC - who can edit dialogs of this NPC if he has the npc_talk_owner priv;#FFFFFF;#000000]",
- "tooltip[n_npc;n_npc: The name of the NPC;#FFFFFF;#000000]",
- "tooltip[n_description;n_description: A description for the NPC;#FFFFFF;#000000]",
- "tooltip[d_sort;d_sort: Make this 0 on your dialog if you want it to be shown the first time a player talks to the NPC\nNegative values are ignored\n;#FFFFFF;#000000]",
- "tooltip[5.2,0.75;5,0.75;d_id: Dialog Id;#FFFFFF;#000000]",
- "tooltip[d_text;d_text: Dialog text. What the NPC says to you;#FFFFFF;#000000]"
- }
-
- return table.concat(formspec, "")
-end
-
--- options
-
-yl_speak_up.get_fs_optiondialog = function(player, n_id, d_id, o_id, p_id, r_id)
- local dialog = yl_speak_up.load_dialog(n_id, false)
- local pname = player:get_player_name()
-
- if next(dialog) == nil or d_id == yl_speak_up.text_new_dialog_id or dialog.n_dialogs == nil then -- file does not exist or the user sent the New dialog
- return yl_speak_up.get_error_message(n_id)
- end
-
- -- default values
- local out = {}
-
- -- npc
- out.n_id = n_id
-
- -- dialog
- out.d_id = yl_speak_up.text_new_dialog_id
- out.d_text = "Dialog Text"
-
- -- option
- out.o_id_items = yl_speak_up.text_new_option_id
- out.o_id_count = 1
- out.o_hide = "false"
- out.o_grey = "false"
- out.o_sort = ""
- out.o_met = "Text when conditions are met"
- out.o_not_met = "Text when conditions are not met"
-
- -- prerequisite
- out.p_id_items = yl_speak_up.text_new_prerequisite_id
- out.p_id_count = 1
- out.p_type_items, out.p_type_items_table = get_prerequisite_types()
- out.p_type_count = 1
- out.p_value = ""
-
- -- result
- out.r_id_items = yl_speak_up.text_new_result_id
- out.r_id_count = 1
- out.r_type_items = get_result_types()
- out.r_type_count = 1
- out.r_value = ""
-
- --dialogs
- for k, v in pairs(dialog.n_dialogs) do
- if k == d_id then
- out.d_id = v.d_id
- out.d_text = minetest.formspec_escape(v.d_text):trim()
- end
- end
-
- --options
- if dialog.n_dialogs[d_id].d_options ~= nil then
- local o_n = 1
- for o_k, o_v in pairs(dialog.n_dialogs[d_id].d_options) do
- o_n = o_n + 1
- if o_k == o_id then
- out.o_id_count = o_n
- end
- out.o_id_items = out.o_id_items .. "," .. o_v.o_id
- end
- if dialog.n_dialogs[d_id].d_options[o_id] then
- if dialog.n_dialogs[d_id].d_options[o_id].o_hide_when_prerequisites_not_met then
- out.o_hide = dialog.n_dialogs[d_id].d_options[o_id].o_hide_when_prerequisites_not_met
- end
- if dialog.n_dialogs[d_id].d_options[o_id].o_grey_when_prerequisites_not_met then
- out.o_grey = dialog.n_dialogs[d_id].d_options[o_id].o_grey_when_prerequisites_not_met
- end
- if dialog.n_dialogs[d_id].d_options[o_id].o_sort then
- out.o_sort = dialog.n_dialogs[d_id].d_options[o_id].o_sort
- end
- if dialog.n_dialogs[d_id].d_options[o_id].o_text_when_prerequisites_met then
- out.o_met =
- minetest.formspec_escape(dialog.n_dialogs[d_id].d_options[o_id].o_text_when_prerequisites_met):trim(
-
- )
- end
- if dialog.n_dialogs[d_id].d_options[o_id].o_text_when_prerequisites_not_met then
- out.o_not_met =
- minetest.formspec_escape(dialog.n_dialogs[d_id].d_options[o_id].o_text_when_prerequisites_not_met):trim(
-
- )
- end
-
- -- prerequisite
-
- --if dialog.n_dialogs[d_id].d_options[o_id].o_prerequisites ~= nil and p_id == yl_speak_up.text_new_prerequisite_id then -- new prerequisite
- --end
- if dialog.n_dialogs[d_id].d_options[o_id].o_prerequisites ~= nil then
- local p_n = 1
- for p_k, p_v in pairs(dialog.n_dialogs[d_id].d_options[o_id].o_prerequisites) do
- p_n = p_n + 1
- if p_k == p_id then
- out.p_id_count = p_n
- end
- out.p_id_items = out.p_id_items .. "," .. p_v.p_id
- end
-
- out.p_type_items, out.p_type_items_table = get_prerequisite_types()
-
- if
- dialog.n_dialogs[d_id].d_options[o_id].o_prerequisites[p_id] ~= nil and
- dialog.n_dialogs[d_id].d_options[o_id].o_prerequisites[p_id].p_type ~= nil
- then
- local p_type_n = 1
- for _, p_type_v in pairs(out.p_type_items_table) do
- if p_type_v == dialog.n_dialogs[d_id].d_options[o_id].o_prerequisites[p_id].p_type then
- out.p_type_count = p_type_n
- end
- p_type_n = p_type_n + 1
- end
-
- out.p_value =
- minetest.formspec_escape(dialog.n_dialogs[d_id].d_options[o_id].o_prerequisites[p_id].p_value):trim(
-
- )
- end
- end
-
- -- result
- if dialog.n_dialogs[d_id].d_options[o_id].o_results ~= nil then
- local r_n = 1
- for r_k, r_v in pairs(dialog.n_dialogs[d_id].d_options[o_id].o_results) do
- r_n = r_n + 1
- if r_k == r_id then
- out.r_id_count = r_n
- end
- out.r_id_items = out.r_id_items .. "," .. r_v.r_id
- end
-
- out.r_type_items, out.r_type_items_table = get_result_types()
-
- if
- dialog.n_dialogs[d_id].d_options[o_id].o_results[r_id] ~= nil and
- dialog.n_dialogs[d_id].d_options[o_id].o_results[r_id].r_type ~= nil
- then
- local r_type_n = 1
- for _, r_type_v in pairs(out.r_type_items_table) do
- if r_type_v == dialog.n_dialogs[d_id].d_options[o_id].o_results[r_id].r_type then
- out.r_type_count = r_type_n
- end
- r_type_n = r_type_n + 1
- end
-
- out.r_value =
- minetest.formspec_escape(dialog.n_dialogs[d_id].d_options[o_id].o_results[r_id].r_value):trim()
- end
- end
- end
- end
-
- local formspec = {
- "size[13.4,8.5]",
- -- npc
- "field[-10,-10;4,0.5;n_id;;",
- out.n_id,
- "]",
- -- dialog
- "field[-10,-10;4,0.5;d_id;;",
- out.d_id,
- "]",
- "label[0.2,0.35;",
- out.d_id,
- "]",
- "field[1,0.1;12.2,0.5;d_text;;",
- out.d_text,
- "]",
- -- option
- "dropdown[0.2,0.75;2,0.75;o_id;",
- out.o_id_items,
- ";",
- out.o_id_count,
- "]",
- "checkbox[0.2,1.85;o_hide;Hide;",
- out.o_hide,
- "]",
- "checkbox[0.2,2.35;o_grey;Grey;",
- out.o_grey,
- "]",
- "field[1.6,2.05;0.75,0.5;o_sort;Sort;",
- out.o_sort,
- "]",
- "textarea[2.4,0.75;10.8,0.95;o_met;;",
- out.o_met,
- "]",
- "textarea[2.4,1.75;10.8,0.95;o_not_met;;",
- out.o_not_met,
- "]",
- -- prerequisite
- "dropdown[0.2,2.8;3,0.75;p_id;",
- out.p_id_items,
- ";",
- out.p_id_count,
- "]",
- "dropdown[0.2,3.8;3,0.75;p_type;",
- out.p_type_items,
- ";",
- out.p_type_count,
- "]",
- "textarea[3.4,2.8;9.8,2.1;p_value;;",
- out.p_value,
- "]",
- -- result
- "dropdown[0.2,5;3,0.75;r_id;",
- out.r_id_items,
- ";",
- out.r_id_count,
- "]",
- "dropdown[0.2,6;3,0.75;r_type;",
- out.r_type_items,
- ";",
- out.r_type_count,
- "]",
- "textarea[3.4,5;9.8,2.1;r_value;;",
- out.r_value,
- "]",
- -- buttons
- "button[0.2,7.7;3,0.75;button_back;Back]",
- "button[7.1,7.7;3,0.75;button_delete;Delete OPTION]",
- "button[10.2,7.7;3,0.75;button_save;Save]",
- -- tooltips
-
- "tooltip[d_text;d_text: Dialog text. What the NPC says to you\n\n",
- out.d_text,
- ";#FFFFFF;#000000]",
- "tooltip[0.2,0.75;2,0.75;o_id: Option Id;#FFFFFF;#000000]",
- "tooltip[o_met;o_met: Option text when prerequisites are met\n(What you say to the NPC)\n\n",
- out.o_met,
- ";#FFFFFF;#000000]",
- "tooltip[o_not_met;o_not_met: Option text when prerequisites are not met\n(What you say to the NPC instead)\n\n",
- out.o_not_met,
- ";#FFFFFF;#000000]",
- "tooltip[o_hide;o_hide: If checked, this option is hidden when prerequistes are not met;#FFFFFF;#000000]",
- "tooltip[o_grey;o_grey: If checked, this option is shown when prerequistes are not met, but grey and not selectable;#FFFFFF;#000000]",
- "tooltip[o_sort;o_sort: The lower the number, the higher up in the list this option goes\nNegative values are ignored;#FFFFFF;#000000]",
- "tooltip[0.2,2.8;3,0.75;p_id: Prerequisite Id;#FFFFFF;#000000]",
- "tooltip[0.2,3.8;3,0.75;p_type: Defines what the p_value stands for.\n\n",
- "item: requires the user to have this item in the inventory\n",
- "quest: requires the user to have completed a quest with this id\n",
- "function: executes the given LUA function which must return true or false. true = prerequisite met\n",
- "auto: ???\n",
- "delete: Deletes the chosen prerequiste when the dialog is saved",
- ";#FFFFFF;#000000]",
- "tooltip[p_value;p_value: This is evaluated to decide whether the prerequisites are met or not;#FFFFFF;#000000]",
- "tooltip[0.2,5;3,0.75;r_id: Result Id;#FFFFFF;#000000]",
- "tooltip[0.2,6;3,0.75;r_type: Defines what the r_value stands for.\n\n",
- "dialog: forwards the user to the given dialog d_id\n",
- "item: places this item in the inventory of the user\n",
- "quest: starts a quest with this id for the user\n",
- "function: executes the given LUA function\n",
- "auto: automatically forwards the user to the given dialog d_id after a given time\n",
- "delete: Deletes the chosen prerequiste when the dialog is saved",
- ";#FFFFFF;#000000]",
- "tooltip[r_value;r_value: This is what happens when the user chooses this option;#FFFFFF;#000000]"
- }
-
- return table.concat(formspec, "")
-end
-
-
--- receive fields
-
--- options
-
-
-yl_speak_up.input_optiondialog = function(player, formname, fields)
- if formname ~= "yl_speak_up:optiondialog" then
- return
- end
- if(not(minetest.check_player_privs(player, {npc_master=true}))) then
- return
- end
-
- local pname = player:get_player_name()
- local n_id = yl_speak_up.speak_to[pname].n_id
- local d_id = yl_speak_up.speak_to[pname].d_id
- local dialog = yl_speak_up.speak_to[pname].dialog
-
- if fields then
- -- Button Cancel: Exit the form
- if fields.button_back or fields.quit then
- local temp_dialog = yl_speak_up.speak_to[pname].dialog
-
- yl_speak_up.speak_to[pname] = {}
-
- yl_speak_up.speak_to[pname].dialog = temp_dialog
- yl_speak_up.speak_to[pname].n_id = n_id
- yl_speak_up.speak_to[pname].d_id = d_id
-
- yl_speak_up.show_fs(player, "setdialog", {n_id = n_id, d_id = d_id})
- return
- end
-
- -- Button Delete Option: Delete option dialog, but do not exit
- if fields.button_delete and fields.d_id and fields.o_id ~= yl_speak_up.text_new_option_id then
- local temp_dialog = yl_speak_up.speak_to[pname].dialog
-
- yl_speak_up.speak_to[pname] = {}
-
- yl_speak_up.speak_to[pname].dialog = temp_dialog
- yl_speak_up.speak_to[pname].n_id = n_id
- yl_speak_up.speak_to[pname].d_id = d_id
-
- yl_speak_up.speak_to[pname].o_id = yl_speak_up.text_new_option_id
- yl_speak_up.speak_to[pname].p_id = yl_speak_up.text_new_prerequisite_id
- yl_speak_up.speak_to[pname].r_id = yl_speak_up.text_new_result_id
-
- local o_id = yl_speak_up.text_new_option_id
- local p_id = yl_speak_up.text_new_prerequisite_id
- local r_id = yl_speak_up.text_new_result_id
-
- delete_option(fields.n_id, fields.d_id, fields.o_id)
- yl_speak_up.log_change(pname, n_id,
- "(staff) Deleted option "..tostring(fields.o_id).." in dialog "..tostring(fields.d_id)..".")
- yl_speak_up.show_fs(player, "optiondialog",
- {n_id = n_id, d_id = d_id, o_id = o_id, p_id = p_id, r_id = r_id})
- return
- end
-
- if fields.d_text then
- yl_speak_up.speak_to[pname].d_text = fields.d_text
- end
- if fields.d_type then
- yl_speak_up.speak_to[pname].d_type = fields.d_type
- end
-
- -- When a new o_id is chosen, then all the other stuff is invalidated and we need to take values from the dialog or even default values
- if fields.o_id ~= nil and fields.o_id ~= yl_speak_up.speak_to[pname].o_id then
- local o_id = fields.o_id
- yl_speak_up.speak_to[pname].o_id = o_id
- yl_speak_up.speak_to[pname].p_id = yl_speak_up.text_new_prerequisite_id
- yl_speak_up.speak_to[pname].r_id = yl_speak_up.text_new_result_id
-
- -- Depends on the dialog
- if o_id == yl_speak_up.text_new_option_id then --New dialog
- yl_speak_up.speak_to[pname].o_hide = "false"
- yl_speak_up.speak_to[pname].o_grey = "false"
- yl_speak_up.speak_to[pname].o_sort = ""
- yl_speak_up.speak_to[pname].o_met = "Text when conditions are not met"
- yl_speak_up.speak_to[pname].o_not_met = "Text when conditions are met"
- else -- existing dialog
- yl_speak_up.speak_to[pname].o_hide =
- dialog.n_dialogs[d_id].d_options[o_id].o_hide_when_prerequisites_not_met or "false"
- yl_speak_up.speak_to[pname].o_grey =
- dialog.n_dialogs[d_id].d_options[o_id].o_grey_when_prerequisites_not_met or "false"
- yl_speak_up.speak_to[pname].o_sort = dialog.n_dialogs[d_id].d_options[o_id].o_sort or ""
- yl_speak_up.speak_to[pname].o_met =
- dialog.n_dialogs[d_id].d_options[o_id].o_text_when_prerequisites_not_met or
- "Text when conditions are not met"
- yl_speak_up.speak_to[pname].o_not_met =
- dialog.n_dialogs[d_id].d_options[o_id].o_text_when_prerequisites_met or
- "Text when conditions are met"
- end
- else
- if fields.o_hide then
- yl_speak_up.speak_to[pname].o_hide = fields.o_hide
- end
- if fields.o_grey then
- yl_speak_up.speak_to[pname].o_grey = fields.o_grey
- end
- if fields.o_sort then
- yl_speak_up.speak_to[pname].o_sort = fields.o_sort
- end
- if fields.o_met then
- yl_speak_up.speak_to[pname].o_met = fields.o_met
- end
- if fields.o_not_met then
- yl_speak_up.speak_to[pname].o_not_met = fields.o_not_met
- end
-
- if fields.p_id ~= nil and fields.p_id ~= yl_speak_up.speak_to[pname].p_id then
- yl_speak_up.speak_to[pname].p_id = fields.p_id
- yl_speak_up.speak_to[pname].p_value = fields.p_value
- yl_speak_up.speak_to[pname].p_type = fields.p_type
- end
- if fields.p_value then
- yl_speak_up.speak_to[pname].p_value = fields.p_value
- end
- if fields.p_type then
- yl_speak_up.speak_to[pname].p_type = fields.p_type
- end
- if fields.r_id ~= nil and fields.r_id ~= yl_speak_up.speak_to[pname].r_id then
- yl_speak_up.speak_to[pname].r_id = fields.r_id
- yl_speak_up.speak_to[pname].r_value = fields.r_value
- yl_speak_up.speak_to[pname].r_type = fields.r_type
- end
- if fields.r_value then
- yl_speak_up.speak_to[pname].r_value = fields.r_value
- end
- if fields.r_type then
- yl_speak_up.speak_to[pname].r_type = fields.r_type
- end
- end
- end
-
- local o_id = fields.o_id or yl_speak_up.speak_to[pname].o_id
- local p_id = fields.p_id or yl_speak_up.speak_to[pname].p_id
- local r_id = fields.r_id or yl_speak_up.speak_to[pname].r_id
-
- -- Button Save
- if fields and fields.button_save and fields.n_id and fields.d_id then
- local temp_dialog = options_to_dialog(pname)
-
- yl_speak_up.save_dialog(n_id, temp_dialog)
- -- TODO: a better change detection would be good - because name, description and owner can change here
- yl_speak_up.log_change(pname, n_id,
- "(staff) Saved dialog "..tostring(fields.d_id)..".")
-
- yl_speak_up.show_fs(player, "optiondialog",
- {n_id = fields.n_id, d_id = fields.d_id, o_id = fields.o_id,
- p_id = fields.p_id, r_id = fields.r_id})
- end
-
- yl_speak_up.show_fs(player, "optiondialog",
- {n_id = n_id, d_id = d_id, o_id = o_id, p_id = p_id, r_id = r_id})
-end
-
--- dialog
-
-yl_speak_up.input_setdialog = function(player, formname, fields)
- if formname ~= "yl_speak_up:setdialog" then
- return
- end
- if(not(minetest.check_player_privs(player, {npc_master=true}))) then
- return
- end
-
- local pname = player:get_player_name()
- local n_id = yl_speak_up.speak_to[pname].n_id
- local d_id = yl_speak_up.speak_to[pname].d_id or yl_speak_up.text_new_dialog_id
-
- -- Button Cancel: Exit the form
- if fields.button_cancel or fields.quit then
- yl_speak_up.speak_to[pname] = nil
- minetest.close_formspec(pname, "yl_speak_up:setdialog")
- return
- end
-
- -- Button Options with valid d_id: Show options formspec
- if fields.button_option and fields.d_id and fields.d_id ~= yl_speak_up.text_new_dialog_id then
- local o_id = yl_speak_up.text_new_option_id
- local p_id = yl_speak_up.text_new_prerequisite_id
- local r_id = yl_speak_up.text_new_result_id
-
- -- Context
- yl_speak_up.speak_to[pname].d_id = fields.d_id
- yl_speak_up.speak_to[pname].o_id = o_id
- yl_speak_up.speak_to[pname].p_id = p_id
- yl_speak_up.speak_to[pname].r_id = r_id
-
- yl_speak_up.show_fs(player, "optiondialog",
- {n_id = n_id, d_id = fields.d_id, o_id = o_id, p_id = p_id, r_id = r_id})
- return
- end
-
- -- Button Options with invalid d_id: Show options formspec
- if fields.button_option and fields.d_id and fields.d_id == yl_speak_up.text_new_dialog_id then
- yl_speak_up.speak_to[pname].d_id = yl_speak_up.text_new_dialog_id
- yl_speak_up.show_fs(player, "msg", {input_to = "yl_speak_up:optiondialog",
- formspec = yl_speak_up.get_error_message()})
- return
- end
-
- -- Button Save: Save the settings, but do not exit
- if fields.button_save and fields.d_id then
- local dialog = yl_speak_up.fields_to_dialog(pname, fields)
- yl_speak_up.save_dialog(n_id, dialog)
- -- TODO: a better change detection would be great (name, description, owner can be changed as well)
- yl_speak_up.log_change(pname, n_id,
- "(staff) Saved dialog "..tostring(fields.d_id)..".")
- yl_speak_up.speak_to[pname].dialog = dialog
-
- if yl_speak_up.speak_to[pname].obj then
- local obj = yl_speak_up.speak_to[pname].obj
- local ent = obj:get_luaentity()
- if ent ~= nil then
- ent.yl_speak_up.npc_name = dialog.n_npc
- ent.yl_speak_up.npc_description = dialog.n_description
- ent.owner = dialog.npc_owner
-
- local i_text = dialog.n_npc .. "\n" .. dialog.n_description .. "\n" .. yl_speak_up.infotext
- obj:set_properties({infotext = i_text})
- yl_speak_up.update_nametag(ent)
- end
- end
-
- yl_speak_up.show_fs(player, "setdialog", {n_id = n_id, d_id = d_id})
- return
- end
-
- -- Button Delete: Delete dialog, but do not exit
- if fields.button_delete and fields.d_id then
- yl_speak_up.delete_dialog(n_id, fields.d_id)
- yl_speak_up.speak_to[pname].d_id = yl_speak_up.text_new_dialog_id
- yl_speak_up.show_fs(player, "setdialog", {n_id = n_id, d_id = yl_speak_up.text_new_dialog_id})
- yl_speak_up.log_change(pname, n_id,
- "(staff) Deleted dialog "..tostring(fields.d_id)..".")
- end
-
- -- Change in Dropdown List: Show dialog formspec again with different dialog selected
- if fields.d_id then
- yl_speak_up.speak_to[pname].d_id = fields.d_id
- yl_speak_up.show_fs(player, "setdialog", {n_id = n_id, d_id = fields.d_id})
- end
-end
-
--- Make the NPC talk
-
-function yl_speak_up.config(clicker, npc)
- if not clicker and not clicker:is_player() then
- return
- end
- if not npc then
- return
- end
-
- local npc_id = npc:get_luaentity().yl_speak_up.id
- local n_id = "n_" .. npc_id
- local pname = clicker:get_player_name()
-
- yl_speak_up.speak_to[pname] = {}
- yl_speak_up.speak_to[pname].n_id = n_id -- Memorize which player talks to which NPC
- yl_speak_up.speak_to[pname].d_id = yl_speak_up.text_new_dialog_id -- The only d_id we can rely on existing
- yl_speak_up.speak_to[pname].dialog = yl_speak_up.load_dialog(n_id, false) -- Load the dialog and see what we can do with it
- yl_speak_up.speak_to[pname].obj = npc
-
- -- find out who owns the npc while we still have easy access to the luaentity
- yl_speak_up.npc_owner[ n_id ] = npc:get_luaentity().owner
-
- yl_speak_up.show_fs(clicker, "setdialog", {n_id = n_id, d_id = yl_speak_up.text_new_dialog_id})
-end
-
diff --git a/textures/yl_speak_up_staff_of_dawai_dawai.png b/textures/yl_speak_up_staff_of_dawai_dawai.png
deleted file mode 100644
index b70f7c6..0000000
Binary files a/textures/yl_speak_up_staff_of_dawai_dawai.png and /dev/null differ
diff --git a/textures/yl_speak_up_staff_of_fashion.png b/textures/yl_speak_up_staff_of_fashion.png
deleted file mode 100644
index 23332e0..0000000
Binary files a/textures/yl_speak_up_staff_of_fashion.png and /dev/null differ
diff --git a/textures/yl_speak_up_staff_of_game_over.png b/textures/yl_speak_up_staff_of_game_over.png
deleted file mode 100644
index c08635d..0000000
Binary files a/textures/yl_speak_up_staff_of_game_over.png and /dev/null differ
diff --git a/textures/yl_speak_up_staff_of_i_said_so.png b/textures/yl_speak_up_staff_of_i_said_so.png
deleted file mode 100644
index 9025336..0000000
Binary files a/textures/yl_speak_up_staff_of_i_said_so.png and /dev/null differ
diff --git a/textures/yl_speak_up_staff_of_shut_up.png b/textures/yl_speak_up_staff_of_shut_up.png
deleted file mode 100644
index 790c477..0000000
Binary files a/textures/yl_speak_up_staff_of_shut_up.png and /dev/null differ
diff --git a/tools.lua b/tools.lua
deleted file mode 100644
index f57c899..0000000
--- a/tools.lua
+++ /dev/null
@@ -1,126 +0,0 @@
-
-yl_speak_up.allow_staff_use = function(itemstack, user, pointed_thing)
- local has_priv = minetest.check_player_privs(user, {npc_master=true})
- local p_name = user:get_player_name()
-
- if not has_priv then
- minetest.chat_send_player(p_name,yl_speak_up.message_tool_taken_because_of_lacking_priv)
- -- no special NPC involved
- yl_speak_up.log_change(p_name, nil,
- "User "..p_name..
- " used an admin item: "..itemstack:get_name()..
- " at pos "..minetest.pos_to_string(user:get_pos(),0),
- "action")
- itemstack:take_item(1)
- return
- end
-
- if (pointed_thing.type ~= "object") then
- return
- end
-
- local obj = pointed_thing.ref
- local luaentity = obj:get_luaentity()
-
- -- Is the thing we clicked really one of our NPCs?
- if not(luaentity) or (luaentity and not(luaentity.yl_speak_up)) then
- return
- end
- return obj
-end
-
-
-minetest.register_tool("yl_speak_up:staff_of_i_said_so", {
- description = "Staff of I-said-so",
- inventory_image = "yl_speak_up_staff_of_i_said_so.png",
- on_use = function(itemstack, user, pointed_thing)
-
- local obj = yl_speak_up.allow_staff_use(itemstack, user, pointed_thing)
- if(not(obj)) then
- return itemstack
- end
-
- yl_speak_up.config(user, obj)
- return itemstack
- end
-})
-
-minetest.register_tool("yl_speak_up:staff_of_shut_up", {
- description = "Staff of shut-up",
- inventory_image = "yl_speak_up_staff_of_shut_up.png",
- on_use = function(itemstack, user, pointed_thing)
-
- local obj = yl_speak_up.allow_staff_use(itemstack, user, pointed_thing)
- if(not(obj)) then
- return itemstack
- end
-
- local p_name = user:get_player_name()
- yl_speak_up.set_muted(p_name, obj, true)
-
- return itemstack
- end
-})
-
-minetest.register_tool("yl_speak_up:staff_of_dawai_dawai", {
- description = "Staff of dawai-dawai",
- inventory_image = "yl_speak_up_staff_of_dawai_dawai.png",
- on_use = function(itemstack, user, pointed_thing)
-
- local obj = yl_speak_up.allow_staff_use(itemstack, user, pointed_thing)
- if(not(obj)) then
- return itemstack
- end
-
- local p_name = user:get_player_name()
- yl_speak_up.set_muted(p_name, obj, false)
-
- return itemstack
- end
-})
-
-minetest.register_tool("yl_speak_up:staff_of_game_over", {
- description = "Staff of game-over",
- inventory_image = "yl_speak_up_staff_of_game_over.png",
- on_use = function(itemstack, user, pointed_thing)
-
- local obj = yl_speak_up.allow_staff_use(itemstack, user, pointed_thing)
- if(not(obj)) then
- return itemstack
- end
-
- local p_name = user:get_player_name()
- local luaentity = obj:get_luaentity()
- local npc = luaentity.yl_speak_up.id
-
- minetest.chat_send_player(p_name,"NPC with ID n_"..npc.." removed from position "..
- minetest.pos_to_string(obj:get_pos(),0).." on command of "..p_name)
- yl_speak_up.log_change(p_name, "n_"..tostring(npc),
- "removed with Staff of game-over")
- obj:remove()
- return itemstack
- end
-})
-
-minetest.register_tool("yl_speak_up:staff_of_fashion", {
- description = "Staff of fashion",
- inventory_image = "yl_speak_up_staff_of_fashion.png",
- on_use = function(itemstack, user, pointed_thing)
-
- local obj = yl_speak_up.allow_staff_use(itemstack, user, pointed_thing)
- if(not(obj)) then
- return itemstack
- end
-
- local p_name = user:get_player_name()
- local luaentity = obj:get_luaentity()
- local npc = luaentity.yl_speak_up.id
-
- yl_speak_up.fashion(user, obj)
- minetest.chat_send_player(p_name,"NPC with ID n_"..npc.." will redress at pos "..
- minetest.pos_to_string(obj:get_pos(),0).." on command of "..p_name)
- yl_speak_up.log_change(p_name, "n_"..tostring(npc),
- "changed skin with Staff of fashion")
- return itemstack
- end
-})