mirror of
https://codeberg.org/vlw/mcfstd.git
synced 2026-04-13 06:39:37 +02:00
Compare commits
3 commits
c908e61aa3
...
4e797fc0db
| Author | SHA1 | Date | |
|---|---|---|---|
| 4e797fc0db | |||
| 0385912729 | |||
| c4195baf85 |
30 changed files with 40 additions and 51 deletions
75
README.md
75
README.md
|
|
@ -24,26 +24,14 @@ 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
|
||||||
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.
|
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.
|
||||||
|
|
||||||
```
|
Enable this library in Minecraft by typing the following two commands
|
||||||
git clonne http://codeberg.org/vlw/mcfstd
|
```mcfunction
|
||||||
```
|
reload
|
||||||
|
|
||||||
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.
|
datapack enable "file/mcfstd-X-X-X.zip" # Where X-X-X would be the version of the datapack
|
||||||
|
|
||||||
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.
|
||||||
|
|
@ -78,12 +66,14 @@ 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>
|
||||||
|
|
@ -93,7 +83,6 @@ 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>
|
||||||
|
|
@ -103,14 +92,12 @@ 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>
|
||||||
|
|
@ -120,21 +107,18 @@ 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>
|
||||||
|
|
@ -144,50 +128,45 @@ 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 (string)</td>
|
<td><code>v</code> Number to add (int)</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 (string)</td>
|
<td><code>v</code> Number to subtract (int)</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 (string)</td>
|
<td><code>v</code> Number to multiply (int)</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 (string)</td>
|
<td><code>v</code> Number to divide (int)</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 (string)</td>
|
<td><code>v</code> Number to modulo (int)</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="4">Relation / Compare</th>
|
<th colspan="4">Relation / Compare</th>
|
||||||
|
|
@ -196,51 +175,46 @@ 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 <code>stdout</code></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"><code>function comp:eq { a: my_variable, b: my_other_variable }</code></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>v</code> Name of the second variable (string)</td>
|
<td><code>b</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 <code>stdout</code></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"><code>function comp:gt { a: my_variable, b: my_other_variable }</code></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>v</code> Name of the second variable (string)</td>
|
<td><code>b</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 <code>stdout</code></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"><code>function comp:gteq { a: my_variable, b: my_other_variable }</code></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>v</code> Name of the second variable (string)</td>
|
<td><code>b</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 <code>stdout</code></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"><code>function comp:lt { a: my_variable, b: my_other_variable }</code></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>v</code> Name of the second variable (string)</td>
|
<td><code>b</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 <code>stdout</code></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"><code>function comp:lteq { a: my_variable, b: my_other_variable }</code></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>v</code> Name of the second variable (string)</td>
|
<td><code>b</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>
|
||||||
|
|
@ -249,7 +223,6 @@ 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 true if the value of stdout is 0 (success)</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><code>execute if function std:out run function my_function</code></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
||||||
7
data/comp/function/lteq.mcfunction
Normal file
7
data/comp/function/lteq.mcfunction
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
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
|
||||||
9
pack.mcmeta
Normal file
9
pack.mcmeta
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"pack": {
|
||||||
|
"description": {
|
||||||
|
"translate": "A standard library that adds variables, arithmetic, and relational operators to mcfunction"
|
||||||
|
},
|
||||||
|
"min_format": [88, 0],
|
||||||
|
"max_format": [88, 0]
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue