diff --git a/src/main/java/carpet/commands/ScriptCommand.java b/src/main/java/carpet/commands/ScriptCommand.java index 1f460f0f..dad4cb1d 100644 --- a/src/main/java/carpet/commands/ScriptCommand.java +++ b/src/main/java/carpet/commands/ScriptCommand.java @@ -289,7 +289,7 @@ public class ScriptCommand private static Collection suggestFunctionCalls(CommandContext c) { CarpetScriptHost host = getHost(c); - return host.globaFunctionNames(host.myCode, s -> !s.startsWith("_")).sorted().collect(Collectors.toList()); + return host.globaFunctionNames(host.main, s -> !s.startsWith("_")).sorted().collect(Collectors.toList()); } private static int listEvents(ServerCommandSource source) { @@ -315,7 +315,7 @@ public class ScriptCommand ServerCommandSource source = context.getSource(); Messenger.m(source, "lb Stored functions"+((host == CarpetServer.scriptServer.globalHost)?":":" in "+host.getName()+":")); - host.globaFunctionNames(host.myCode, (str) -> all || !str.startsWith("__")).sorted().forEach( (s) -> { + host.globaFunctionNames(host.main, (str) -> all || !str.startsWith("__")).sorted().forEach( (s) -> { FunctionValue fun = host.getFunction(s); Expression expr = fun.getExpression(); Tokenizer.Token tok = fun.getToken(); @@ -330,7 +330,7 @@ public class ScriptCommand //Messenger.m(source, "w "+code); Messenger.m(source, "w "); Messenger.m(source, "lb Global variables"+((host == CarpetServer.scriptServer.globalHost)?":":" in "+host.getName()+":")); - host.globaVariableNames(host.myCode, (s) -> s.startsWith("global_")).sorted().forEach( (s) -> { + host.globaVariableNames(host.main, (s) -> s.startsWith("global_")).sorted().forEach( (s) -> { Messenger.m(source, "wb "+s+": ", "w "+ host.getGlobalVariable(s).evalValue(null).getPrettyString()); }); return 1; @@ -399,7 +399,7 @@ public class ScriptCommand ServerCommandSource source = context.getSource(); CarpetScriptHost host = getHost(context); handleCall(source, host, () -> { - CarpetExpression ex = new CarpetExpression(host.myCode, expr, source, new BlockPos(0, 0, 0)); + CarpetExpression ex = new CarpetExpression(host.main, expr, source, new BlockPos(0, 0, 0)); return ex.scriptRunCommand(host, new BlockPos(source.getPosition())); }); return 1; @@ -410,7 +410,7 @@ public class ScriptCommand ServerCommandSource source = context.getSource(); CarpetScriptHost host = getHost(context); MutableIntBoundingBox area = new MutableIntBoundingBox(a, b); - CarpetExpression cexpr = new CarpetExpression(host.myCode, expr, source, origin); + CarpetExpression cexpr = new CarpetExpression(host.main, expr, source, origin); int int_1 = area.getBlockCountX() * area.getBlockCountY() * area.getBlockCountZ(); if (int_1 > CarpetSettings.fillLimit) @@ -461,7 +461,7 @@ public class ScriptCommand ServerCommandSource source = context.getSource(); CarpetScriptHost host = getHost(context); MutableIntBoundingBox area = new MutableIntBoundingBox(a, b); - CarpetExpression cexpr = new CarpetExpression(host.myCode, expr, source, origin); + CarpetExpression cexpr = new CarpetExpression(host.main, expr, source, origin); int int_1 = area.getBlockCountX() * area.getBlockCountY() * area.getBlockCountZ(); if (int_1 > CarpetSettings.fillLimit) { diff --git a/src/main/java/carpet/script/CarpetScriptHost.java b/src/main/java/carpet/script/CarpetScriptHost.java index c6f8ba71..1f595615 100644 --- a/src/main/java/carpet/script/CarpetScriptHost.java +++ b/src/main/java/carpet/script/CarpetScriptHost.java @@ -60,7 +60,7 @@ public class CarpetScriptHost extends ScriptHost return null; } host.setChatErrorSnooper(source); - CarpetExpression ex = new CarpetExpression(host.myCode, code, source, new BlockPos(0, 0, 0)); + CarpetExpression ex = new CarpetExpression(host.main, code, source, new BlockPos(0, 0, 0)); ex.getExpr().asATextSource(); ex.scriptRunCommand(host, new BlockPos(source.getPosition())); } @@ -78,7 +78,7 @@ public class CarpetScriptHost extends ScriptHost @Override protected ScriptHost duplicate() { - return new CarpetScriptHost(scriptServer, myCode, false, this); + return new CarpetScriptHost(scriptServer, main, false, this); } @Override @@ -312,19 +312,19 @@ public class CarpetScriptHost extends ScriptHost private void dumpState() { - myCode.saveData(null, globalState); + main.saveData(null, globalState); } private Tag loadState() { - return myCode.getData(null); + return main.getData(null); } public Tag getGlobalState(String file) { if (getName() == null ) return null; if (file != null) - return myCode.getData(file); + return main.getData(file); if (parent == null) return globalState; return ((CarpetScriptHost)parent).globalState; @@ -336,7 +336,7 @@ public class CarpetScriptHost extends ScriptHost if (file!= null) { - myCode.saveData(file, tag); + main.saveData(file, tag); return; } diff --git a/src/main/java/carpet/script/CarpetScriptServer.java b/src/main/java/carpet/script/CarpetScriptServer.java index 08d7308b..135980cd 100644 --- a/src/main/java/carpet/script/CarpetScriptServer.java +++ b/src/main/java/carpet/script/CarpetScriptServer.java @@ -217,7 +217,7 @@ public class CarpetScriptServer return 1; }); - for (String function : host.globaFunctionNames(host.myCode, s -> !s.startsWith("_")).sorted().collect(Collectors.toList())) + for (String function : host.globaFunctionNames(host.main, s -> !s.startsWith("_")).sorted().collect(Collectors.toList())) { command = command. then(literal(function). diff --git a/src/main/java/carpet/script/ExpressionInspector.java b/src/main/java/carpet/script/ExpressionInspector.java index 922c84cf..e6d2a1f6 100644 --- a/src/main/java/carpet/script/ExpressionInspector.java +++ b/src/main/java/carpet/script/ExpressionInspector.java @@ -48,8 +48,8 @@ public class ExpressionInspector // not that useful in commandline, more so in external scripts, so skipping here //scarpetMatches.addAll(CarpetServer.scriptServer.events.eventHandlers.keySet().stream(). // filter(s -> s.startsWith(prefix) && s.length() <= maxLen).map(s -> "__"+s+"(").collect(Collectors.toList())); - scarpetMatches.addAll(host.globaFunctionNames(host.myCode, s -> s.startsWith(prefix)).map(s -> s+"(").collect(Collectors.toList())); - scarpetMatches.addAll(host.globaVariableNames(host.myCode, s -> s.startsWith(prefix)).collect(Collectors.toList())); + scarpetMatches.addAll(host.globaFunctionNames(host.main, s -> s.startsWith(prefix)).map(s -> s+"(").collect(Collectors.toList())); + scarpetMatches.addAll(host.globaVariableNames(host.main, s -> s.startsWith(prefix)).collect(Collectors.toList())); return scarpetMatches; } } diff --git a/src/main/java/carpet/script/ScriptHost.java b/src/main/java/carpet/script/ScriptHost.java index 63a8b064..d3d609d4 100644 --- a/src/main/java/carpet/script/ScriptHost.java +++ b/src/main/java/carpet/script/ScriptHost.java @@ -64,16 +64,16 @@ public abstract class ScriptHost protected ScriptHost parent; protected boolean perUser; - public String getName() {return myCode==null?null:myCode.getName();} + public String getName() {return main ==null?null: main.getName();} - public final Module myCode; + public final Module main; public Fluff.TriFunction> errorSnooper = null; protected ScriptHost(Module code, boolean perUser, ScriptHost parent) { this.parent = parent; - this.myCode = code; + this.main = code; this.perUser = perUser; ModuleData moduleData = new ModuleData(code); initializeModuleGlobals(moduleData); @@ -138,7 +138,7 @@ public abstract class ScriptHost protected abstract void runModuleCode(Context c, Module module); // this should be shell out in the executor - public FunctionValue getFunction(String name) { return getFunction(myCode, name); } + public FunctionValue getFunction(String name) { return getFunction(main, name); } public FunctionValue getAssertFunction(Module module, String name) { FunctionValue ret = getFunction(module, name); @@ -178,7 +178,7 @@ public abstract class ScriptHost return null; } - public LazyValue getGlobalVariable(String name) { return getGlobalVariable(myCode, name); } + public LazyValue getGlobalVariable(String name) { return getGlobalVariable(main, name); } public LazyValue getGlobalVariable(Module module, String name) { ModuleData local = moduleData.get(module);