MoLang Function Reference
MoLang Function Reference
Section titled “MoLang Function Reference”Venture uses MoLang scripting for flexible, data-driven venture creation. This reference documents all available functions, query structures, and scripting capabilities.
Query Structures
Section titled “Query Structures”Player Context (q.player)
Section titled “Player Context (q.player)”Available in all script contexts. Provides access to the player who started the venture.
Basic Properties
Section titled “Basic Properties”q.player.name // Player username (String)q.player.uuid // Player UUID (String)Communication
Section titled “Communication”q.player.tell(message) // Send chat message to playerq.player.tell_minimessage(msg) // Send MiniMessage formatted messageCommands
Section titled “Commands”q.run_command(command) // Execute server command// Example: q.run_command('give ' + q.player.name + ' minecraft:diamond 5')PC Access
Section titled “PC Access”q.player.pc.find_by_properties(properties)// Find Pokemon in PC matching Cobblemon property string// Returns: count of matching Pokemon// Example: q.player.pc.find_by_properties('species=pikachu shiny')Pokémon Context (q.pokemon)
Section titled “Pokémon Context (q.pokemon)”Available in pokemon_requirements and reward scripts. Provides access to individual Pokémon.
Basic Properties
Section titled “Basic Properties”q.pokemon.species.name // Species name (e.g., "Pikachu")q.pokemon.level // Current level (Integer)q.pokemon.nickname // Nickname (String, empty if none)q.pokemon.form // Form name (String)q.pokemon.ability // Ability name (String)q.pokemon.gender // Gender string ("MALE", "FEMALE", "NEUTRAL")q.pokemon.nature // Nature name (String)q.pokemon.tera_type // Terastal type (String)q.pokemon.ot // Original Trainer name (String)q.pokemon.owner_uuid // Owner UUID (String)// Individual Values (IVs)q.pokemon.ivs.hp // HP IV (0-31)q.pokemon.ivs.atk // Attack IV (0-31)q.pokemon.ivs.def // Defense IV (0-31)q.pokemon.ivs.spa // Special Attack IV (0-31)q.pokemon.ivs.spd // Special Defense IV (0-31)q.pokemon.ivs.spe // Speed IV (0-31)
// Effort Values (EVs)q.pokemon.evs.hp // HP EV (0-255)q.pokemon.evs.atk // Attack EV (0-255)q.pokemon.evs.def // Defense EV (0-255)q.pokemon.evs.spa // Special Attack EV (0-255)q.pokemon.evs.spd // Special Defense EV (0-255)q.pokemon.evs.spe // Speed EV (0-255)Matching
Section titled “Matching”q.pokemon.matches(properties) // Test against Cobblemon property string// Returns: 1.0 if matches, 0.0 if not// Example: q.pokemon.matches('type=fire level=50..100')
q.pokemon.has_aspect(aspect) // Check for specific aspect// Returns: 1.0 if has aspect, 0.0 if not// Example: q.pokemon.has_aspect('shiny')
q.pokemon.is_type(type) // Check if Pokemon has type// Returns: 1.0 if has type, 0.0 if not// Example: q.pokemon.is_type('fire')Selected Pokémon Context (q.selected_pokemon)
Section titled “Selected Pokémon Context (q.selected_pokemon)”Available in pokemon_requirements for multi-Pokémon validation.
q.selected_pokemon // Returns array of all currently selected Pokemonq.selected_pokemon(index) // Access specific Pokemon by index (0-based)q.selected_pokemon.size // Number of selected Pokemon
// Example: Check if all selected are fire typefor_each(t.pkmn, q.selected_pokemon, { t.pkmn.is_type('fire') == 0.0 ? return 0.0;});return 1.0;Venture Context
Section titled “Venture Context”Available in tick_script for accessing venture state.
q.venture_type() // VentureType structq.venture_type.id // Venture ID (String)q.venture_type.name // Venture display name (String)q.venture_type.duration // Duration in milliseconds (Long)
q.end_time() // End timestamp (milliseconds)q.elapsed_time() // Milliseconds elapsed since startq.ticks_elapsed() // Game ticks elapsed (20 ticks = 1 second)q.venture_level() // Venture level (Integer, currently always 1)Pokémon Manipulation Functions
Section titled “Pokémon Manipulation Functions”Experience Functions
Section titled “Experience Functions”// Single Pokemon (in reward scripts)q.pokemon(index).add_xp(amount) // Add XP to specific Pokemonq.pokemon(index).set_xp(amount) // Set total XPq.pokemon(index).get_xp() // Get current XP
// All Pokemonq.add_xp_all(amount) // Add XP to all Pokemon in ventureq.set_xp_all(amount) // Set XP for all Pokemon
// Example: Give 200 XP to first Pokemonq.pokemon(0).add_xp(200);
// Example: Give 100 XP to allq.add_xp_all(100);IV (Individual Value) Functions
Section titled “IV (Individual Value) Functions”// Single Pokemonpokemon.set_iv(stat, value) // Set IV for a stat (0-31)// Stats: "hp", "atk", "def", "spa", "spd", "spe"// Example: pokemon.set_iv('atk', 31)
// All Pokemonq.set_iv_all(stat, value) // Set IV for all Pokemonq.add_iv_all(stat, amount) // Add to IV (clamped to 0-31)
// Example: Set all Attack IVs to 31q.set_iv_all('atk', 31);
// Example: Add 5 to all Speed IVsq.add_iv_all('spe', 5);EV (Effort Value) Functions
Section titled “EV (Effort Value) Functions”// Single Pokemonpokemon.set_ev(stat, value) // Set EV for a stat (0-255, respects 510 total)// Automatically enforces EV limits
// All Pokemonq.set_ev_all(stat, value) // Set EV for all Pokemonq.add_ev_all(stat, amount) // Add to EV (respects limits)
// Example: Set Special Attack EV to 252pokemon.set_ev('spa', 252);
// Example: Add 10 EVs to all Pokemon's Speedq.add_ev_all('spe', 10);Move Functions
Section titled “Move Functions”pokemon.learn_move(move_id) // Add move to benched moves// Note: Adds to benched moves, not active moveset// Example: pokemon.learn_move('earthquake')Property Application
Section titled “Property Application”pokemon.apply(property_string) // Apply Cobblemon property string// Can modify species, level, aspects, etc.// Example: pokemon.apply('level=100 shiny')
q.apply_to_all(property_string) // Apply property to all Pokemon// Example: q.apply_to_all('level=50')Item Functions
Section titled “Item Functions”pokemon.clear_held_item() // Remove held itemCollection Functions
Section titled “Collection Functions”Multi-Pokémon Queries
Section titled “Multi-Pokémon Queries”q.any_match(expression) // Returns 1.0 if ANY Pokemon matches expressionq.all_match(expression) // Returns 1.0 if ALL Pokemon match expression
// Example: Check if any Pokemon is shinyq.any_match(q.pokemon.has_aspect('shiny'))
// Example: Check if all Pokemon are level 50+q.all_match(q.pokemon.level >= 50.0)Iteration
Section titled “Iteration”for_each(variable, array, { script })// Execute script for each element in array// 'variable' is accessible inside the block
// Example: Add XP to each Pokemonfor_each(t.pkmn, q.pokemon, { t.pkmn.add_xp(200); q.player.tell(t.pkmn.species.name + ' gained 200 XP!');});Requirement Building Functions
Section titled “Requirement Building Functions”These functions add lines to requirement tooltips and failure messages.
q.add_requirement(text) // Add requirement line to tooltipq.append_fail_message(text) // Add failure message when requirement not metq.add_reward_line(text) // Add reward line to tooltip
// Example: Add requirement with failure messageq.add_requirement('All Pokemon must be level 30+');q.pokemon.level < 30.0 ? { q.append_fail_message(q.pokemon.species.name + ' is only level ' + q.pokemon.level); return 0.0;};Persistent Variables
Section titled “Persistent Variables”Venture Variables (v.)
Section titled “Venture Variables (v.)”Store state across tick script executions. Variables persist for the duration of the venture.
v.variable_name // Access/create venture variablev.variable_name = value // Set variable value
// Example: Track treasure discoveriesv.treasures_found == 0.0 ? v.treasures_found = 0.0; // Initializev.treasures_found = v.treasures_found + 1.0; // Increment
// Example: Store item IDv.item_type = 'minecraft:diamond';Temporary Variables (t.)
Section titled “Temporary Variables (t.)”Used for temporary calculations within a single script execution. Reset between executions.
t.temp_value = calculation // Store temporary resultt.result = math.min(a, b) // Use in calculations
// Example: Calculate team sizet.team_size = q.pokemon.size;t.xp_per_pokemon = 500.0 / t.team_size;Utility Functions
Section titled “Utility Functions”Math Functions
Section titled “Math Functions”math.random_integer(min, max) // Random integer (inclusive)math.min(a, b) // Minimum valuemath.max(a, b) // Maximum valuemath.floor(value) // Round downmath.ceil(value) // Round upmath.sin(value) // Sine functionmath.cos(value) // Cosine function
// Example: Random treasure rollt.roll = math.random_integer(1, 100);t.roll <= 5.0 ? { q.player.tell('Found treasure!');};Array Functions
Section titled “Array Functions”q.array(item1, item2, ...) // Create arrayarray[index] // Access element by indexarray.size // Array length
// Example: Random selectiont.options = q.array('diamond', 'emerald', 'gold');t.index = math.random_integer(0, 2);t.selected = t.options[t.index];Control Flow
Section titled “Control Flow”condition ? true_value : false_value // Ternary operator
// Example: Level-based rewardt.xp_bonus = q.pokemon.level >= 50.0 ? 500.0 : 200.0;Complete Examples
Section titled “Complete Examples”Simple XP Reward
Section titled “Simple XP Reward”scripts: [ """ // Give 200 XP to all Pokemon for_each(t.pkmn, q.pokemon, { t.pkmn.add_xp(200); }); """]Complex Requirement Validation
Section titled “Complex Requirement Validation”pokemon_requirements: [ """ // Require level 30+ q.pokemon.level < 30.0 ? { q.append_fail_message(q.pokemon.species.name + ' must be level 30+'); return 0.0; };
// Require fire or water type t.valid_type = q.pokemon.is_type('fire') || q.pokemon.is_type('water'); t.valid_type == 0.0 ? { q.append_fail_message('Must be Fire or Water type!'); return 0.0; };
return 1.0; """]Multi-Pokémon Team Validation
Section titled “Multi-Pokémon Team Validation”pokemon_requirements: [ """ // Count types in selection t.fire_count = 0.0; t.water_count = 0.0;
for_each(t.p, q.selected_pokemon, { t.fire_count = t.p.is_type('fire') ? t.fire_count + 1.0 : t.fire_count; t.water_count = t.p.is_type('water') ? t.water_count + 1.0 : t.water_count; });
// Require at least one of each t.fire_count > 0.0 && t.water_count > 0.0 ? return 1.0 : { q.append_fail_message('Team must include both Fire and Water types!'); return 0.0; }; """]Dynamic Reward with Venture Variables
Section titled “Dynamic Reward with Venture Variables”tick_script: [ """ // Initialize treasure counter v.treasures == 0.0 ? v.treasures = 0.0;
// Check every 10 seconds (200 ticks) t.time = q.ticks_elapsed; (t.time % 200) == 0.0 ? { // 5% chance to find treasure t.roll = math.random_integer(1, 100); t.roll <= 5.0 ? { v.treasures = v.treasures + 1.0; q.player.tell('<gold>Found treasure #' + v.treasures + '!'); }; }; """]
rewards: [ { type: script scripts: [ """ // Give treasures found during venture t.count = v.treasures; t.count > 0.0 ? { q.run_command('give ' + q.player.name + ' minecraft:diamond ' + t.count); q.player.tell('Received ' + t.count + ' diamonds!'); }; """ ] }]Progressive EV Training
Section titled “Progressive EV Training”rewards: [ { type: script reward_string: "+10 Speed EVs per Pokemon" scripts: [ """ for_each(t.pkmn, q.pokemon, { // Get current Speed EV t.current = t.pkmn.evs.spe;
// Add 10, cap at 252 t.new_value = math.min(252, t.current + 10.0);
// Apply t.pkmn.set_ev('spe', t.new_value);
// Notify q.player.tell(t.pkmn.species.name + ' gained 10 Speed EVs!'); }); """ ] }]Best Practices
Section titled “Best Practices”Variable Naming
Section titled “Variable Naming”- Use
v.for persistent venture state - Use
t.for temporary calculations - Use descriptive names:
t.team_sizenott.x
Error Handling
Section titled “Error Handling”- Always validate before operations
- Provide clear failure messages
- Use defensive checks:
v.counter == 0.0 ? v.counter = 0.0;
Performance
Section titled “Performance”- Minimize operations in tick_script
- Use modulo for periodic checks:
(q.ticks_elapsed % 100) == 0.0 - Cache calculated values in temporary variables
Readability
Section titled “Readability”- Use multi-line strings for complex scripts
- Add comments explaining logic
- Break complex operations into steps
Common Patterns
Section titled “Common Patterns”Type-Based Rewards
Section titled “Type-Based Rewards”for_each(t.pkmn, q.pokemon, { t.pkmn.is_type('fire') ? q.run_command('give ' + q.player.name + ' cobblemon:charcoal'); t.pkmn.is_type('water') ? q.run_command('give ' + q.player.name + ' cobblemon:mystic_water');});Level-Scaled XP
Section titled “Level-Scaled XP”for_each(t.pkmn, q.pokemon, { t.base_xp = 100.0; t.bonus = t.pkmn.level >= 50.0 ? 50.0 : 0.0; t.pkmn.add_xp(t.base_xp + t.bonus);});Shiny Detection
Section titled “Shiny Detection”q.any_match(q.pokemon.has_aspect('shiny')) ? { q.player.tell('<rainbow>A shiny Pokemon returned!</rainbow>'); q.run_command('give ' + q.player.name + ' cobblemon:shiny_charm');};Conditional Item Rewards
Section titled “Conditional Item Rewards”t.high_level_count = 0.0;for_each(t.p, q.pokemon, { t.high_level_count = t.p.level >= 75.0 ? t.high_level_count + 1.0 : t.high_level_count;});
t.high_level_count >= 3.0 ? { q.run_command('give ' + q.player.name + ' cobblemon:ability_capsule'); q.player.tell('Bonus reward for high-level team!');};