run now returns success count, intercepted output and an error message. Good for parsing. Fixes #428

This commit is contained in:
gnembon committed 2020-09-10 01:48:32 -03:00
1 parent dcfdfbfff7
commit 1bec0f88f4
3 files changed
+45 -10

No files matched your search

+7 -3
View File
@@ -313,11 +313,15 @@ read_file('foo', 'shared_text') => ['one', 'two', 'three', '', 'four', '', '
### `run(expr)`
Runs a vanilla command from the string result of the `expr` and returns its success count
Runs a vanilla command from the string result of the `expr` and returns a triple of success count,
intercepted list of output messages, and error message if the command resulted in a failure.
Successful commands return `null` as their error.
<pre>
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 block volume
run('give @s stone 4') -> 1 // this operation was successful once
run('fill 1 1 1 10 10 10 air') -> [123, ["Successfully filled 123 blocks"], null] // 123 block were filled, this operation was successful 123 times out of a possible 1000 block volume
run('give @s stone 4') -> [1, ["Gave 4 [Stone] to gnembon"], null] // this operation was successful once
run('seed') -> [-170661413, ["Seed: [4031384495743822299]"], null]
run('sed') -> [0, [], "sed<--[HERE]"] // wrong command
</pre>
### `save()`