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

Help with boat script

Slepy

New Member
Joined
May 14, 2009
Messages
111
Reaction score
1
moze mi ktos pomoc z przerobieniem te scripta na 8.5 Stigma
someone can change this script for 8.5 Stigma

XML:
    <movevent type="StepIn" itemid="3589" event="script" value="boat.lua"/>
    <movevent type="StepIn" itemid="3594" event="script" value="boat.lua"/>
Lua:
-- BY GOD CARBON (RTOIP)
lodzid = {
[NORTH] = {3587,3589,3591},
[SOUTH] = {3591,3589,3587},
[WEST]    = {3592,3594,3596},
[EAST]    = {3596,3594,3592}
}
POZIOMO    =    1
PIONOWO    =    2
cid = {}
pozycja = {}
--    USTAWIENIA \
powrot = true    -- czy lodz ma powracac ta sama trasa?
licznik = true    -- czy licznik ma byc wlaczony?
trasa = {
--    TU ZMIENIAMY TRASE \/
{    -- kierunek NWSE        ile  ma przeplynac    co ile odnawia licznik    co ile ms lodz plynie kratke
    {kierunek = SOUTH,        odleglosc = 100,        licznikco = 10,    delay = 30}--,
    --{kierunek = SOUTH,        odleglosc = 10,        licznikco = 10,    delay = 300}
},
{
    {kierunek = NORTH,        odleglosc = 30,        licznikco = 50,    delay = 200}--,
    --{kierunek = NORTH,        odleglosc = 30,        licznikco = 50,    delay = 200}
}
--    DALEJ JUZ NIE
}
--    KONIEC USTAWIEN /
function kierunekLodzi(ktora)
    if getThingFromPos({x = pozycja[ktora].x, y = pozycja[ktora].y-1, z = pozycja[ktora].z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == lodzid[NORTH][1] then
        return PIONOWO
    else
        return POZIOMO
    end
end
function obrocLodzPoziomo(ktora)
    if kierunekLodzi(ktora) == PIONOWO then
        for n = 1,3 do
            local i = n - 2
            local kawalek    = {x = pozycja[ktora].x, y = pozycja[ktora].y+i, z = pozycja[ktora].z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}
            local ppos        = {x = pozycja[ktora].x, y = pozycja[ktora].y+i, z = pozycja[ktora].z, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE}
            local newpos    = {x = pozycja[ktora].x+i, y = pozycja[ktora].y, z = pozycja[ktora].z}
            local lodz = getThingFromPos(kawalek)
            doRemoveItem(lodz.uid,1)
            doCreateItem(lodzid[WEST][n],1,newpos)
            while (getThingFromPos(ppos).itemid > 0) and i ~= 0 do
                doTeleportThing(getThingFromPos(ppos).uid,newpos)
            end
        end
    end
    return true
end
function obrocLodzPionowo(ktora)
    if kierunekLodzi(ktora) == POZIOMO then
        for n = 1,3 do
            local i = n - 2
            local kawalek    = {x = pozycja[ktora].x+i, y = pozycja[ktora].y, z = pozycja[ktora].z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}
            local ppos        = {x = pozycja[ktora].x+i, y = pozycja[ktora].y, z = pozycja[ktora].z, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE}
            local newpos    = {x = pozycja[ktora].x, y = pozycja[ktora].y+i, z = pozycja[ktora].z}
            local lodz = getThingFromPos(kawalek)
            doRemoveItem(lodz.uid,1)
            doCreateItem(lodzid[NORTH][n],1,newpos)
            while (getThingFromPos(ppos).itemid > 0) and i ~= 0 do
                doTeleportThing(getThingFromPos(ppos).uid,newpos)
            end
        end
    end
    return true
end
function _move(parameters)
    pozycja[parameters.ktora] = move(parameters.trasa,parameters.invert,parameters.ktora)
    return true
end
function setactionid(parameters)
    doSetItemActionId(getThingFromPos({x = pozycja[parameters.ktora].x, y = pozycja[parameters.ktora].y, z = pozycja[parameters.ktora].z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid,parameters.actionid)
    return true
end
function move(p,invert,ktoralodz)
    local plus    =
    {--        NORTH    EAST    SOUTH    WEST
    x    =    {0,        1,        0,        -1},
    y    =    {-1,    0,        1,        0},
    x1    =    {0,        1,        0,        -1},
    x3    =    {0,        -1,        0,        1},
    y1    =    {-1,    0,        1,        0},
    y2    =    {0,        0,        0,        0},
    y3    =    {1,        0,        -1,        0}
    }
    local kier    =    p.kierunek
    if invert == true then
        if kier == NORTH then
            kier = SOUTH
        elseif kier == SOUTH then
            kier = NORTH
        elseif kier == EAST then
            kier = WEST
        elseif kier == WEST then
            kier = EAST
        end
    end
    if (kier == NORTH or kier == SOUTH) and kierunekLodzi(ktoralodz) == POZIOMO then
        obrocLodzPionowo(ktoralodz)
    elseif (kier == EAST or kier == WEST) and kierunekLodzi(ktoralodz) == PIONOWO then
        obrocLodzPoziomo(ktoralodz)
    end
    local czesci = {
        {x = pozycja[ktoralodz].x+plus.x1[kier+1], y = pozycja[ktoralodz].y+plus.y1[kier+1],    z = pozycja[ktoralodz].z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
        {x = pozycja[ktoralodz].x,                        y = pozycja[ktoralodz].y,                        z = pozycja[ktoralodz].z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}, 
        {x = pozycja[ktoralodz].x+plus.x3[kier+1], y = pozycja[ktoralodz].y+plus.y3[kier+1],    z = pozycja[ktoralodz].z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}
    }
    local npos = {
        {x = pozycja[ktoralodz].x+plus.x[kier+1]+plus.x1[kier+1],    y = pozycja[ktoralodz].y+plus.y[kier+1]+plus.y1[kier+1],    z = pozycja[ktoralodz].z},
        {x = pozycja[ktoralodz].x+plus.x[kier+1],                    y = pozycja[ktoralodz].y+plus.y[kier+1],                    z = pozycja[ktoralodz].z},
        {x = pozycja[ktoralodz].x+plus.x[kier+1]+plus.x3[kier+1],    y = pozycja[ktoralodz].y+plus.y[kier+1]+plus.y3[kier+1],    z = pozycja[ktoralodz].z}
    }
    for i = 1,3 do 
        lodz = getThingFromPos(czesci[i])
        doRemoveItem(lodz.uid,1)
        doCreateItem(lodzid[kier][i],1,npos[i])
        while getThingFromPos({x = czesci[i].x, y = czesci[i].y, z = czesci[i].z, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE}).itemid > 0 do
            doTeleportThing(getThingFromPos({x = czesci[i].x, y = czesci[i].y, z = czesci[i].z, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE}).uid,npos[i])
        end
    end
    if licznik == true and ((kier == SOUTH or kier == NORTH) and pozycja[ktoralodz].y % p.licznikco == 0) or ((kier == EAST or kier == WEST) and pozycja[ktoralodz].x % p.licznikco == 0) then
        local mpers = 1000 / p.delay
        doPlayerSendCancel(cid[ktoralodz],"Speed: " .. mpers .. " m/s (" .. mpers * 3.6 .. " km/h)")
    end
    return {x = pozycja[ktoralodz].x+plus.x[kier+1], y = pozycja[ktoralodz].y+plus.y[kier+1], z = pozycja[ktoralodz].z}
end
function onStepIn(cidd, item, position, fromPosition)
    if item.actionid < 20001 or item.actionid > 20100 then    return true    end
    local ktoralodz = item.actionid - 20000
    cid[ktoralodz] = cidd
    pozycja[ktoralodz] = position
    local j = 0
    local k = 0
    local m = 0
    for l = 1,table.maxn(trasa[ktoralodz]) do
        m = m + trasa[ktoralodz][l].odleglosc
        while j < m do
            addEvent(_move, k, {trasa = trasa[ktoralodz][l], invert = false, ktora = ktoralodz})
            j = j + 1
            k = k + trasa[ktoralodz][l].delay
        end
    end
    if powrot == true then
        l = table.maxn(trasa[ktoralodz])
        while l > 0 do
            m = m + trasa[ktoralodz][l].odleglosc
            while j < m do
                addEvent(_move, k, {trasa = trasa[ktoralodz][l], invert = true, ktora = ktoralodz})
                j = j + 1
                k = k + trasa[ktoralodz][l].delay
            end
            l = l - 1
        end
    end
    addEvent(setactionid,k, {actionid = item.actionid, ktora = ktoralodz})
    return true
end
pomozcie prosze
help please
 
Last edited by a moderator:
Boat floating on a designated route (max 3 players) + real speedometer!

The player enters the field with actionId 200xx (xx - number of boats)
The boat starts to sail at a fixed configuration between
 
Please do not use any language other than English in the public boards.

I also modified the original post to make it easier to understand and moved it to the requests board.
 
Back
Top