- Joined
- Nov 17, 2010
- Messages
- 6,795
- Solutions
- 581
- Reaction score
- 5,359
I use the below script for the starting of all of my npc's.
I want to change their default text behaviour, but I don't understand the npc system well enough to alter it.
I found the below/below information in data/npc/lib/npcsystem/npchandler.lua
However this obviously changes it for every npc, and not just npc to npc.
I've attempted to integrate that section into my actual npc, however my attempts are laughable at best, as I have no idea why, how, or where to place it, or even if that is the correct approach.
Can someone point me in the right direction?
Cheers,
Xikini
I want to change their default text behaviour, but I don't understand the npc system well enough to alter it.
I found the below/below information in data/npc/lib/npcsystem/npchandler.lua
However this obviously changes it for every npc, and not just npc to npc.
I've attempted to integrate that section into my actual npc, however my attempts are laughable at best, as I have no idea why, how, or where to place it, or even if that is the correct approach.
Can someone point me in the right direction?
Cheers,
Xikini
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Test Npc" script="data/npc/scripts/test.lua" walkinterval="500" floorchange="0">
<health now="100" max="100"/>
<look type="132" head="57" body="0" legs="0" feet="56" addons="2"/>
</npc>
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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
function getNpcName()
return getCreatureName(getNpcId())
end
function greet(cid)
talkState[cid] = 0
return true
end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if msgcontains(msg, "job") then
selfSay("I am a test Npc.", cid)
talkState[talkUser] = 0
elseif msgcontains(msg, "name") then
selfSay("My name is " .. getNpcName() .. ".", cid)
talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_GREET, greet)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Lua:
messages = {
-- These are the default replies of all npcs. They can/should be changed individually for each npc.
[MESSAGE_GREET] = 'Welcome, |PLAYERNAME|! I have been expecting you.',
[MESSAGE_FAREWELL] = 'Good bye, |PLAYERNAME|!',
[MESSAGE_BUY] = 'Do you want to buy |ITEMCOUNT| |ITEMNAME| for |TOTALCOST| gold coins?',
[MESSAGE_ONBUY] = 'It was a pleasure doing business with you.',
[MESSAGE_BOUGHT] = 'Bought |ITEMCOUNT|x |ITEMNAME| for |TOTALCOST| gold.',
[MESSAGE_SELL] = 'Do you want to sell |ITEMCOUNT| |ITEMNAME| for |TOTALCOST| gold coins?',
[MESSAGE_ONSELL] = 'Thank you for this |ITEMNAME|, |PLAYERNAME|.',
[MESSAGE_SOLD] = 'Sold |ITEMCOUNT|x |ITEMNAME| for |TOTALCOST| gold.',
[MESSAGE_MISSINGMONEY] = 'Sorry, you don\'t have enough money.',
[MESSAGE_MISSINGITEM] = 'You don\'t even have that item, |PLAYERNAME|!',
[MESSAGE_NEEDMONEY] = 'You do not have enough money.',
[MESSAGE_NEEDITEM] = 'You do not have this object.',
[MESSAGE_NEEDSPACE] = 'You do not have enough capacity.',
[MESSAGE_NEEDMORESPACE] = 'You do not have enough capacity for all items.',
[MESSAGE_IDLETIMEOUT] = 'Next, please!',
[MESSAGE_WALKAWAY] = 'How rude!',
[MESSAGE_DECLINE] = 'Not good enough, is it... ?',
[MESSAGE_SENDTRADE] = 'Here\'s my offer, |PLAYERNAME|. Don\'t you like it?',
[MESSAGE_NOSHOP] = 'Sorry, I\'m not offering anything.',
[MESSAGE_ONCLOSESHOP] = 'Thank you, come back when you want something more.',
[MESSAGE_ALREADYFOCUSED]= '|PLAYERNAME|! I am already talking to you...',
[MESSAGE_PLACEDINQUEUE] = '|PLAYERNAME|, please wait for your turn. There are |QUEUESIZE| customers before you.'
}