From f35516443bf69c968b748f333b7341c0300e3197 Mon Sep 17 00:00:00 2001 From: gnembon Date: Fri, 25 Oct 2019 17:31:25 -0300 Subject: [PATCH] docs --- src/main/java/carpet/script/CarpetExpression.java | 13 ++++++++++--- src/main/java/carpet/script/Expression.java | 3 +++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/carpet/script/CarpetExpression.java b/src/main/java/carpet/script/CarpetExpression.java index 23a0b117..bad1c53a 100644 --- a/src/main/java/carpet/script/CarpetExpression.java +++ b/src/main/java/carpet/script/CarpetExpression.java @@ -2432,14 +2432,20 @@ public class CarpetExpression *

Renders a cuboid of particles between point pos to pos2 with supplied density.

*

Markers

*

create_marker(text, pos, rotation?, block?)

- *

Spawns a (permanent) marker entity with text or block at position. Returns that entity for further manipulations

+ *

Spawns a (permanent) marker entity with text or block at position. Returns that entity for further manipulations. + * Unloading the app that spawned them will cause all the markers from the loaded portion of the world to be removed. + * Also - if the game loads that marker in the future and the app is not loaded, it will be removed as well.

*

remove_all_markers()

- *

Removes all scarpet markers from the loaded portion of the world in case you didn't want to do the cleanup

+ *

Removes all scarpet markers from the loaded portion of the world created by this app, in case you didn't want + * to do the proper cleanup

*

System function

*

nbt(expr)

*

Treats the argument as a nbt serializable string and returns its nbt value. * In case nbt is not in a correct nbt compound tag format, it will return null value.

*

Consult section about container operations in Expression to learn about possible operations on nbt values.

+ *

escape_nbt(expr)

+ *

Excapes all the special characters in the string or nbt tag and returns a string that can be stored in nbt directly as + * a string value.

*

print(expr)

*

Displays the result of the expression to the chat. Overrides default scarpet behaviour of * sending everyting to stderr.

@@ -3137,7 +3143,8 @@ public class CarpetExpression *
*

invoke family of commands provide convenient way to invoke stored procedures (i.e. functions * that has been defined previously by any running script. To view current stored procedure set, - * run /script globals, to define a new stored procedure, just run a /script run function(a,b) -> ( ... ) + * run /script globals(or /script globals all to display all functions even hidden ones), + * to define a new stored procedure, just run a /script run function(a,b) -> ( ... ) * command with your procedure once, and to forget a procedure, use undef function: * /script run undef('function')

*

diff --git a/src/main/java/carpet/script/Expression.java b/src/main/java/carpet/script/Expression.java index bd8e166e..135d8bc0 100644 --- a/src/main/java/carpet/script/Expression.java +++ b/src/main/java/carpet/script/Expression.java @@ -883,6 +883,9 @@ public class Expression implements Cloneable * Function call creates new scope for variables inside expr, so all non-global variables are not * visible from the caller scope. All parameters are passed by value to the new scope, including lists and other * containers, however their copy will be shallow.

+ *

The function returns its name as a string, which means it can be used to call it later with the call function

+ *

Using _ as the function name creates anonymous function, so each time _ function is defined, + * it will be given a unique name, which you can pass somewhere else to get this function called.

*
      * a(lst) -> lst+=1; list = l(1,2,3); a(list); a(list); list  // => [1,2,3]
      *