Skip to content

Introduction to MoLang Extensions

MoLang Extensions adds modern programming constructs to Cobblemon’s bundled MoLang scripting language — functions, conditionals, loops, structs, imports, and more.

Functions

Define reusable fn() functions with parameters and return values

Control Flow

if/else, switch(), and while() for readable logic

Module System

import() MoLang files from data packs to share code across scripts

Quality of Life

Compound operators, member access on expressions, comments, and structs

Define and call a function:

fn('heal', v.target, v.amount, {
v.target.health = math.min(v.target.health + v.amount, v.target.max_health);
return v.target.health;
});
v.result = f.heal(v.pikachu, 20);

Readable conditionals instead of ternary chains:

if (v.health > 50) {
v.status = 'healthy';
} else if (v.health > 0) {
v.status = 'wounded';
} else {
v.status = 'dead';
};

Loop over a party:

t.i = 0;
while(t.i < t.party_size, {
t.mon = q.player.party.get_pokemon(t.i);
t.mon.add_exp(100);
t.i += 1;
});
  • Minecraft 1.21.1+
  • Fabric Loader 0.16.0+
  • Fabric API
  • Fabric Language Kotlin
  • Cobblemon