From 9f82ae5b7b312a0fc0b435d987a5a8729fb8f83a Mon Sep 17 00:00:00 2001 From: zorman2000 Date: Thu, 1 Dec 2016 09:26:57 -0500 Subject: [PATCH] Dialogues: Changed prompt for yes/no dialogue to show on formspec instad of sent as message. Added item name now when giving a gift to NPC. Positive answer for yes/no dialogue is now a constant. --- chat.lua | 13 +++++-------- npc.lua | 9 +++++++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/chat.lua b/chat.lua index 6b7aeaa..f864020 100644 --- a/chat.lua +++ b/chat.lua @@ -24,11 +24,9 @@ -- chatline2 = { text = "Q2", options = nil } -- } -local options = {"Question 1","Question 2","Question 3","Question 4"} - npc.dialogue = {} -npc.dialogue.YES_GIFT_ANSWER_LABEL_PREFIX = "Yes, give " +npc.dialogue.POSITIVE_GIFT_ANSWER_PREFIX = "Yes, give " npc.dialogue.NEGATIVE_ANSWER_LABEL = "Nevermind" -- This table contains the answers of dialogue boxes @@ -61,12 +59,11 @@ function npc.dialogue.show_yes_no_dialogue(prompt, negative_answer_label, negative_callback, player_name) - -- Send prompt message to player - minetest.chat_send_player(player_name, prompt) - local formspec = "size[7,2.4]".. - "button_exit[0.5,0.65;6,0.5;yes_option;"..positive_answer_label.."]".. - "button_exit[0.5,1.45;6,0.5;no_option;"..negative_answer_label.."]" + local formspec = "size[7,3]".. + "label[0.5,0.1;"..prompt.."]".. + "button_exit[0.5,1.15;6,0.5;yes_option;"..positive_answer_label.."]".. + "button_exit[0.5,1.95;6,0.5;no_option;"..negative_answer_label.."]" -- Create entry into responses table npc.dialogue.dialogue_results.yes_no_dialogue[1] = { diff --git a/npc.lua b/npc.lua index f269d40..c885fe7 100755 --- a/npc.lua +++ b/npc.lua @@ -602,10 +602,15 @@ mobs:register_mob("advanced_npc:npc", { -- Receive gift or start chat. If player has no item in hand -- then it is going to start chat directly if self.can_have_relationship and item:to_table() ~= nil then + -- Get item name + local item = minetest.registered_items[item:get_name()] + local item_name = item.description + minetest.log(dump(npc.dialogue.POSITIVE_GIFT_ANSWER_PREFIX)) + minetest.log(dump(item_name)) -- Show dialogue to confirm that player is giving item as gift npc.dialogue.show_yes_no_dialogue( - "Do you want to give this item to "..self.nametag.."?", - "Yes, I want to give it!", + "Do you want to give "..item_name.." to "..self.nametag.."?", + npc.dialogue.POSITIVE_GIFT_ANSWER_PREFIX..item_name, function() if receive_gift(self, clicker) == false then start_chat(self, clicker)