dofile('areas.lua')

function onPlayerPositionChange(player, newPos, oldPos)
    local currentBiome = 'none'

    for _, area in ipairs(areas) do
        if isInRange(newPos, area.from, area.to) then
            currentBiome = area.biome
            break
        end
    end

    applyShader(currentBiome)
end

function isInRange(pos, from, to)
    return pos.x >= from.x and pos.x <= to.x and
           pos.y >= from.y and pos.y <= to.y and
           pos.z == from.z
end

connect(g_game, { onGameStart = function() 
    g_game.onPlayerPositionChange:connect(onPlayerPositionChange) 
end })