View difference between Paste ID: WHjdCY8v and EZwyM42g
SHOW: | | - or go back to the newest paste.
1-
local npc = NPC({
1+
local npc = new NPC("Chondur") -- Loads default, passes name
2-
	name = "Chondur",
2+
3-
	
3+
---- internally, the npc class should have:
4-
	messages = {
4+
name = "Chondur",
5-
		greet = "Be greeted, child. What do you want in an old shaman's hut?",
5+
6-
		farewell = "Good bye.",
6+
messages = { -- this are default. If you just use new NPC(name) it should automatically loads all this pre-defined 
7-
		walkway = "Good bye!",
7+
    greet = "Hello %N. How can I help you today?", -- use format to insert playername in %N
8-
		sendTrade = "Well, I currently buy mysterious and enigmatic voodoo skulls and a few other things I might need for my rituals."
8+
    farewell = "Good bye.",
9-
	},
9+
    walkway = "Good bye!",
10-
	
10+
    trade = "Well, I currently buy mysterious and enigmatic voodoo skulls and a few other things I might need for my rituals.",
11-
	keywords = {
11+
	-- you must define all the default messages here
12-
		["rituals"]  = "Hm. I don't think you need another one of my counterspells to cross the barrier on Goroma.",
12+
},
13-
	},
13+
   
14-
	
14+
keywords = {
15-
	shop = {
15+
	["rituals"]  = {
16-
		{id = 5669,		buy = 0,		sell = 4000,		name= "Mysterious Voodoo Skull"},
16+
		[0] = Hm. I don't think you need another one of my counterspells to cross the barrier on Goroma.",
17-
		{id = 5670,		buy = 0,		sell = 4000,		name= "Enigmatic Voodoo Skull"},
17+
		[1] = Hm. I don't think you need another one of my counterspells to cross the barrier on Goroma."
18-
		{id = 9969,		buy = 0,		sell = 4000,		name= "black skull"},
18+
19-
		{id = 2798,		buy = 0,		sell = 500,			name= "blood herb"},
19+
},
20-
		{id = 9447,		buy = 0,		sell = 10000,		name= "blood goblet"},
20+
   
21
shop = { -- I suppose you used name because of the actual structure but I've never seen one case where people actually used a different name than the one in ID. (furniture maybe?)
22-
})
22+
	[id] = {buy = 0, sell = 4000[, count = 1, type = 0, name = ItemType(id):getName(), actionid = 0]} -- parameters inside [] should be optional, the default values should be the ones mentioned. This table has to be parsed through pairs/next.
23
}
24-
npc.topicHandler:addTopics({
24+
----
25
-- back to the npc file we should have only this for now:
26-
	---stampor mount
26+
local npc = new NPC("Chondur")
27-
	{word = {"mount", "stampor"},
27+
28-
		answer = "You did bring all the items I requqested, cuild. Good. Shall I travel to the spirit realm and try finding a stampor compasion for you?",
28+
npc:setMessage("greet", message)
29-
		
29+
npc:setKeyword("rituals", "Hm. I don't think you need another one of my counterspells to cross the barrier on Goroma."[, topic = 0])
30-
		default = {
30+
npc:addShopItem(...)
31-
			reset = true
31+
npc:removeShopItem(id)
32-
		},
32+
33-
		
33+
-- those are basic functions and this way they are very very easy to be set/removed. See an example of how to implement them:
34-
		condition = {
34+
setMessage:
35-
			topicCondition.notCondition(topicCondition.haveMount(11), "You already have stampor mount.")
35+
if type == "greet" then 
36-
		},
36+
   messages.greet = message
37-
		
37+
elseif ...
38-
		topics = {
38+
39-
			{
39+
setKeyword:
40-
				word = "yes",
40+
keywords[type][topic] = message
41-
				answer = {
41+
42-
					"Ohhhhh Mmmmmmmmmmmm Ammmmmgggggggaaaaaaa ...",
42+
addShopItem:
43-
					"Aaaaaaaaaahhmmmm Mmmaaaaaaaaaa Kaaaaaamaaaa ...",
43+
shop[id] = ...
44-
					"Brrt! I think it worked! It's a male stampor. I linked this spirit to yours. You can probably already summon him to you ...",
44+
45-
					"So, since me are done here... I need to prepare another ritual, so please let me work, child."
45+
removeShopItem:
46-
				},
46+
shop[id] = nil
47-
				
47+
--
48-
				reset = true,
48+
49-
				
49+
--[[Now for topics in long conversation (what is inside Lua files today) you have to keep it simple and dynamic. Use the keywords to create
50-
				condition = {
50+
conversations using the topics.]]
51-
					topicCondition.notCondition(topicCondition.haveMount(11), "You already have stampor mount."),
51+
function onSay(player, message, topic)
52-
					topicCondition.haveItem(13299, 50, "Sorry you don't have the necessary items."),
52+
topic = topic or 0
53-
					topicCondition.haveItem(13301, 30, "Sorry you don't have the necessary items."),
53+
 if keywords[message] then
54-
					topicCondition.haveItem(13300, 100, "Sorry you don't have the necessary items.")
54+
	npc:say(keywords[message][topic])
55-
				},
55+
end
56-
				
56+
57-
				action = {
57+
-- here you manipulate topics to move to other topics
58-
					topicAction.removeItem(13299, 50),
58+
if topic == 1 then...
59-
					topicAction.removeItem(13301, 30),
59+
elseif topic == 2 and getStorage...