1--[[
2 ***************************************************************************
3 *                       Copyright © 2020 - Arianne                        *
4 ***************************************************************************
5 ***************************************************************************
6 *                                                                         *
7 *   This program is free software; you can redistribute it and/or modify  *
8 *   it under the terms of the GNU General Public License as published by  *
9 *   the Free Software Foundation; either version 2 of the License, or     *
10 *   (at your option) any later version.                                   *
11 *                                                                         *
12 ***************************************************************************
13]]
14
15
16local brokerName = "Sawyer"
17local broker = nil
18local shopName = "deniranpawnbuy"
19
20local function initNPC()
21	broker = entities:createSpeakerNPC(brokerName)
22	broker:setOutfit("body=0,head=0,eyes=3,hair=14,dress=5,hat=11")
23	broker:setOutfitColor("body", SkinColor.DARK)
24	broker:setOutfitColor("eyes", 0x0000ff)
25	broker:setPosition(18, 5)
26	broker:setIdleDirection(Direction.LEFT)
27	broker:setDescription("You see " .. brokerName ..". He owns and runs the pawn shop.")
28
29	-- dialogue
30	broker:addGreeting("Welcome to the Deniran Pawn Shop.")
31	broker:addGoodbye()
32	broker:addHelp("If you want to pawn something, check my blackboard for a list of what I buy.")
33	broker:addJob("I own this pawn shop. If you want to sell something, check my blackboard for a list of what I buy.")
34	broker:addQuest("Well... I don't have anything you can help me with right now.")
35	broker:addOffer("Please check the blackboard for a list of items that I buy.")
36
37	game:add(broker)
38end
39
40local function initShop()
41	merchants:addBuyer(broker, merchants.shops:get(shopName), false)
42
43	-- shop sign
44	local sign = entities:createShopSign(shopName, "Deniran Pawn Shop", brokerName .. " buys the following items", false)
45	sign:setEntityClass("blackboard")
46	sign:setPosition(18, 8)
47
48	game:add(sign);
49end
50
51
52local zone = "int_deniran_pawn_shop"
53
54if game:setZone(zone) then
55	initNPC()
56	if broker ~= nil then
57		initShop()
58	end
59else
60	logger:error("Could not set zone: " .. zone)
61end
62