Molang General Functions
These are the "Standard Functions."
Name | Description | Usage |
---|---|---|
print(message: String)
|
Logs a message into the Minecraft console. | q.print('Hello World!')
|
set_query | IDK | IDK |
replace(text: String, search: String, replace: String): String
|
Replaces all occurrences of substring search inside of text with the value of replace .
|
q.replace('Hexxo Worxd!', 'x', 'l')
|
is_blank(value: MoValue): Double
|
Checks if the passed value is either a blank string (empty or only whitespace) or a double equal to only 0.0 .
|
q.isBlank(' ')
|
run_command(command: String): Double?
|
Runs a command, only works as a server. Returns 0.0 if run as a client.
|
q.run_command('say Hello World')
|
is_int(val: MoValue): Double
|
Returns 1.0 if a value is an integer, otherwise returns 0.0 .
|
q.is_int(1)
|
is_number(val: MoValue): Double
|
Returns 1.0 a value is a double, otherwise returns 0.0 .
|
q.is_number(3.14)
|
to_number(value: MoValue): Double
|
Tries to cast to a double, returns 0.0 if the cast fails.
|
q.to_number('3.14')
|
to_int(val: MoValue): Double
|
Tries to cast to an integer, return 0 if it fails.
|
q.to_int('3')
|
to_string(val: MoValue): String
|
Casts value to a string. | q.to_string(123)
|
do_effect_walks(): Double
|
Returns 1.0 if the config has walkingInBattleAnimations set to true, otherwise returns 0.0 .
|
q.do_effect_walks(): Double
|
random(options: MoValue...)
|
Takes a list of values and chooses one by random. | q.random(1, 2, 3, 4, 5)
|
curve(curveName: String): ObjectValue<(Float) -> Float>
|
Returns a WaveFunction by the curveName . (Options found here)
|
q.curve('symmetrical')
|
array(values: MoValue...): ArrayStruct<MoValue>
|
Returns an array from the parameters. | q.array(1, 2, 3, 4, 5)
|
run_script(identifier: String): MoValue
|
Runs a script from an identifier . Returns the result of the script or 0.0 if it fails.
|
q.run_script('cobblemon:npc_battle_cooling_down')
|
run_molang(expression: String): MoValue
|
Parses a MoLang expression and resolves it using the same context as the MoLang that called it. | q.run_molang('q.print(\'Hello World!\')')
|
system_time_millis(): Double
|
Returns the value of the system’s time in milliseconds. | q.system_time_millis()
|
date_local_time(): String
|
Returns the current date in "DD/MM/YYYY" format. | q.date_local_time()
|
date_of(millis: Double): String
|
Takes epoch milliseconds and formats it in "DD/MM/YYYY" format. | q.date_of(1000000)
|
date_is_after(dateA: String, dateB: String): Double
|
Takes two dates in format "DD/MM/YYYY" and returns 1.0 if the first date is after the second date.
|
q.date_is_after('01/01/2024', '02/01/2024')
|