• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Skipping "Yes" message to travel on boats?

LIINDI

New Member
Joined
Mar 14, 2018
Messages
78
Solutions
1
Reaction score
3
Hey.

Do anyone know how to edit this script so that you don't have to say "Yes" after you've written your destination?

LUA:
-- Travel
local function addTravelKeyword(keyword, cost, destination, action, condition)
    if condition then
        keywordHandler:addKeyword({keyword}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m sorry but I don\'t sail there.'}, condition)
    end
 
    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 = false, cost = cost, discount = 'postman', destination = destination}, nil, action)
        travelKeyword:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, text = 'We would like to serve you some time.', reset = true})
end

So instead it's just:
Hi
Yalahar
*POoof* and you're in yalahar.

Thanks!

*EDIT* Shit didn't see it wasn't allowed to post 2 times in 24hrs. Please remove if i violated that rule.
 
Last edited:
Solution
X
Alright cool im gonna try it soon and let you know. Can i use this on every "Captain" aswell? The same code? The one provided is for Captain Bluebear!
Well in normal Tibia, prices change from boat captain to boat captain, as well as the destinations available.
But sure, you could remove the 'kick' feature, and the 'only premium' feature, and then use it for every boat captain.

-- edit
and if you don't have the postman quest, you can get rid of that part as well.


At it's most basic, you'd be looking at something like this.

LUA:
if msgcontains(msg, "passage") or msgcontains(msg, "sail") then
    selfSay("Passages to City_1, City_2, Yalahar, City_4, City_5.", cid)
elseif msgcontains(msg, "yalahar") then
    local cost = 170...
Hey.

Do anyone know how to edit this script so that you don't have to say "Yes" after you've written your destination?

LUA:
-- Travel
local function addTravelKeyword(keyword, cost, destination, action, condition)
    if condition then
        keywordHandler:addKeyword({keyword}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m sorry but I don\'t sail there.'}, condition)
    end
 
    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 = false, cost = cost, discount = 'postman', destination = destination}, nil, action)
        travelKeyword:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, text = 'We would like to serve you some time.', reset = true})
end

So instead it's just:
Hi
Yalahar
*POoof* and you're in yalahar.

Thanks!

*EDIT* Shit didn't see it wasn't allowed to post 2 times in 24hrs. Please remove if i violated that rule.
You'd have to script the npc in lua instead of with the default npc code.
You could make it more fancy with a table to every destination, but it's not really necessary.
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 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, "passage") or msgcontains(msg, "sail") then
        selfSay("Passages to City_1, City_2, Yalahar, City_4, City_5.", cid)
    elseif msgcontains(msg, "yalahar") then
        if not isPremium(cid) then
            selfSay("Only premium members can fast travel.", cid)
            return true
        end
        local cost = 170
        local destination = {x = 1000, y = 1000, z = 7}
        if getPlayerStorageValue(cid, postman_storage) >= postman_mission_7_value then
            cost = cost - 10
        end
        if getPlayerMoney(cid) >= cost then
            doPlayerRemoveMoney(cid, cost)
            selfSay("Fare travels!", cid)
            doTeleportThing(cid, destination)
        else
            selfSay("You don't have enough money, friend. Travel to Yalahar costs " .. cost .. " gold coins.", cid)
        end
    elseif msgcontains(msg, "kick") then
        local destination = {x = 1000, y = 1000, z = 7}
        doTeleportThing(cid, destination)
    else
        selfSay("I'm sorry but I don't sail there.", cid)
    end
  
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
You'd have to script the npc in lua instead of with the default npc code.
You could make it more fancy with a table to every destination, but it's not really necessary.
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 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, "passage") or msgcontains(msg, "sail") then
        selfSay("Passages to City_1, City_2, Yalahar, City_4, City_5.", cid)
    elseif msgcontains(msg, "yalahar") then
        if not isPremium(cid) then
            selfSay("Only premium members can fast travel.", cid)
            return true
        end
        local cost = 170
        local destination = {x = 1000, y = 1000, z = 7}
        if getPlayerStorageValue(cid, postman_storage) >= postman_mission_7_value then
            cost = cost - 10
        end
        if getPlayerMoney(cid) >= cost then
            doPlayerRemoveMoney(cid, cost)
            selfSay("Fare travels!", cid)
            doTeleportThing(cid, destination)
        else
            selfSay("You don't have enough money, friend. Travel to Yalahar costs " .. cost .. " gold coins.", cid)
        end
    elseif msgcontains(msg, "kick") then
        local destination = {x = 1000, y = 1000, z = 7}
        doTeleportThing(cid, destination)
    else
        selfSay("I'm sorry but I don't sail there.", cid)
    end
 
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Alright cool im gonna try it soon and let you know. Can i use this on every "Captain" aswell? The same code? The one provided is for Captain Bluebear!
 
Alright cool im gonna try it soon and let you know. Can i use this on every "Captain" aswell? The same code? The one provided is for Captain Bluebear!
Well in normal Tibia, prices change from boat captain to boat captain, as well as the destinations available.
But sure, you could remove the 'kick' feature, and the 'only premium' feature, and then use it for every boat captain.

