Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local npc = new NPC("Chondur") -- Loads default, passes name
- ---- internally, the npc class should have:
- name = "Chondur",
- messages = { -- this are default. If you just use new NPC(name) it should automatically loads all this pre-defined
- greet = "Hello %N. How can I help you today?", -- use format to insert playername in %N
- farewell = "Good bye.",
- walkway = "Good bye!",
- trade = "Well, I currently buy mysterious and enigmatic voodoo skulls and a few other things I might need for my rituals.",
- -- you must define all the default messages here
- },
- keywords = {
- ["rituals"] = {
- [0] = Hm. I don't think you need another one of my counterspells to cross the barrier on Goroma.",
- [1] = Hm. I don't think you need another one of my counterspells to cross the barrier on Goroma."
- }
- },
- 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?)
- [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.
- }
- ----
- -- back to the npc file we should have only this for now:
- local npc = new NPC("Chondur")
- npc:setMessage("greet", message)
- npc:setKeyword("rituals", "Hm. I don't think you need another one of my counterspells to cross the barrier on Goroma."[, topic = 0])
- npc:addShopItem(...)
- npc:removeShopItem(id)
- -- those are basic functions and this way they are very very easy to be set/removed. See an example of how to implement them:
- setMessage:
- if type == "greet" then
- messages.greet = message
- elseif ...
- setKeyword:
- keywords[type][topic] = message
- addShopItem:
- shop[id] = ...
- removeShopItem:
- shop[id] = nil
- --
- --[[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
- conversations using the topics.]]
- function onSay(player, message, topic)
- topic = topic or 0
- if keywords[message] then
- npc:say(keywords[message][topic])
- end
- -- here you manipulate topics to move to other topics
- if topic == 1 then...
- elseif topic == 2 and getStorage...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement