diff --git a/docs/scarpet/language/Containers.md b/docs/scarpet/language/Containers.md index 1d51e881..a5c92b3a 100644 --- a/docs/scarpet/language/Containers.md +++ b/docs/scarpet/language/Containers.md @@ -43,8 +43,7 @@ equivalent to `has(get(foo,a), b)` or `has(foo, a, b)` ### `delete(container, address, ...), delete(lvalue)` Removes specific entry from the container. For the lists - removes the element and shrinks it. For maps, it -removes the key from the map, and for nbt - removes content from a given path. For lists and maps returns previous -entry at the address, for nbt's - number of removed objects, with 0 indicating that the original value was unaffected. +removes the key from the map, and for nbt - removes content from a given path. Like with the `get` and `has`, `delete` can accept chained addresses, as well as l-value container access, removing the value from the leaf of the path provided, so `delete(foo, a, b)` is the diff --git a/docs/scarpet/language/SystemFunctions.md b/docs/scarpet/language/SystemFunctions.md index 4bc26c32..88e5c1a0 100644 --- a/docs/scarpet/language/SystemFunctions.md +++ b/docs/scarpet/language/SystemFunctions.md @@ -252,7 +252,7 @@ indicating if the given seed has been used or not. returns a noise value from `0.0` to `1.0` (roughly) for 1, 2 or 3 dimensional coordinate. The default seed it samples from is `0`, but seed can be specified as a 4th argument as well. In case you need 1D or 2D noise values with custom -seed, use `null` for `z`, or `y` and `z` arguments respectively. +seed, use `null` for `y` and `z`, or `z` arguments respectively. Perlin noise is based on a square grid and generates rougher maps comparing to Simplex, which is creamier. Querying for lower-dimensional result, rather than affixing unused dimensions to constants has a speed benefit, diff --git a/src/main/java/carpet/commands/ScriptCommand.java b/src/main/java/carpet/commands/ScriptCommand.java index 59191a76..22546861 100644 --- a/src/main/java/carpet/commands/ScriptCommand.java +++ b/src/main/java/carpet/commands/ScriptCommand.java @@ -461,6 +461,10 @@ public class ScriptCommand { host.handleErrorWithStack("Math doesn't compute", ae); } + catch (StackOverflowError soe) + { + host.handleErrorWithStack("Your thoughts are too deep", soe); + } return 0; //host.resetErrorSnooper(); // lets say no need to reset the snooper in case something happens on the way } diff --git a/src/main/java/carpet/script/CarpetExpression.java b/src/main/java/carpet/script/CarpetExpression.java index 67496d99..e23e2971 100644 --- a/src/main/java/carpet/script/CarpetExpression.java +++ b/src/main/java/carpet/script/CarpetExpression.java @@ -82,6 +82,10 @@ public class CarpetExpression { throw new CarpetExpressionException("Math doesn't compute... "+ae.getMessage(), null); } + catch (StackOverflowError soe) + { + throw new CarpetExpressionException("Your thoughts are too deep", null); + } } public Value scriptRunCommand(ScriptHost host, BlockPos pos) @@ -115,5 +119,9 @@ public class CarpetExpression { throw new CarpetExpressionException("Math doesn't compute... "+ae.getMessage(), null); } + catch (StackOverflowError soe) + { + throw new CarpetExpressionException("Your thoughts are too deep", null); + } } } diff --git a/src/main/java/carpet/script/CarpetScriptHost.java b/src/main/java/carpet/script/CarpetScriptHost.java index 02673b6d..e7b5b8ca 100644 --- a/src/main/java/carpet/script/CarpetScriptHost.java +++ b/src/main/java/carpet/script/CarpetScriptHost.java @@ -136,6 +136,10 @@ public class CarpetScriptHost extends ScriptHost host.handleErrorWithStack("Math doesn't compute", ae); return null; } + catch (StackOverflowError soe) + { + host.handleErrorWithStack("Your thoughts are too deep", soe); + } finally { host.storeSource = null; @@ -698,13 +702,16 @@ public class CarpetScriptHost extends ScriptHost catch (CarpetExpressionException exc) { handleErrorWithStack("Error while running custom command", exc); - return Value.NULL; } catch (ArithmeticException ae) { handleErrorWithStack("Math doesn't compute", ae); - return Value.NULL; } + catch (StackOverflowError soe) + { + handleErrorWithStack("Your thoughts are too deep", soe); + } + return Value.NULL; } public Value handleCommand(ServerCommandSource source, FunctionValue function, List args) @@ -716,13 +723,16 @@ public class CarpetScriptHost extends ScriptHost catch (CarpetExpressionException exc) { handleErrorWithStack("Error while running custom command", exc); - return Value.NULL; } catch (ArithmeticException ae) { handleErrorWithStack("Math doesn't compute", ae); - return Value.NULL; } + catch (StackOverflowError soe) + { + handleErrorWithStack("Your thoughts are too deep", soe); + } + return Value.NULL; } public Value callLegacy(ServerCommandSource source, String call, List coords, String arg) @@ -1068,13 +1078,13 @@ public class CarpetScriptHost extends ScriptHost super.resetErrorSnooper(); } - public void handleErrorWithStack(String intro, Exception exception) + public void handleErrorWithStack(String intro, Throwable exception) { if (responsibleSource != null) { if (exception instanceof CarpetExpressionException) ((CarpetExpressionException) exception).printStack(responsibleSource); String message = exception.getMessage(); - Messenger.m(responsibleSource, "r "+intro+(message.isEmpty()?"":": "+message)); + Messenger.m(responsibleSource, "r "+intro+( (message == null || message.isEmpty())?"":": "+message)); } else {