I'm currently working on a new NPC system that I'm maybe going to release. I want you to share your suggestions about it and maybe tell me how I can improve it.
Here is an example of how a NPC script might look like:
All variables are optional and it's easy for you to add new ones too.
You can see how you can add your own keywords, inside every keyword it can be two tables, "require" and "do". Everything inside the table "require" is required to do everything inside the table "do".
Here is an example of how a NPC script might look like:
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
function creatureSayCallback(cid, type, msg)
quest = {
["mission"] = {
reuqire = {
vocation = {id = 1, promotion = 1, error = "You\'re not a master sorcerer."},
level = {value = 400, error = "You need to be level 400."},
storage = {id = 3000, value = 1, get = "equal_or_higher"}
}
do = {
sendMsg = {"Okay", "Do you want a mission?"}, -- Send multiple messages.
setState = 1
}
["yes"] = {
if talk_state == 1 then
do = {
sendMsg = {"Too bad, I don\'t have any. lol"}
if yes == yes then
doSendMagicEffect(getCreaturePosition(cid), 2) -- You can also add own functions that doesn't exsist on the npc system.
end
setState = 0
}
else
npcHandler:say("What \"yes\"? I didn\'t even ask anything.", cid)
end
}
}
setQuestNpc(cid, msg, quest, talk_state)
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
All variables are optional and it's easy for you to add new ones too.
You can see how you can add your own keywords, inside every keyword it can be two tables, "require" and "do". Everything inside the table "require" is required to do everything inside the table "do".