diff --git a/dialogue.lua b/dialogue.lua index bfccdef..fa86b0f 100644 --- a/dialogue.lua +++ b/dialogue.lua @@ -42,6 +42,7 @@ function npc.dialogue.show_options_dialogue(self, is_married_dialogue, is_casual_trade_dialogue, casual_trade_type, + is_dedicated_trade_prompt, dismiss_option_label, player_name) local options_length = table.getn(responses) + 1 @@ -65,6 +66,7 @@ function npc.dialogue.show_options_dialogue(self, is_married_dialogue = is_married_dialogue, is_casual_trade_dialogue = is_casual_trade_dialogue, casual_trade_type = casual_trade_type, + is_dedicated_trade_prompt = is_dedicated_trade_prompt, options = responses } @@ -182,6 +184,13 @@ function npc.dialogue.start_dialogue(self, player, show_married_dialogue) return end + -- Show options dialogue for dedicated trader + if self.trader_data.trader_status == npc.trade.TRADER then + dialogue = npc.trade.DEDICATED_TRADER_PROMPT + npc.dialogue.process_dialogue(self, dialogue, player:get_player_name()) + return + end + local chance = math.random(1, 100) minetest.log("Chance: "..dump(chance)) if chance < 30 then @@ -261,6 +270,7 @@ function npc.dialogue.process_dialogue(self, dialogue, player_name) dialogue.is_married_dialogue, dialogue.casual_trade_type ~= nil, dialogue.casual_trade_type, + dialogue.is_dedicated_trade_prompt, npc.dialogue.NEGATIVE_ANSWER_LABEL, player_name ) @@ -417,6 +427,12 @@ minetest.register_on_player_receive_fields(function (player, formname, fields) .responses[player_response.options[i].response_id] .action(player_response.npc, player) end + return + elseif player_response.is_dedicated_trade_prompt == true then + -- Get the functions for a dedicated trader prompt + npc.trade.DEDICATED_TRADER_PROMPT + .responses[player_response.options[i].response_id] + .action(player_response.npc, player) return else -- Get dialogues for sex and phase diff --git a/trade/trade.lua b/trade/trade.lua index 12a7e5c..f3d6e50 100644 --- a/trade/trade.lua +++ b/trade/trade.lua @@ -48,6 +48,29 @@ npc.trade.CASUAL_TRADE_SELL_DIALOGUE = { } } +-- Dedicated trade dialogue prompt +npc.trade.DEDICATED_TRADER_PROMPT = { + text = "Hello there, would you like to trade?", + is_dedicated_trade_prompt = true, + responses = { + [1] = { + text = "Buy", + action_type = "function", + response_id = 1, + action = function(self, player) + end + }, + [2] = { + text = "Sell", + action_type = "function", + response_id = 2, + action = function(self, player) + + end + } + } +} + function npc.trade.show_trade_offer_formspec(self, player, offer_type) -- Strings for formspec, to include international support later @@ -171,6 +194,15 @@ function npc.trade.get_casual_trade_offer(self, offer_type) return result end +-- The following function create buy and sell offers for dedicated traders, +-- based on the trader list and the source of items. Initially, it will only +-- be NPC inventories. In the future, it should support both NPC and chest +-- inventories, +function npc.trade.get_trade_offers_for_dedicated_trader(self) + + +end + -- Creates a trade offer based on the offer type, given item and count. If -- the offer is a "buy" offer, it is required to provide the price item and -- the minimum price item count.