From d656d755358c3a01413a4536a80651f7de25d166 Mon Sep 17 00:00:00 2001 From: austin Date: Fri, 16 May 2025 14:12:00 -0400 Subject: [PATCH] script engine passing methods back into engine --- assets/Scripts/client/clienthooks.ts | 4 +--- .../Scripts/types/host/client/client-area-utils.ts | 6 ++++++ docs/src/progress/renderertodo.md | 1 + .../client/script/ScriptClientAreaUtils.java | 12 ++++++++++-- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/assets/Scripts/client/clienthooks.ts b/assets/Scripts/client/clienthooks.ts index d47bd51d..16a52647 100644 --- a/assets/Scripts/client/clienthooks.ts +++ b/assets/Scripts/client/clienthooks.ts @@ -71,11 +71,9 @@ export const clientHooks: Hook[] = [ } break; case 'SelectRoom': { const areaSelection: AreaSelection = engine.classes.areaUtils.static.selectAreaRectangular() - console.log(JSON.stringify(areaSelection)) - console.log(areaSelection.getType()) - console.log(JSON.stringify(areaSelection.getType())) console.log(areaSelection.getRectStart()) console.log(JSON.stringify(areaSelection.getRectStart())) + engine.classes.areaUtils.static.makeSelectionVisible(areaSelection) } break; case 'ShowFurniture': { } break; diff --git a/assets/Scripts/types/host/client/client-area-utils.ts b/assets/Scripts/types/host/client/client-area-utils.ts index 201f0ffd..fcfac63f 100644 --- a/assets/Scripts/types/host/client/client-area-utils.ts +++ b/assets/Scripts/types/host/client/client-area-utils.ts @@ -25,4 +25,10 @@ export interface ClientAreaUtils { */ readonly selectAreaRectangular: () => AreaSelection + /** + * Makes a selection visible + * @param selection The selection + */ + readonly makeSelectionVisible: (selection: AreaSelection) => void + } \ No newline at end of file diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index 867691af..14c004ee 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -1848,6 +1848,7 @@ HTML-defined buttons now directly eval in the js context instead of going throug Fix caching with deleted source files Proof of concept of ui button calling engine code Script engine direct access to joml vectors +Script engine passing objects back into methods successfully diff --git a/src/main/java/electrosphere/client/script/ScriptClientAreaUtils.java b/src/main/java/electrosphere/client/script/ScriptClientAreaUtils.java index 9a2e7773..a033fc51 100644 --- a/src/main/java/electrosphere/client/script/ScriptClientAreaUtils.java +++ b/src/main/java/electrosphere/client/script/ScriptClientAreaUtils.java @@ -25,9 +25,17 @@ public class ScriptClientAreaUtils { Vector3i chunkPos = Globals.clientState.clientWorldData.convertRealToWorldSpace(cursorPos); Vector3i blockPos = ClientWorldData.convertRealToLocalBlockSpace(cursorPos); AreaSelection selection = AreaSelection.selectRectangularBlockCavity(chunkPos, blockPos, AreaSelection.DEFAULT_SELECTION_RADIUS); - Globals.cursorState.selectRectangularArea(selection); - CursorState.makeAreaVisible(); return selection; } + /** + * Makes a selection visible + * @param selection The selection + */ + @Export + public static void makeSelectionVisible(AreaSelection selection){ + Globals.cursorState.selectRectangularArea(selection); + CursorState.makeAreaVisible(); + } + }