Error:
[07/05/2010 19:47:18] [Error - Npc interface]
[07/05/2010 19:47:18] data/npc/scripts/oracle.lua
[07/05/2010 19:47:18] Description:
[07/05/2010 19:47:18] data/npc/scripts/oracle.lua:97: attempt to index global 'city1' (a nil value)
[07/05/2010 19:47:18] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/oracle.lua
[07/05/2010 19:47:18] [Error - Npc interface]
[07/05/2010 19:47:18] data/npc/scripts/oracle.lua
[07/05/2010 19:47:18] Description:
[07/05/2010 19:47:18] data/npc/scripts/oracle.lua:97: attempt to index global 'city1' (a nil value)
[07/05/2010 19:47:18] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/oracle.lua
Code:
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
function oracle(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
local cityNode = node:getParent():getParent()
local vocNode = node:getParent()
local destination = cityNode:getParameters().destination
local town = cityNode:getParameters().town
local vocation = vocNode:getParameters().vocation
if(destination ~= nil and vocation ~= nil and town ~= nil) then
if(getPlayerLevel(cid) < parameters.level) then
npcHandler:say('You must first reach level ' .. parameters.level .. '!', cid)
npcHandler:resetNpc()
else
if(getPlayerVocation(cid) > 0) then
npcHandler:say('Sorry, You already have a vocation!')
npcHandler:resetNpc()
else
doPlayerSetVocation(cid, vocation)
doPlayerSetTown(cid, town)
npcHandler:resetNpc()
local tmp = getCreaturePosition(cid)
doTeleportThing(cid, destination)
doSendMagicEffect(tmp, CONST_ME_POFF)
doSendMagicEffect(destination, CONST_ME_TELEPORT)
end
end
end
return true
end
function greetCallback(cid)
--!!Config!!--
--Vocation setup
local vocation1 = {name = "sorcerer", id = 1,
text = "Are you sure that a "..vocation1.name.." is what you wish to become? This decision is irreversible!"}
local vocation2 = {name = "druid", id = 2,
text = "Are you sure that a "..vocation2.name.." is what you wish to become? This decision is irreversible!"}
local vocation3 = {name = "paladin", id = 3,
text = "Are you sure that a "..vocation3.name.." is what you wish to become? This decision is irreversible!"}
local vocation4 = {name = "knight", id = 4,
text = "Are you sure that a "..vocation4.name.." is what you wish to become? This decision is irreversible!"}
--Start Town setup
local city1 = {name = "avondale", townID = 1, destination = {x=702, y=1016, z=7},
text = "Avondale, eh? So what vocation do you wish to become? {"..vocation1.name .."}, {"..vocation2.name .."}, {"..vocation3.name .."} or {"..vocation4.name .."}?"}
local city2 = {name = "calria", townID = 2, destination = {x=1153, y=1139, z=7},
text = "Thais, eh? So what vocation do you wish to become? {"..vocation1.name .."}, {"..vocation2.name .."}, {"..vocation3.name .."} or {"..vocation4.name .."}?"}
local towntext = "What city do you wish to live in? {".. city1.name .."}, {".. city2.name .."}?"
--Text setup
local requiredlevel = 8
local greet = "Hello |PLAYERNAME|. Are you prepared to face your destiny?"
local lowlevel = "COME BACK WHEN YOU ARE LEVEL 8!"
local refuse = "Then come back when you are ready."
local refuse_voc = "Then what vocation do you want to become?"
---------
if(getPlayerLevel(cid) < requiredlevel) then
npcHandler:say(lowlevel)
return false
else
return true
end
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setMessage(MESSAGE_GREET, greet)
local yesNode = KeywordNode:new({'yes'}, oracle, {level = requiredlevel})
local noNode = KeywordNode:new({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = refuse_voc})
local node1 = keywordHandler:addKeyword({'yes'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = towntext})
--City 1 control
local node2 = node1:addChildKeyword(city1.name, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, town = city1.townID, destination = city1.destination, text = city1.text})
local node3 = node2:addChildKeyword(vocation1.name, StdModule.say, {npcHandler = npcHandler, vocation = vocation1.id, onlyFocus = true, text = vocation1.text})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
node3 = node2:addChildKeyword(vocation2.name, StdModule.say, {npcHandler = npcHandler, vocation = vocation2.id, onlyFocus = true, text = vocation2.text})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
node3 = node2:addChildKeyword(vocation3.name, StdModule.say, {npcHandler = npcHandler, vocation = vocation3.id, onlyFocus = true, text = vocation3.text})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
node3 = node2:addChildKeyword(vocation4.name, StdModule.say, {npcHandler = npcHandler, vocation = vocation4.id, onlyFocus = true, text = vocation4.text})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
--City 2 control
node2 = node1:addChildKeyword(city2.name, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, town = city2.townID, destination = city2.destination, text = city2.text})
node3 = node2:addChildKeyword(vocation1.name, StdModule.say, {npcHandler = npcHandler, vocation = vocation1.id, onlyFocus = true, text = vocation1.text})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
node3 = node2:addChildKeyword(vocation2.name, StdModule.say, {npcHandler = npcHandler, vocation = vocation2.id, onlyFocus = true, text = vocation2.text})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
node3 = node2:addChildKeyword(vocation3.name, StdModule.say, {npcHandler = npcHandler, vocation = vocation3.id, onlyFocus = true, text = vocation3.text})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
node3 = node2:addChildKeyword(vocation4.name, StdModule.say, {npcHandler = npcHandler, vocation = vocation4.id, onlyFocus = true, text = vocation4.text})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
keywordHandler:addKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = refuse})
npcHandler:addModule(FocusModule:new())