From ac6b3c7f483df29c62bcf2de175bd478a7fb0f04 Mon Sep 17 00:00:00 2001 From: gnembon Date: Sun, 6 Dec 2020 23:40:02 -0400 Subject: [PATCH] apps can be organized in floders in your shared instance space. --- docs/scarpet/api/Overview.md | 3 ++- src/main/java/carpet/script/CarpetScriptServer.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/scarpet/api/Overview.md b/docs/scarpet/api/Overview.md index 7c08b451..4f1da73c 100644 --- a/docs/scarpet/api/Overview.md +++ b/docs/scarpet/api/Overview.md @@ -6,7 +6,8 @@ Here is the gist of the Minecraft related functions. Otherwise the CarpetScript ## App structure The main delivery method for scarpet programs into the game is in the form of apps in `*.sc` files located in the world `scripts` -folder. In singleplayer, you can also save apps in `.minecraft/config/carpet/scripts` for them to be available in any world. +folder, flat. In singleplayer, you can also save apps in `.minecraft/config/carpet/scripts` for them to be available in any world, +and here you can actually organize them in folders. When loaded (via `/script load` command, etc.), the game will run the content of the app once, regardless of its scope (more about the app scopes below), without executing of any functions, unless called directly, and with the exception of the `__config()` function, if present, which will be executed once. Loading the app will also bind specific diff --git a/src/main/java/carpet/script/CarpetScriptServer.java b/src/main/java/carpet/script/CarpetScriptServer.java index d7090999..b515489e 100644 --- a/src/main/java/carpet/script/CarpetScriptServer.java +++ b/src/main/java/carpet/script/CarpetScriptServer.java @@ -149,7 +149,7 @@ public class CarpetScriptServer { Path globalFolder = FabricLoader.getInstance().getConfigDir().resolve("carpet/scripts"); Files.createDirectories(globalFolder); - scriptPath = Files.list(globalFolder) + scriptPath = Files.walk(globalFolder) .filter(script -> script.getFileName().toString().equalsIgnoreCase(name + ".sc") || (allowLibraries && script.getFileName().toString().equalsIgnoreCase(name + ".scl"))) .findFirst(); @@ -194,7 +194,7 @@ public class CarpetScriptServer try { Path worldScripts = server.getSavePath(WorldSavePath.ROOT).resolve("scripts"); Files.createDirectories(worldScripts); - Files.walk(worldScripts) + Files.list(worldScripts) .filter(f -> f.toString().endsWith(".sc")) .forEach(f -> moduleNames.add(f.getFileName().toString().replaceFirst("\\.sc$","").toLowerCase(Locale.ROOT)));