Addons
Addons are other functions that are packaged within Konstruct. These aren’t enabled by default, but it is highly recommended to enable them. In this page <>
’s refer to an input argument and []
’s are an optional argument.
Table of contents
Calculate
The calculate function evaluates any math expression using mXparser. There are a ton of different equations and math operators that can be used. To see all of them browse around the documentation.
- Name
calc
- Arguments
<expression>
- Output
- Evaluation of expression. If there is an error it will return
NaN
.
EXAMPLE
Input: calc('15 * 15')
Output: 225.0
Get
This function returns a specified argument.
- Name
get
- Arguments
<argumentNumber>
,<args>...
- Output
- Uses
argumentNumber
as the index to fetch from the rest of theargs
. Theargs
start at index 0. If the number is not a valid index it will return the 1st value inargs
.
EXAMPLE
Input: get(2, 'First Option', 'Second Option', '''Third Option''')
Output: Third Option
Random Integer
This function returns a random int from min
to max
(inclusive)
- Name
randInt
- Arguments
<min>
,<max>
- Output
- Returns a random int from
min
tomax
(inclusive)
EXAMPLE
Input: randInt(3, 8)
Output: 7
Round
This function rounds a number to n
specified decimal places.
- Name
round
- Arguments
<number>
,[<places (default 0)>]
- Output
- Rounds a number to a specified place. If no
places
is specified it will round to the int. No decimal is added if it’s set to 0.
EXAMPLE
Input: round(5.3333, 2)
Output: 5.33
Replace
This function replaces matches in a string.
- Name
replace
- Arguments
<findString>
,<input>
,<replaceTo>
,[literal/regex/upper_lower]
- Output
- Replaces all matches in
<input>
of<findString>
with<replaceTo>
. An optional value of find type ofliteral
,regex
, orupper_lower
.literal
is the default.
EXAMPLE
Input: [replace('''\[(.+)\]''', 'I can use [regex] now in functions', $1, regex)]
Output: I can use regex now in functions
OwO
This function uses OwO to owo text.
- Name
owo
- Arguments
<text>
- Output
- OwO’s
<text>
EXAMPLE
Input: owo('This is very very cool lol <3')
Output: Thais is vewy vewy coow wow <3
Roman Numeral
Converts an integer to a romal numeral.
- Name
romannumeral
- Arguments
<number>
- Output
- Converts
<number>
to roman numeral.
EXAMPLE
Input: romannumeral(321)
Output: CCCXXI
Null
Evaluates any amount of arguments and returns a blank string.
- Name
null
- Arguments
<any>...
- Output
- Evaluates each argument and then returns a blank string. If a function/variable is invalid within it, it will still throw an error.
EXAMPLE
Input: null()
Output: null
Time
Gets the current time in a specially formatted way.
- Name
time
- Arguments
<time format>
- Output
- Formats the current time based off of DateTimeFormatter
EXAMPLE
Input: 'Date: ' + time('yyyy-MM-dd')
Output: Date: 2022-01-18