Skip to content

bb.lua (Building Bridges Test Command)

Duke edited this page Aug 28, 2023 · 1 revision
---------------------------------------------------------------------------------------------------
-- func: !bb <point or nil>
-- desc: Test and parse data from pathlogs
-- note: if argument is nil, will set position to the next point in the table
---------------------------------------------------------------------------------------------------

require("scripts/globals/pathfind")

cmdprops =
{
    permission = 1,
    parameters = "i"
}

local path =
{
    -- Copy and paste pathlog data for each individual Lamia here.
}

function error(player, msg)
    player:PrintToPlayer(msg)
    player:PrintToPlayer("Invalid patrol point!")
end

function onTrigger(player, arg1)
    local len = dsp.path.length(path)

    if arg1 then
        local pos = dsp.path.get(path, arg1)

        if arg1 <= len then
            player:setPos(pos[1], pos[2], pos[3], 0)
            player:setLocalVar("currentSection", arg1)
        else
            error(player, string.format( "Max len is %i", len ) )
        end
    else
        local current = player:getLocalVar("currentSection")
        local next = current + 1
        local pos = dsp.path.get(path, next)

        if next <= len then
            player:setPos(pos[1], pos[2], pos[3], 0)
            player:setLocalVar("currentSection", next)
            player:PrintToPlayer(string.format( "Current point is %i", next ) )
        else
            error(player, string.format( "Max len is %i", len ) )
        end
    end
end

Clone this wiki locally