From 0865710f6569a275b461a415c010fcb50d676886 Mon Sep 17 00:00:00 2001 From: lucia c Date: Sun, 14 Apr 2024 11:58:43 -0500 Subject: [PATCH] fixed the errors we get when the logs are over (#22) --- ts/main.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ts/main.ts b/ts/main.ts index d2c6d90..0d45ded 100644 --- a/ts/main.ts +++ b/ts/main.ts @@ -77,6 +77,12 @@ function initialize(data: object[]) { // Drawing function for Field2D draw = () => { const item = data[i]; + + if (i >= data.length || item == undefined) { + playing = false; + return; + } + const robotX = Number(item["Robot X"]); const robotY = Number(item["Robot Y"]); const robotRotation = degreesToRadians(Number(item["Robot Theta (deg)"]));