From 0a1ebf77ab695bb520c281994e92b03343fcde6f Mon Sep 17 00:00:00 2001 From: IR0NSIGHT Date: Thu, 30 Nov 2023 20:02:31 +0100 Subject: [PATCH] fix fatal error, when trying to use custom layers, but project has none --- src/worldpainterApi/worldpainterApi.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/worldpainterApi/worldpainterApi.ts b/src/worldpainterApi/worldpainterApi.ts index a76ac70..a35cdc6 100644 --- a/src/worldpainterApi/worldpainterApi.ts +++ b/src/worldpainterApi/worldpainterApi.ts @@ -1,5 +1,6 @@ import { ParsingError } from '../FileOperation/Parser'; import { Layer } from '../Layer/Layer'; +import { log } from "../log"; export function getTerrainById(terrainId: number): Terrain { // @ts-ignore worldpainter java object @@ -52,6 +53,8 @@ export function getLayerById(layerId: string): Layer | ParsingError { default: { //search for custom layers const customLayers: Layer[] = dimension.getCustomLayers(); + if (!Array.isArray(customLayers)) + return { mssg: 'no custom layers found in project: ' + layerId }; let matched: Layer | undefined = undefined; customLayers .filter((f) => f != null)