• 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!

Action Moving Boat

Will be used on my TFS 1.0 Projects for sure! :D

Kind Regards,
Eldin.
 
I am missing the doTravel function. Anyone care to share it? id rather not try to figure it out myself as it is a bit over my coding boundrys
 
Yes it says its a nil value

TFS 0.3.6

Code:
local config = {
   endborders = {1284,1284},
   speed = 300,
   ignorefirstborders = 3
}

local fight = createConditionObject(CONDITION_INFIGHT)
setConditionParam(fight, CONDITION_PARAM_TICKS, -1)

local function comparePos(poss, pos)
     return pos.x == poss.x and pos.y == poss.y
end

local n, s = 0, 0

local function getRightPos(poss, last)

     ps = {
         {x = poss.x, y = poss.y - 1, z = poss.z},
         {x = poss.x + 1, y = poss.y, z = poss.z},
         {x = poss.x, y = poss.y + 1, z = poss.z},
         {x = poss.x - 1, y = poss.y, z = poss.z}
     }
     for _, pos in pairs(ps) do
         if(getTileItemById(pos, 4820).uid > 0) then
             if(not comparePos(last, pos)) then
                 p = pos
                 return p
             end
         else
             for b = 1, #config.endborders do
                 if(getTileItemById(pos, config.endborders[b]).uid > 0 and s > config.ignorefirstborders) then
                     n = n + 1
                     p = pos
                     return p and n
                 end
             end
         end
     end
end

local function doTravel(cid, poss, last)

     getRightPos(poss, last)
     travel = p.x > poss.x and "east" or (p.y < poss.y and "north" or (p.y > poss.y and "south" or (p.x < poss.x and "west" or "false")))
     if n > 1 then
         p = poss
     end
     if(travel == "false") then
        if(getCreatureCondition(cid, CONDITION_INFIGHT)) then
             doRemoveCondition(cid, CONDITION_INFIGHT)
         end
         n = 0
         s = 0
         return false
     end

     local des = {
         ["north"] = {cPos = {{x = p.x, y = p.y - 1, z = p.z}, p, {x = p.x, y = p.y + 1, z = p.z}}, dir = 0, boat = {3587, 3589, 3591}},
         ["east"] = {cPos = {{x = p.x + 1, y = p.y, z = p.z}, p, {x = p.x - 1, y = p.y, z = p.z}}, dir = 1, boat = {3596, 3594, 3592}},
         ["south"] = {cPos = {{x = p.x, y = p.y + 1, z = p.z}, p, {x = p.x, y = p.y - 1, z = p.z}}, dir = 2, boat = {3591, 3589, 3587}},
         ["west"] = {cPos = {{x = p.x - 1, y = p.y, z = p.z}, p, {x = p.x + 1, y = p.y, z = p.z}}, dir = 3, boat = {3592, 3594, 3596}}
     }

     local x = des[travel]
     if(x) then
         for x = p.x - 2, p.x + 2 do
             for y = p.y - 2, p.y + 2 do
                 pos = {x = x, y = y, z = p.z}
                 for id = 3587, 3596 do
                     if(getTileItemById(pos, id).uid > 0) then
                         doRemoveItem(getTileItemById(pos, id).uid, 1)
                     end
                 end
             end
         end
         for c = 1, #x.boat do
             its = doCreateItem(x.boat[c], 1, x.cPos[c])
             if(n > 0 and c == 2) then
                 doSetItemActionId(its, 6901)
             end
         end
         doTeleportThing(cid, x.cPos[2], false)
         doCreatureSetLookDir(cid, x.dir)
         if(n > 1) then
             if(getCreatureCondition(cid, CONDITION_INFIGHT)) then
                 doRemoveCondition(cid, CONDITION_INFIGHT)
             end
             n = 0
             s = 0
             return false
         end
         s = s + 1
     end
     return addEvent(doTravel, config.speed, cid, p, poss)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)

     if(getCreatureCondition(cid, CONDITION_INFIGHT)) then
         return doPlayerSendCancel(cid, "You can't travel when you're in a fight.")
     end
     doTeleportThing(cid, toPosition)
     doAddCondition(cid, fight)
     doTravel(cid, getPlayerPosition(cid), getPlayerPosition(cid))
     return true
end
 
If server restart/close/crash whatever while on boat player will get stuck in water I asume? Should add a no logout area in map editor.
 
On the first page I posted a function people can add to login/logout/preparedeath scripts incase the boat is used to travel to places where people can only go with the boat, this will also teleport the player back when it's on the water.
 
