Output Functions - anon-noob/mothball GitHub Wiki
Output Functions
Output functions tell Mothball to return specific information about the player's position, speed, and vector, among other things. If the simulation does not have an output function, then by default, Mothball will output the player's X and Z position as well as their velocities.
Most output functions have aliases, which means you can call the same function with different names.
Common Characteristics
Common Arguments
Most output functions share these two arguments.
argument name | datatype | default value | details |
---|---|---|---|
zero | float | 0 | If zero is 0, then the function will output a number, call it x . If zero is a nonzero number, then the function will output as an expression (zero + (x - zero) ) For example, if the output is 2.89 , then setting zero = 3 outputs 3 - 0.11 |
label | str | usually the name of the function | Mothball outputs in the form label: number_or_expression . Typically, the label's default value is the function's name, but you can change it to suit your purpose. |
You do not need to do anything extra to tell Mothball that an argument is a string. It will automatically detect it for you. For example, when running outz(2.5, 3)
, Mothball will know that the 2.5
is a float and the 3
is a string.
Conversion Formulas for Blocks, Displacement, and Momentum
In game, we might measure things with different units in order to keep the numbers nicer. For example, when we say "1 block momentum 4 block jump", what it actually means is "1.6 on momentum, 3.4 on jump", both numbers being in terms of displacement.
Below are the formulas for converting these units. Keep in mind that we work with one axis (x and z) at a time.
Displacement to Momentum and Blocks to Displacement
Let $d$ be the displacement in one axis. The amount of momentum $m$ traveled is
$$m = \begin{cases}d - 0.6 & \text{if } d \geq 0 \newline d + 0.6 & \text{if } d < 0\end{cases}$$
Similarly, let $b$ be the distance traveled in blocks. The displacement $d$ is therefore
$$d = \begin{cases}b - 0.6 & \text{if } b \geq 0 \newline b + 0.6 & \text{if } b < 0\end{cases}$$
Momentum to Displacement and Displacement to Blocks
Let $m$ be the momentum traveled in one axis. The displacement $d$ is
$$d = \begin{cases}m + 0.6 & \text{if } m \geq 0 \newline m - 0.6 & \text{if } m < 0\end{cases}$$
Similarly, if $d$ is the displacement, then the blocks $b$ traveled is therefore
$$b = \begin{cases}d + 0.6 & \text{if } d \geq 0 \newline d - 0.6 & \text{if } d < 0\end{cases}$$
Outz
# No Other Alias
outz(
zero: float = 0,
label: str = "Z"
)
Outputs the player's Z position, also known as displacement.
Outx
# No Other Alias
outx(
zero: float = 0,
label: str = "X"
)
Outputs the player's X position, also known as displacement.
Outzmm
# Other Aliases: zmm
outzmm(
zero: float = 0,
label: str = "Z mm"
)
Outputs the player's Z in terms of momentum.
Outxmm
# Other Aliases: xmm
outxmm(
zero: float = 0,
label: str = "X mm"
)
Outputs the player's X in terms of momentum.
Outzb
# Other Aliases: zb
outzb(
zero: float = 0,
label: str = "Z b"
)
Outputs the player's Z in terms of blocks.
Outxb
# Other Aliases: xb
outxb(
zero: float = 0,
label: str = "X b"
)
Outputs the player's X in terms of blocks.
Speedvector
# Other Alises: speedvec, vec
speedvector(
)
Outputs the magnitude and direction of the player's speed vector. This function does not have a zero
argument or a label
argument. It is outputted with the labels Speed
and Angle
.
Outvz
# No Other Aliases
outvz(
zero: float = 0,
label: str = "Vz"
)
Outputs the player's Z velocity.
Outvx
# No Other Aliases
outvx(
zero: float = 0,
label: str = "Vx"
)
Outputs the player's X velocity.
Macro
# No Other Alias
macro(
name: str = "a"
)
Outputs an MPK mod macro named name.csv
. This does NOT support the creation of cyv client macros.
Println
# Other Aliases: print
println(
string: str = "\n"
)
Prints string
to the output, particularly useful for organizing and detailing your outputs. println
will always end with a newline.
To print commas, place a \
before the comma. For example, print(hey\, u cute)
Because this is a discord bot, pings are disabled and links will not print. Additionally, you cannot use this function more than 3 times inside the repeat
function (and for what purpose in the first place).
I don't know why you would do this but prepending with a -
does not print the string backwards, but maybe it will be supported, so -print(hey there)
would output ereht yeh
.