diff --git a/src/main/java/carpet/script/CarpetExpression.java b/src/main/java/carpet/script/CarpetExpression.java index 225f84b7..cb10102a 100644 --- a/src/main/java/carpet/script/CarpetExpression.java +++ b/src/main/java/carpet/script/CarpetExpression.java @@ -148,7 +148,7 @@ public class CarpetExpression *
* /script stop allows to stop execution of any script currently running that calls the
- * gametick() function which
+ * game_tick() function which
* allows the game loop to regain control of the game and process other commands. This will also make sure
* that all current and future programs will stop their execution. Execution of all programs will be
* prevented until /script resume command is called.
@@ -161,11 +161,11 @@ public class CarpetExpression
* exponentially with n. It takes a little over 50 milliseconds to do fib(24), so above one tick,
* but about a minute to do fib(40). Calling fib(40) will not only freeze the game, but also you woudn't be able to interrupt
* its execution. We can modify the script as follows
fib(n) -> ( gametick(50); if(n<3, 1, fib(n-1)+fib(n-2) ) ); fib(40)+ *
fib(n) -> ( game_tick(50); if(n<3, 1, fib(n-1)+fib(n-2) ) ); fib(40)*
But this would never finish as such call would finish after ~ 2^40 ticks. To make our computations
* responsive, yet able to respond to user interactions, other commands, as well as interrupt execution,
* we could do the following:
fib(n) -> ( if(n==23, gametick(50) ); if(n<3, 1, fib(n-1)+fib(n-2) ) ); fib(40)+ *
fib(n) -> ( if(n==23, game_tick(50) ); if(n<3, 1, fib(n-1)+fib(n-2) ) ); fib(40)*
This would slow down the computation of fib(40) from a minute to two, but allows the game to keep continue running * and be responsive to commands, using about half of each tick to advance the computation. * Obviously depending on the problem, and available hardware, certain things can take @@ -2644,7 +2644,11 @@ public class CarpetExpression *
logger(expr)Prints the message to system logs, and not to chat.
*run(expr)Runs a command from the string result of the expr expression, and returns its success count
Runs a vanilla command from the string result of the expr and returns its success count
+ * run('fill 1 1 1 10 10 10 air') -> 123 // 123 block were filled, this operation was successful 123 times out of a possible 1000 blocks volume
+ * run('give @s stone 4') -> 1 // this operation was successful once
+ *
* save()Performs autosave, saves all chunks, player data, etc. Useful for programs where autosave is disabled * due to performance reasons and saves the world only on demand.
@@ -2664,8 +2668,8 @@ public class CarpetExpression * accept expected tick length, in milliseconds. You can't use it to permanently change the game speed, but * setting longer commands with custom tick speeds can be interrupted via/script stop command
*
- * loop(1000,tick()) // runs the game as fast as it can for 1000 ticks
- * loop(1000,tick(100)) // runs the game twice as slow for 1000 ticks
+ * loop(1000,game_tick()) // runs the game as fast as it can for 1000 ticks
+ * loop(1000,game_tick(100)) // runs the game twice as slow for 1000 ticks
*
* current_dimension()Returns current dimension that the script runs in.
diff --git a/src/main/java/carpet/script/Expression.java b/src/main/java/carpet/script/Expression.java index a11b142b..342834c8 100644 --- a/src/main/java/carpet/script/Expression.java +++ b/src/main/java/carpet/script/Expression.java @@ -809,6 +809,9 @@ public class Expression implements Cloneable * *Ability to combine more statements into one expression, with functions, passing parameters, and global and outer * scoping allow to organize even larger scripts
+ *import(module_name)Imports the entire content of another scarpet app by running the code in the current code context, making all + * functions and global variables available in the current script to use.
*call(function, args.....)calls a user defined function with specified arguments. It is equivalent to calling function(args...)
* directly except you can use it with function value, or name instead. This means you can pass functions to other user defined
@@ -1595,7 +1598,7 @@ public class Expression implements Cloneable
*
Evaluates expression expr, num number of times.
*expr receives _ system variable indicating the iteration.
- * loop(5, tick()) => repeat tick 5 times
+ * loop(5, game_tick()) => repeat tick 5 times
* list = l(); loop(5, x = _; loop(5, list += l(x, _) ) ); list
* // double loop, produces: [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [1, 0], [1, 1], ... , [4, 2], [4, 3], [4, 4]]
*
@@ -2735,7 +2738,7 @@ public class Expression implements Cloneable
*
* sleep(expr)Halts the execution of the program (and the game itself) for expr milliseconds.
- * All in all, its better to use tick(expr) to let the game do its job while the program waits
game_tick(expr) to let the game do its job while the program waits
* sleep(50)*
time()Returns the number of milliseconds since 'some point',