Last edited:
Code:
[Error - Action Interface]
[03/06/2014 14:34:23] data/actions/scripts/other/movingboat.lua:onUse
[03/06/2014 14:34:24] Description:
[03/06/2014 14:34:25] data/actions/scripts/other/movingboat.lua:45: attempt to index global 'p' (a nil value)
[03/06/2014 14:34:25] stack traceback:
[03/06/2014 14:34:26]     data/actions/scripts/other/movingboat.lua:45: in function 'doTravel'
[03/06/2014 14:34:27]     data/actions/scripts/other/movingboat.lua:105: in function <data/actions/scripts/other/movingboat.lua:98>
Im using Linux - Unbuntu 14.0.4 i think is the version. Shouldnt matter but meh
 
This error means it can't find the first water with id 4820, so it can't start. Make sure you have water with that id next to the middle part of the boat.
 
This error means it can't find the first water with id 4820, so it can't start. Make sure you have water with that id next to the middle part of the boat.
That fixed it, thank you. I had a derp moment.. I set the water as Aid 4820 lol
 
[Error - Action Interface]
[03/06/2014 14:34:23] data/actions/scripts/other/movingboat.lua:eek:nUse
[03/06/2014 14:34:24] Description:
[03/06/2014 14:34:25] data/actions/scripts/other/movingboat.lua:##: attempt to index global 'p' (a nil value)
[03/06/2014 14:34:25] stack traceback:
[03/06/2014 14:34:26] data/actions/scripts/other/movingboat.lua:##: in function 'doTravel'
[03/06/2014 14:34:27] data/actions/scripts/other/movingboat.lua:##: in function <data/actions/scripts/other/movingboat.lua:##>

REPLACED all the Numbers with "##". Same Issue with both of the Main Scripts Posted. Using TFS 1.0




EDIT:
Not really sure what all i managed to change but with a few small tweeks i managed to get it to work, if anyone is still having this error, i can post my working script..
 
Last edited:
Tested with TFS 1.0, works fine for me.

You have to set it up in a correct way, using water with itemid 4820 next to the middle part of the boat where you added actionid 6901.
If water with itemid 4820 isn't next to it, you get this error.
kHGWhVV.png

1. actionid 6901
2. itemid 4820
 
Last edited:
my bad, for some reason the itemids kept randomizing, got it to work 100%, u should add a option to let player operate the boat, and only dock at said locations
 
Does the Boat need to be 3 SQM long? can it be any size? Can it Go Down? Can you give me a hand to make the boat break at XYZ instead of making the boat stay?

This is my set up
2zdsosz.jpg
 
Liking the above post!.. Very good idea, something like this, it would be amazing!
 
You can change the size of the boat by changing the boat ids in local des.
It's only possible to go noth, east, south and west with the boat, it looks a bit weird for the boat to not move straight and if it changes direction it could skip the corners, so I suggest to make the river a bit bigger.
For the waterfall part, same as it looks for ids of the water and borders ids, you can make it check if it finds an invisible stair hole, then change the pos to 1 floor lower so it continues down.
 
Trying to make it get a second array for endborders to turn the boat the opposite way at the end if its the Alt ends pretty sure it is something with this function, just not 100% sure how to mod it to turn the boat... -.-

Code:
local config = {
     endborders = {4644, 4646},
    alt_endborders = {4645, 4647},
     speed = 300,
     ignorefirstborders = 3
}


for b = 1, #config.endborders do
                 if getTileItemById(pos, config.endborders[b]).uid > 0 and s > config.ignorefirstborders then
                     n = n + 1
                     p = pos
                     return p and n
                 end
             end

Making a for statement like
Code:
for b = 1, #config.alt_endborders do
                NOT SURE IF THE IF STATMENT NEEDS TO BE MODDED
if getTileItemById(pos, config.alt_endborders[b]).uid > 0 and s > config.ignorefirstborders then
                    NOT SURE WHAT TO MOD IN THIS PART
                 end
             end
And wouldn't this be the right part to made make it go to a new function for floor changing, like instead of "alt_endborders" make it like "floorchange"

Also with the floor change, it would be cool to have it when the boat gets to the end, crash or something and be recreated at the beginning.
 
Last edited:
@Limos
Ty for the info :p will try it out

@EverClaw
will try that out, im going to play around with it just wanted some general ideas. I had this Idea long ago, but since im just a mapper I couldn't make it but now with @Limos script I might be able to :p
 
PHP:
[Error - Action Interface] 
data/actions/scripts/other/movingboat.lua:onUse
Description: 
(luaDoRemoveItem) Item not found
Picture :
153acu0.jpg

bug? plase help : ) nice script
 
Back
Top