Advertisement
Guest User

Untitled

a guest
Jan 18th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local npc = new NPC("Chondur") -- Loads default, passes name
  2.  
  3. ---- internally, the npc class should have:
  4. name = "Chondur",
  5.  
  6. messages = { -- this are default. If you just use new NPC(name) it should automatically loads all this pre-defined
  7.     greet = "Hello %N. How can I help you today?", -- use format to insert playername in %N
  8.     farewell = "Good bye.",
  9.     walkway = "Good bye!",
  10.     trade = "Well, I currently buy mysterious and enigmatic voodoo skulls and a few other things I might need for my rituals.",
  11.     -- you must define all the default messages here
  12. },
  13.    
  14. keywords = {
  15.     ["rituals"]  = {
  16.         [0] = Hm. I don't think you need another one of my counterspells to cross the barrier on Goroma.",
  17.         [1] = Hm. I don't think you need another one of my counterspells to cross the barrier on Goroma."
  18.     }
  19. },
  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.     [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. ----
  25. -- back to the npc file we should have only this for now:
  26. local npc = new NPC("Chondur")
  27.  
  28. npc:setMessage("greet", message)
  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. npc:addShopItem(...)
  31. npc:removeShopItem(id)
  32.  
  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. setMessage:
  35. if type == "greet" then
  36.   messages.greet = message
  37. elseif ...
  38.  
  39. setKeyword:
  40. keywords[type][topic] = message
  41.  
  42. addShopItem:
  43. shop[id] = ...
  44.  
  45. removeShopItem:
  46. shop[id] = nil
  47. --
  48.  
  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. conversations using the topics.]]
  51. function onSay(player, message, topic)
  52. topic = topic or 0
  53. if keywords[message] then
  54.     npc:say(keywords[message][topic])
  55. end
  56.  
  57. -- here you manipulate topics to move to other topics
  58. if topic == 1 then...
  59. elseif topic == 2 and getStorage...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement