• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved Latest TFS 1.2 VoiceModule Error on NPC

SlayingWorld

Active Member
Joined
Jan 23, 2014
Messages
156
Reaction score
37
Location
USA
As the title says im using the latest 1.2 forgottenserver and i added a captain npc to travel to place around the map, but when the server loads it it says this error.
Code:
Lua Script Error: [Npc interface]
data/npc/scripts/Soul Captain.lua
data/npc/scripts/Soul Captain.lua:12: attempt to index global 'VoiceModule' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/npc/scripts/Soul Captain.lua:12: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Soul Captain.lua

This is the script for my npc
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

local voices = { {text = 'Fly or sails to Amestris, Forgotten Lands, Pont Vanis, Nilfgaard, Snowhill, Riwen.'} }
npcHandler:addModule(VoiceModule:new(voices))

-- Travel
local function addTravelKeyword(keyword, cost, destination)
    local travelKeyword = keywordHandler:addKeyword({keyword}, StdModule.say, {npcHandler = npcHandler, text = 'Do you seek a passage to ' .. keyword:titleCase() .. ' for |TRAVELCOST|?', cost = cost, discount = 'postman'})
        travelKeyword:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, cost = cost, discount = 'postman', destination = destination})
        travelKeyword:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, text = 'We would like to serve you some time.', reset = true})
end

addTravelKeyword('amestris', 0, Position(1011, 996, 6))
addTravelKeyword('forgotten lands', 0, Position(855, 797, 7))
addTravelKeyword('pont vanis', 0, Position(689, 539, 6))
addTravelKeyword('nilfgaard', 0, Position(535, 315, 6))
addTravelKeyword('snowhill', 0, Position(1322, 1461, 6))
addTravelKeyword('riwen', 0, Position(520, 1397, 6))

-- Basic
keywordHandler:addKeyword({'sail'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Amestris}, {Forgotten Lands}, {Pont Vanis}, {Snowhill}, {Riwen}?'})
keywordHandler:addKeyword({'fly'}, StdModule.say, {npcHandler = npcHandler, text = 'I can only fly to {Nilfgaard} as there is no place for my boat.'})
keywordHandler:addKeyword({'passage'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Amestris}, {Forgotten Lands}, {Pont Vanis}, {Nilfgaard}, {Snowhill}, {Riwen}?'})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, text = 'I am the captain of this ship.'})
keywordHandler:addKeyword({'captain'}, StdModule.say, {npcHandler = npcHandler, text = 'I am the captain of this ship.'})
keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, text = 'My name is Soul Captain from the Soul Society.'})

npcHandler:setMessage(MESSAGE_GREET, 'Welcome on board, |PLAYERNAME|. Where can I {sail} or {fly} you today?')
npcHandler:setMessage(MESSAGE_FAREWELL, 'Good bye. Recommend us if you were satisfied with our service.')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Good bye then.')

npcHandler:addModule(FocusModule:new())

It used to work with an old version of tfs 1.2 but with the latest it doesnt. Not sure if they changed some libraries.
 
I already tried adding the custom modules from ORTS to the LIBS under NPCS, yes i had added the "dofile('data/npc/lib/npcsystem/custommodules.lua')" inside the npc lib to join them up.
 
Okay im getting closer, but i got stuck here. I went ahead and copied the npc libs from ORTS to my ot folder. I just get this error.

Code:
Lua Script Error: [Npc interface]
data/npc/scripts/Soul Captain.lua
data/npc/scripts/Soul Captain.lua:16: attempt to call method 'titleCase' (a nil value)
stack traceback:
        [C]: in function 'titleCase'
        data/npc/scripts/Soul Captain.lua:16: in function 'addTravelKeyword'
        data/npc/scripts/Soul Captain.lua:21: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Soul Captain.lua

Any idea where i can get that lib from ORTS ?
 
Okay im getting closer, but i got stuck here. I went ahead and copied the npc libs from ORTS to my ot folder. I just get this error.

Code:
Lua Script Error: [Npc interface]
data/npc/scripts/Soul Captain.lua
data/npc/scripts/Soul Captain.lua:16: attempt to call method 'titleCase' (a nil value)
stack traceback:
        [C]: in function 'titleCase'
        data/npc/scripts/Soul Captain.lua:16: in function 'addTravelKeyword'
        data/npc/scripts/Soul Captain.lua:21: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Soul Captain.lua

Any idea where i can get that lib from ORTS ?
you need this aswell
https://github.com/orts/server/blob...31814d406d4cb7dcc2bf/data/lib/core/string.lua
 
Thank you sir! Any way i can send you a prostitute via ups?
hahaha i dont think so :'(

Just so you know as well for future reference how to solve this yourself basically
You see this shit
Code:
data/npc/scripts/Soul Captain.lua:16: attempt to call method 'titleCase' (a nil value)
it means that it cannot find the function 'titleCase' so you need to find the function.

If you just had tfs (not ORTS) you would go to the GIT PAGE for tfs 1.2 and up the top where is says "Search this repository" search for 'titleCase' (since you're using ORTS nothing will pop up.

Now if you do the same thing on the ORTS GIT you will see that the top one is the function you were missing (LINK TO SEARCH)

Hope this helps =)
 
Success! Close this thread!
hahaha i dont think so :'(

Just so you know as well for future reference how to solve this yourself basically
You see this shit
Code:
data/npc/scripts/Soul Captain.lua:16: attempt to call method 'titleCase' (a nil value)
it means that it cannot find the function 'titleCase' so you need to find the function.

If you just had tfs (not ORTS) you would go to the GIT PAGE for tfs 1.2 and up the top where is says "Search this repository" search for 'titleCase' (since you're using ORTS nothing will pop up.

Now if you do the same thing on the ORTS GIT you will see that the top one is the function you were missing (LINK TO SEARCH)

Hope this helps =)

Thanks sir! im not using the ORTS im just using the npc captain to travel but i needed orts libs to make it function properly :p But yes i understood clearly! Thanks!
 
Back
Top