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:
parent
954752c9e3
commit
9f82ae5b7b
13
chat.lua
13
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] = {
|
||||
|
9
npc.lua
9
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)
|
||||
|
Loading…
Reference in New Issue
Block a user