From 677debd475a77b1bb33ae214f4f3e886aee3fa1b Mon Sep 17 00:00:00 2001 From: DeltaNedas <39013340+DeltaNedas@users.noreply.github.com> Date: Thu, 30 Jan 2020 00:38:51 +0000 Subject: [PATCH] testing script loading stuff is not allowed in console, only from `LoadedMod`s. --- core/src/mindustry/mod/Scripts.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/src/mindustry/mod/Scripts.java b/core/src/mindustry/mod/Scripts.java index 6d70437dbb..b862e89149 100644 --- a/core/src/mindustry/mod/Scripts.java +++ b/core/src/mindustry/mod/Scripts.java @@ -68,6 +68,10 @@ public class Scripts implements Disposable{ } public void run(LoadedMod mod, Fi file){ + new RequireBuilder() + .setModuleScriptProvider(new SoftCachingModuleScriptProvider( + new UrlModuleSourceProvider(Arrays.asList(new URI[] {file.child("scripts").file().toURI()}), null))) + .setSandboxed(true).createRequire(context, scope).install(scope); run(wrapper.replace("$SCRIPT_NAME$", mod.name + "/" + file.nameWithoutExtension()).replace("$CODE$", file.readString()).replace("$MOD_NAME$", mod.name), file.name()); }