-- edit
and if you don't have the postman quest, you can get rid of that part as well.


At it's most basic, you'd be looking at something like this.

LUA:
if msgcontains(msg, "passage") or msgcontains(msg, "sail") then
    selfSay("Passages to City_1, City_2, Yalahar, City_4, City_5.", cid)
elseif msgcontains(msg, "yalahar") then
    local cost = 170
    local destination = {x = 1000, y = 1000, z = 7}
    if getPlayerMoney(cid) >= cost then
        doPlayerRemoveMoney(cid, cost)
        selfSay("Fare travels!", cid)
        doTeleportThing(cid, destination)
    else
        selfSay("You don't have enough money, friend. Travel to Yalahar costs " .. cost .. " gold coins.", cid)
    end
else
    selfSay("I'm sorry but I don't sail there.", cid)
end
 
Last edited by a moderator:
Solution
Well in normal Tibia, prices change from boat captain to boat captain, as well as the destinations available.
But sure, you could remove the 'kick' feature, and the 'only premium' feature, and then use it for every boat captain.

-- edit
and if you don't have the postman quest, you can get rid of that part as well.


At it's most basic, you'd be looking at something like this.

LUA:
if msgcontains(msg, "passage") or msgcontains(msg, "sail") then
    selfSay("Passages to City_1, City_2, Yalahar, City_4, City_5.", cid)
elseif msgcontains(msg, "yalahar") then
    local cost = 170
    local destination = {x = 1000, y = 1000, z = 7}
    if getPlayerMoney(cid) >= cost then
        doPlayerRemoveMoney(cid, cost)
        selfSay("Fare travels!", cid)
        doTeleportThing(cid, destination)
    else
        selfSay("You don't have enough money, friend. Travel to Yalahar costs " .. cost .. " gold coins.", cid)
    end
else
    selfSay("I'm sorry but I don't sail there.", cid)
end

Thanks alot mate. Gonna try it out later after serversave and let you know if it worked :D

Great Regards
LINDI
 
Well in normal Tibia, prices change from boat captain to boat captain, as well as the destinations available.
But sure, you could remove the 'kick' feature, and the 'only premium' feature, and then use it for every boat captain.

-- edit
and if you don't have the postman quest, you can get rid of that part as well.


At it's most basic, you'd be looking at something like this.

LUA:
if msgcontains(msg, "passage") or msgcontains(msg, "sail") then
    selfSay("Passages to City_1, City_2, Yalahar, City_4, City_5.", cid)
elseif msgcontains(msg, "yalahar") then
    local cost = 170
    local destination = {x = 1000, y = 1000, z = 7}
    if getPlayerMoney(cid) >= cost then
        doPlayerRemoveMoney(cid, cost)
        selfSay("Fare travels!", cid)
        doTeleportThing(cid, destination)
    else
        selfSay("You don't have enough money, friend. Travel to Yalahar costs " .. cost .. " gold coins.", cid)
    end
else
    selfSay("I'm sorry but I don't sail there.", cid)
end

Alright man so i tried it but didn't seem to work. I forgot that in order to use LUA code instead of XML i also needed to change the \data\npc\scripts.. Not only the data\npc xml files.

This is what the xmls look like but they i don't think need editing only the .lua right?

XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Captain Bluebear" script="Captain Bluebear.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100" />
    <look type="129" head="19" body="69" legs="125" feet="50" addons="0" />
</npc>

I should have posted the whole lua script from the beginning instead of just the "travel part" of it because the npc files are already lua format. What i did what change the xml ones to lua and that bugged the whole thing up lol.

Here's the full lua script from Captain Bluebear

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 voices = { {text = 'Passages to Carlin, Ab\'Dendriel, Edron, Venore, Port Hope, Liberty Bay, Yalahar, Roshamuul, Krailos, Oramond and Svargrond.'} }
npcHandler:addModule(VoiceModule:new(voices))

-- Travel
local function addTravelKeyword(keyword, cost, destination, action, condition)
    if condition then
        keywordHandler:addKeyword({keyword}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m sorry but I don\'t sail there.'}, condition)
    end
 
    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 = false, cost = cost, discount = 'postman', destination = destination}, nil, action)
        travelKeyword:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, text = 'We would like to serve you some time.', reset = true})
end

addTravelKeyword('carlin', 110, Position(32387, 31820, 6), function(player) if player:getStorageValue(Storage.postman.Mission01) == 1 then player:setStorageValue(Storage.postman.Mission01, 2) end end)
addTravelKeyword('ab\'dendriel', 130, Position(32734, 31668, 6))
addTravelKeyword('edron', 160, Position(33175, 31764, 6))
addTravelKeyword('venore', 170, Position(32954, 32022, 6))
addTravelKeyword('port hope', 160, Position(32527, 32784, 6))
addTravelKeyword('roshamuul', 210, Position(33494, 32567, 7))
addTravelKeyword('svargrond', 180, Position(32341, 31108, 6))
addTravelKeyword('liberty bay', 180, Position(32285, 32892, 6))
addTravelKeyword('yalahar', 200, Position(32816, 31272, 6), nil, function(player) return player:getStorageValue(Storage.SearoutesAroundYalahar.Thais) ~= 1 and player:getStorageValue(Storage.SearoutesAroundYalahar.TownsCounter) < 5 end)
addTravelKeyword('oramond', 150, Position(33479, 31985, 7))
addTravelKeyword('krailos', 230, Position(33492, 31712, 6))

