local common = {}

function common.openModem(side)
    if peripheral.isPresent(side) then
        rednet.open(side)
        return true
    end
    return false
end

function common.sendCommand(protocol, cmd, target)
    rednet.broadcast({
        cmd = cmd,
        target = target or "all"
    }, protocol)
end

function common.position(startX, startY, startZ, facing, forward, y)
    local x = startX
    local z = startZ

    if facing == "east" then
        x = x + forward
    elseif facing == "west" then
        x = x - forward
    elseif facing == "south" then
        z = z + forward
    elseif facing == "north" then
        z = z - forward
    end

    return x, y, z
end

return common