Compare commits

..

No commits in common. "master" and "1.0.0" have entirely different histories.

30 changed files with 52 additions and 41 deletions

View file

@ -24,14 +24,26 @@ execute unless std:out run return fail
**See the [function reference](#functions) for a full list of available functions** **See the [function reference](#functions) for a full list of available functions**
# Installation # Installation
Download the datapack as a zip from [the releases page](/vlw/mcfstd/releases) for the version that you require. Place the zip file directly into the `datapacks/` directory of your Minecraft world save directory. This is not a stand-alone datapack but is instead intended to be placed inside the `data/` directory of your own datapack. Clone this repository into the `data/` directory of your datapack.
Enable this library in Minecraft by typing the following two commands
```mcfunction
reload
datapack enable "file/mcfstd-X-X-X.zip" # Where X-X-X would be the version of the datapack
``` ```
git clonne http://codeberg.org/vlw/mcfstd
```
It is highly recommended that you rename the directory that contains this library after you clone it. This will prevent other datapacks that use this library from interfering with yours, and it also prevents your datapacks from interfering with theirs. This is important since other datapacks might use a version of this library that is not compatible with yours.
For example
```
data/
mcfstd/
```
would become:
```
data/
std_my_datapack/
```
One that is done, reload your plugins with `/reload` and you should have access to mcfstd functions
# The standard output # The standard output
This library contains a standard output that is used as an intermediary for arithmetic and comparison operations. This library contains a standard output that is used as an intermediary for arithmetic and comparison operations.
@ -66,14 +78,12 @@ execute if std:out run return run function my_function
``` ```
# Functions # Functions
> [!Note]
> The functions under the `z_:` namespace are used internally by mcfstd and are not meant to be called directly unless you know what you are doing.
<table> <table>
<tr> <tr>
<th>Function</th> <th>Function</th>
<th>Arguments</th> <th>Arguments</th>
<th>Description</th> <th>Description</th>
<th>Example</th>
</tr> </tr>
<tr> <tr>
<th colspan="4">Variables</th> <th colspan="4">Variables</th>
@ -83,6 +93,7 @@ execute if std:out run return run function my_function
<td rowspan="2"><code>var:set</code></td> <td rowspan="2"><code>var:set</code></td>
<td><code>k</code> Name of the variable (string)</td> <td><code>k</code> Name of the variable (string)</td>
<td rowspan="2">Set the value of a variable</td> <td rowspan="2">Set the value of a variable</td>
<td rowspan="2"><code>function var:set { k: my_variable, v: 10 }</code></td>
</tr> </tr>
<tr> <tr>
<td><code>v</code> Value of the variable (int)</td> <td><code>v</code> Value of the variable (int)</td>
@ -92,12 +103,14 @@ execute if std:out run return run function my_function
<td><code>var:unset</code></td> <td><code>var:unset</code></td>
<td><code>k</code> Name of the variable (string)</td> <td><code>k</code> Name of the variable (string)</td>
<td>Remove a varialbe</td> <td>Remove a varialbe</td>
<td><code>function var:unset { k: my_variable }</code></td>
</tr> </tr>
<!-- var:mv --> <!-- var:mv -->
<tr> <tr>
<td rowspan="2"><code>var:mv</code></td> <td rowspan="2"><code>var:mv</code></td>
<td><code>k</code> Old variable name (string)</td> <td><code>k</code> Old variable name (string)</td>
<td rowspan="2">Rename a variable</td> <td rowspan="2">Rename a variable</td>
<td rowspan="2"><code>function var:mv { k: my_variable, v: my_renamed_variable }</code></td>
</tr> </tr>
<tr> <tr>
<td><code>v</code> New variable name (string)</td> <td><code>v</code> New variable name (string)</td>
@ -107,18 +120,21 @@ execute if std:out run return run function my_function
<td><code>var:inc</code></td> <td><code>var:inc</code></td>
<td><code>k</code> Name of the variable (string)</td> <td><code>k</code> Name of the variable (string)</td>
<td>Increment the value of a variable</td> <td>Increment the value of a variable</td>
<td><code>function var:inc { k: my_variable }</code></td>
</tr> </tr>
<!-- var:dec --> <!-- var:dec -->
<tr> <tr>
<td><code>var:dec</code></td> <td><code>var:dec</code></td>
<td><code>k</code> Name of the variable (string)</td> <td><code>k</code> Name of the variable (string)</td>
<td>Decrement the value of a variable</td> <td>Decrement the value of a variable</td>
<td><code>function var:dec { k: my_variable }</code></td>
</tr> </tr>
<!-- var:put --> <!-- var:put -->
<tr> <tr>
<td><code>var:put</code></td> <td><code>var:put</code></td>
<td>-</td> <td>-</td>
<td>Put the current value of A into this variable</td> <td>Put the current value of A into this variable</td>
<td><code>function var:put { k: my_variable }</code></td>
</tr> </tr>
<tr> <tr>
<th colspan="4">Arithmetic</th> <th colspan="4">Arithmetic</th>
@ -128,45 +144,50 @@ execute if std:out run return run function my_function
<td rowspan="2"><code>math:add</code></td> <td rowspan="2"><code>math:add</code></td>
<td><code>k</code> Name of the variable (string)</td> <td><code>k</code> Name of the variable (string)</td>
<td rowspan="2">Add a number to the current value of a variable and store the result in A</td> <td rowspan="2">Add a number to the current value of a variable and store the result in A</td>
<td rowspan="2"><code>function math:add { k: my_variable, v: 10 }</code></td>
</tr> </tr>
<tr> <tr>
<td><code>v</code> Number to add (int)</td> <td><code>v</code> Number to add (string)</td>
</tr> </tr>
<!-- math:sub --> <!-- math:sub -->
<tr> <tr>
<td rowspan="2"><code>math:sub</code></td> <td rowspan="2"><code>math:sub</code></td>
<td><code>k</code> Name of the variable (string)</td> <td><code>k</code> Name of the variable (string)</td>
<td rowspan="2">Subtract a number to the current value of a variable and store the result in A</td> <td rowspan="2">Subtract a number to the current value of a variable and store the result in A</td>
<td rowspan="2"><code>function math:sub { k: my_variable, v: 10 }</code></td>
</tr> </tr>
<tr> <tr>
<td><code>v</code> Number to subtract (int)</td> <td><code>v</code> Number to subtract (string)</td>
</tr> </tr>
<!-- math:mul --> <!-- math:mul -->
<tr> <tr>
<td rowspan="2"><code>math:mul</code></td> <td rowspan="2"><code>math:mul</code></td>
<td><code>k</code> Name of the variable (string)</td> <td><code>k</code> Name of the variable (string)</td>
<td rowspan="2">Multiply a number with the current value of a variable and store the result in A</td> <td rowspan="2">Multiply a number with the current value of a variable and store the result in A</td>
<td rowspan="2"><code>function math:mul { k: my_variable, v: 10 }</code></td>
</tr> </tr>
<tr> <tr>
<td><code>v</code> Number to multiply (int)</td> <td><code>v</code> Number to multiply (string)</td>
</tr> </tr>
<!-- math:div --> <!-- math:div -->
<tr> <tr>
<td rowspan="2"><code>math:div</code></td> <td rowspan="2"><code>math:div</code></td>
<td><code>k</code> Name of the variable (string)</td> <td><code>k</code> Name of the variable (string)</td>
<td rowspan="2">Divide a number with the current value of a variable and store the result in A</td> <td rowspan="2">Divide a number with the current value of a variable and store the result in A</td>
<td rowspan="2"><code>function math:div { k: my_variable, v: 10 }</code></td>
</tr> </tr>
<tr> <tr>
<td><code>v</code> Number to divide (int)</td> <td><code>v</code> Number to divide (string)</td>
</tr> </tr>
<!-- math:mod --> <!-- math:mod -->
<tr> <tr>
<td rowspan="2"><code>math:mod</code></td> <td rowspan="2"><code>math:mod</code></td>
<td><code>k</code> Name of the variable (string)</td> <td><code>k</code> Name of the variable (string)</td>
<td rowspan="2">Modulo a number with the current value of a variable and store the result in A</td> <td rowspan="2">Modulo a number with the current value of a variable and store the result in A</td>
<td rowspan="2"><code>function math:mod { k: my_variable, v: 10 }</code></td>
</tr> </tr>
<tr> <tr>
<td><code>v</code> Number to modulo (int)</td> <td><code>v</code> Number to modulo (string)</td>
</tr> </tr>
<tr> <tr>
<th colspan="4">Relation / Compare</th> <th colspan="4">Relation / Compare</th>
@ -175,46 +196,51 @@ execute if std:out run return run function my_function
<tr> <tr>
<td rowspan="2"><code>comp:eq</code></td> <td rowspan="2"><code>comp:eq</code></td>
<td><code>a</code> Name of the first variable (string)</td> <td><code>a</code> Name of the first variable (string)</td>
<td rowspan="2">Check if <code>a = b</code> and store the result in <a href="#the-standard-output">the standard output</a></td> <td rowspan="2">Check if <code>a = b</code> and store the result in <code>stdout</code></td>
<td rowspan="2"><code>function comp:eq { a: my_variable, b: my_other_variable }</code></td>
</tr> </tr>
<tr> <tr>
<td><code>b</code> Name of the second variable (string)</td> <td><code>v</code> Name of the second variable (string)</td>
</tr> </tr>
<!-- comp:gt --> <!-- comp:gt -->
<tr> <tr>
<td rowspan="2"><code>comp:gt</code></td> <td rowspan="2"><code>comp:gt</code></td>
<td><code>a</code> Name of the first variable (string)</td> <td><code>a</code> Name of the first variable (string)</td>
<td rowspan="2">Check if <code>a > b</code> and store the result in <a href="#the-standard-output">the standard output</a></td> <td rowspan="2">Check if <code>a > b</code> and store the result in <code>stdout</code></td>
<td rowspan="2"><code>function comp:gt { a: my_variable, b: my_other_variable }</code></td>
</tr> </tr>
<tr> <tr>
<td><code>b</code> Name of the second variable (string)</td> <td><code>v</code> Name of the second variable (string)</td>
</tr> </tr>
<!-- comp:gteq --> <!-- comp:gteq -->
<tr> <tr>
<td rowspan="2"><code>comp:gteq</code></td> <td rowspan="2"><code>comp:gteq</code></td>
<td><code>a</code> Name of the first variable (string)</td> <td><code>a</code> Name of the first variable (string)</td>
<td rowspan="2">Check if <code>a >= b</code> and store the result in <a href="#the-standard-output">the standard output</a></td> <td rowspan="2">Check if <code>a >= b</code> and store the result in <code>stdout</code></td>
<td rowspan="2"><code>function comp:gteq { a: my_variable, b: my_other_variable }</code></td>
</tr> </tr>
<tr> <tr>
<td><code>b</code> Name of the second variable (string)</td> <td><code>v</code> Name of the second variable (string)</td>
</tr> </tr>
<!-- comp:lt --> <!-- comp:lt -->
<tr> <tr>
<td rowspan="2"><code>comp:lt</code></td> <td rowspan="2"><code>comp:lt</code></td>
<td><code>a</code> Name of the first variable (string)</td> <td><code>a</code> Name of the first variable (string)</td>
<td rowspan="2">Check if <code>a < b</code> and store the result in <a href="#the-standard-output">the standard output</a></td> <td rowspan="2">Check if <code>a < b</code> and store the result in <code>stdout</code></td>
<td rowspan="2"><code>function comp:lt { a: my_variable, b: my_other_variable }</code></td>
</tr> </tr>
<tr> <tr>
<td><code>b</code> Name of the second variable (string)</td> <td><code>v</code> Name of the second variable (string)</td>
</tr> </tr>
<!-- comp:lteq --> <!-- comp:lteq -->
<tr> <tr>
<td rowspan="2"><code>comp:lteq</code></td> <td rowspan="2"><code>comp:lteq</code></td>
<td><code>a</code> Name of the first variable (string)</td> <td><code>a</code> Name of the first variable (string)</td>
<td rowspan="2">Check if <code>a <= b</code> and store the resulteq in <a href="#the-standard-output">the standard output</a></td> <td rowspan="2">Check if <code>a <= b</code> and store the resulteq in <code>stdout</code></td>
<td rowspan="2"><code>function comp:lteq { a: my_variable, b: my_other_variable }</code></td>
</tr> </tr>
<tr> <tr>
<td><code>b</code> Name of the second variable (string)</td> <td><code>v</code> Name of the second variable (string)</td>
</tr> </tr>
<tr> <tr>
<th colspan="4">Built-in operations</th> <th colspan="4">Built-in operations</th>
@ -223,6 +249,7 @@ execute if std:out run return run function my_function
<tr> <tr>
<td><code>std:out</code></td> <td><code>std:out</code></td>
<td>-</td> <td>-</td>
<td>Will return nothing if the value of <a href="#the-standard-output">the standard output</a> is not <code>fail</code>. Else this function will also <code>fail</code></td> <td>Will return true if the value of stdout is 0 (success)</td>
<td><code>execute if function std:out run function my_function</code></td>
</tr> </tr>
</table> </table>

View file

@ -1,7 +0,0 @@
function z_:construct
$function comp:eq { a: $(a), b: $(b) }
execute unless function std:out run return fail
$function comp:lt { a: $(a), b: $(b) }
execute unless function std:out run return fail

View file

@ -1,9 +0,0 @@
{
"pack": {
"description": {
"translate": "A standard library that adds variables, arithmetic, and relational operators to mcfunction"
},
"min_format": [88, 0],
"max_format": [88, 0]
}
}