-- Kick
--keywordHandler:addKeyword({'kick'}, StdModule.kick, {npcHandler = npcHandler, destination = {Position(32320, 32219, 6), Position(32321, 32210, 6)}})

-- Basic
keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, text = 'My name is Captain Bluebear from the Royal Tibia Line.'})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, text = 'I am the captain of this sailing-ship.'})
keywordHandler:addKeyword({'captain'}, StdModule.say, {npcHandler = npcHandler, text = 'I am the captain of this sailing-ship.'})
keywordHandler:addKeyword({'ship'}, StdModule.say, {npcHandler = npcHandler, text = 'The Royal Tibia Line connects all seaside towns of Tibia.'})
keywordHandler:addKeyword({'line'}, StdModule.say, {npcHandler = npcHandler, text = 'The Royal Tibia Line connects all seaside towns of Tibia.'})
keywordHandler:addKeyword({'company'}, StdModule.say, {npcHandler = npcHandler, text = 'The Royal Tibia Line connects all seaside towns of Tibia.'})
keywordHandler:addKeyword({'tibia'}, StdModule.say, {npcHandler = npcHandler, text = 'The Royal Tibia Line connects all seaside towns of Tibia.'})
keywordHandler:addKeyword({'good'}, StdModule.say, {npcHandler = npcHandler, text = 'We can transport everything you want.'})
keywordHandler:addKeyword({'passenger'}, StdModule.say, {npcHandler = npcHandler, text = 'We would like to welcome you on board.'})
keywordHandler:addKeyword({'trip'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Carlin}, {Ab\'Dendriel}, {Venore}, {Port Hope}, {Liberty Bay}, {Svargrond}, {Yalahar}, {Roshamuul}, {Oramond} or {Edron}?'})
keywordHandler:addKeyword({'route'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Carlin}, {Ab\'Dendriel}, {Venore}, {Port Hope}, {Liberty Bay}, {Svargrond}, {Yalahar}, {Roshamuul}, {Oramond} or {Edron}?'})
keywordHandler:addKeyword({'passage'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Carlin}, {Ab\'Dendriel}, {Venore}, {Port Hope}, {Liberty Bay}, {Svargrond}, {Yalahar}, {Roshamuul}, {Oramond} or {Edron}?'})
keywordHandler:addKeyword({'town'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Carlin}, {Ab\'Dendriel}, {Venore}, {Port Hope}, {Liberty Bay}, {Svargrond}, {Yalahar}, {Roshamuul}, {Oramond} or {Edron}?'})
keywordHandler:addKeyword({'destination'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Carlin}, {Ab\'Dendriel}, {Venore}, {Port Hope}, {Liberty Bay}, {Svargrond}, {Yalahar}, {Roshamuul}, {Oramond} or {Edron}?'})
keywordHandler:addKeyword({'sail'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Carlin}, {Ab\'Dendriel}, {Venore}, {Port Hope}, {Liberty Bay}, {Svargrond}, {Yalahar}, {Roshamuul}, {Oramond} or {Edron}?'})
keywordHandler:addKeyword({'go'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Carlin}, {Ab\'Dendriel}, {Venore}, {Port Hope}, {Liberty Bay}, {Svargrond}, {Yalahar}, {Roshamuul}, {Oramond} or {Edron}?'})
keywordHandler:addKeyword({'ice'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m sorry, but we don\'t serve the routes to the Ice Islands.'})
keywordHandler:addKeyword({'senja'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m sorry, but we don\'t serve the routes to the Ice Islands.'})
keywordHandler:addKeyword({'folda'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m sorry, but we don\'t serve the routes to the Ice Islands.'})
keywordHandler:addKeyword({'vega'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m sorry, but we don\'t serve the routes to the Ice Islands.'})
keywordHandler:addKeyword({'darashia'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m not sailing there. This route is afflicted by a ghostship! However I\'ve heard that Captain Fearless from Venore sails there.'})
keywordHandler:addKeyword({'darama'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m not sailing there. This route is afflicted by a ghostship! However I\'ve heard that Captain Fearless from Venore sails there.'})
keywordHandler:addKeyword({'ghost'}, StdModule.say, {npcHandler = npcHandler, text = 'Many people who sailed to Darashia never returned because they were attacked by a ghostship! I\'ll never sail there!'})
keywordHandler:addKeyword({'thais'}, StdModule.say, {npcHandler = npcHandler, text = 'This is Thais. Where do you want to go?'})

npcHandler:setMessage(MESSAGE_GREET, 'Welcome on board, |PLAYERNAME|. Where can I {sail} 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())

</npc>

This is what needs editing. Sorry for the missunderstanding!
 
Back
Top