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.
This commit is contained in:
zorman2000 2016-12-01 09:26:57 -05:00
parent 954752c9e3
commit 9f82ae5b7b
2 changed files with 12 additions and 10 deletions

View File

@ -24,11 +24,9 @@
-- chatline2 = { text = "Q2", options = nil } -- chatline2 = { text = "Q2", options = nil }
-- } -- }
local options = {"Question 1","Question 2","Question 3","Question 4"}
npc.dialogue = {} 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" npc.dialogue.NEGATIVE_ANSWER_LABEL = "Nevermind"
-- This table contains the answers of dialogue boxes -- This table contains the answers of dialogue boxes
@ -61,12 +59,11 @@ function npc.dialogue.show_yes_no_dialogue(prompt,
negative_answer_label, negative_answer_label,
negative_callback, negative_callback,
player_name) player_name)
-- Send prompt message to player
minetest.chat_send_player(player_name, prompt)
local formspec = "size[7,2.4]".. local formspec = "size[7,3]"..
"button_exit[0.5,0.65;6,0.5;yes_option;"..positive_answer_label.."]".. "label[0.5,0.1;"..prompt.."]"..
"button_exit[0.5,1.45;6,0.5;no_option;"..negative_answer_label.."]" "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 -- Create entry into responses table
npc.dialogue.dialogue_results.yes_no_dialogue[1] = { npc.dialogue.dialogue_results.yes_no_dialogue[1] = {

View File

@ -602,10 +602,15 @@ mobs:register_mob("advanced_npc:npc", {
-- Receive gift or start chat. If player has no item in hand -- Receive gift or start chat. If player has no item in hand
-- then it is going to start chat directly -- then it is going to start chat directly
if self.can_have_relationship and item:to_table() ~= nil then 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 -- Show dialogue to confirm that player is giving item as gift
npc.dialogue.show_yes_no_dialogue( npc.dialogue.show_yes_no_dialogue(
"Do you want to give this item to "..self.nametag.."?", "Do you want to give "..item_name.." to "..self.nametag.."?",
"Yes, I want to give it!", npc.dialogue.POSITIVE_GIFT_ANSWER_PREFIX..item_name,
function() function()
if receive_gift(self, clicker) == false then if receive_gift(self, clicker) == false then
start_chat(self, clicker) start_chat(self, clicker)