Trade: (WIP) Add custom trading dialogues, custom trading offers and code to show the custom trading options.

This commit is contained in:
zorman2000
2017-02-23 07:27:25 -05:00
parent 37d8182bda
commit 1417e35ffb
3 changed files with 184 additions and 32 deletions

11
npc.lua
View File

@ -478,7 +478,10 @@ local function npc_spawn(self, pos)
sell = {},
buy = {},
both = {}
}
},
-- Custom trade allows to specify more than one payment
-- and a custom prompt (instead of the usual buy or sell prompts)
custom_trades = {}
}
-- Initialize trading offers for NPC
@ -559,6 +562,12 @@ local function npc_spawn(self, pos)
npc.trade.generate_trade_offers_by_status(ent)
-- Add a custom trade offer
local offer1 = npc.trade.create_custom_sell_trade_offer("Do you want me to fix your steel sword?", "Fix steel sword", "Fix steel sword", "default:sword_steel", {"default:sword_steel", "default:iron_lump 5"})
table.insert(ent.trader_data.custom_trades, offer1)
local offer2 = npc.trade.create_custom_sell_trade_offer("Do you want me to fix your mese sword?", "Fix mese sword", "Fix mese sword", "default:sword_mese", {"default:sword_mese", "default:copper_lump 10"})
table.insert(ent.trader_data.custom_trades, offer2)
-- npc.add_action(ent, npc.action.stand, {self = ent})
-- npc.add_action(ent, npc.action.stand, {self = ent})
-- npc.add_action(ent, npc.action.walk_step, {self = ent, dir = npc.direction.east})