Molang Scripting
Molang Scripting
Section titled “Molang Scripting”Journey extends Cobblemon’s powerful Molang scripting system with custom functions for creating dynamic, conditional logic in tasks, zones, timelines, and other systems. This guide covers the proper Molang language syntax and all available Journey-specific functions.
Table of Contents
Section titled “Table of Contents”- Molang Language Fundamentals
- Journey Player Functions
- Journey NPC Functions
- Cobblemon Core Functions
- Advanced Molang Techniques
Molang Language Fundamentals
Section titled “Molang Language Fundamentals”What is Molang?
Section titled “What is Molang?”Molang is a simple expression-based language designed for fast, data-driven calculation of values at run-time. It uses C-family syntax and is case-insensitive (except for strings).
Reference: Bedrock Dev Molang Documentation
Basic Syntax Structure
Section titled “Basic Syntax Structure”# Function callsmath.sin(query.life_time * 180.0)math.random(0, 100)
# Conditional expressions (ternary operator)query.health > 10 ? 1.0 : 0.0
# Boolean logicquery.health > 50 && query.is_on_ground
# Comparison operatorsquery.health >= query.max_healthquery.life_time != 0Data Types
Section titled “Data Types”Numbers
Section titled “Numbers”# All numbers are treated as floating-point423.14159-25.50.0Booleans
Section titled “Booleans”# Booleans are converted to numbers: false = 0.0, true = 1.0true # becomes 1.0false # becomes 0.0
# Boolean expressionsquery.health > 0 # evaluates to 1.0 or 0.0query.is_baby == false # evaluates to 1.0 or 0.0Strings
Section titled “Strings”# Strings are case-sensitive and enclosed in single quotes'Hello World''minecraft:diamond''task_complete'Operators
Section titled “Operators”Mathematical Operators
Section titled “Mathematical Operators”10 + 5 # Addition: 1510 - 5 # Subtraction: 510 * 5 # Multiplication: 5010 / 5 # Division: 2Comparison Operators
Section titled “Comparison Operators”10 < 5 # Less than: 0.0 (false)10 <= 10 # Less than or equal: 1.0 (true)10 > 5 # Greater than: 1.0 (true)10 >= 10 # Greater than or equal: 1.0 (true)10 == 10 # Equal: 1.0 (true)10 != 5 # Not equal: 1.0 (true)Logical Operators
Section titled “Logical Operators”true && false # Logical AND: 0.0 (false)true || false # Logical OR: 1.0 (true)!true # Logical NOT: 0.0 (false)Conditional Operator
Section titled “Conditional Operator”# Ternary operator: condition ? value_if_true : value_if_falsequery.health > 10 ? 'healthy' : 'injured'query.is_baby ? 0.5 : 1.0Journey Player Functions
Section titled “Journey Player Functions”These functions are available when the context includes a player (e.g., in task filters, rewards, timeline conditions). All functions are called on the player object in Molang scripts.
Task Management Functions
Section titled “Task Management Functions”# Check if a player has an active taskq.player.has_task('namespace:task_id') # Returns 1.0 if task is active, 0.0 if not
# Check if a player has an active subtaskq.player.has_subtask('namespace:task_id', 'subtask_name') # Returns 1.0 if subtask exists, 0.0 if not
# Check if a player has completed a specific taskq.player.has_completed_task('namespace:task_id') # Returns 1.0 if completed, 0.0 if not
# Check if a player has completed a specific subtaskq.player.has_completed_subtask('namespace:task_id', 'subtask_name') # Returns 1.0 if completed, 0.0 if not
# Start a new task for the playerq.player.start_task('namespace:task_id') # Returns 1.0 on success, 0.0 on failurePlayer Level
Section titled “Player Level”# Get the player's Minecraft XP levelq.player.level # Returns XP level as number (e.g., 30.0)Inventory Management Functions
Section titled “Inventory Management Functions”# Check if player has an item (with optional count)q.player.has_item('minecraft:diamond') # Returns 1.0 if has at least 1q.player.has_item('minecraft:diamond', 5) # Returns 1.0 if has at least 5
# Remove items from player's inventoryq.player.remove_item('minecraft:diamond', 1) # Removes 1 diamondPokémon Management Functions
Section titled “Pokémon Management Functions”# Get player's Pokédex data structureq.player.pokedex() # Returns pokedex struct
# Get player's starter Pokémon dataq.player.starter_pokemon() # Returns starter pokemon struct or 0.0
# Check if player has a Pokémon matching specific criteriaq.player.has_party_pokemon_matching('species=pikachu') # Returns 1.0 if found, 0.0 if not
# Remove a Pokémon from player's party by slot indexq.player.remove_party_pokemon(0) # Removes Pokémon in slot 0 (first slot)
# Find party slot for a Pokémon matching criteriaq.player.party_slot_for_pokemon('species=pikachu') # Returns slot index (0-5) or -1.0 if not foundZone Management Functions
Section titled “Zone Management Functions”# Check if player is in a specific zoneq.player.is_in_zone('zone_uuid_here') # Returns 1.0 if in zone, 0.0 if notFlag System Functions
Section titled “Flag System Functions”# Check if player has a flag setq.player.has_flag('flag_name') # Returns 1.0 if flag exists, 0.0 if not
# Add a flag to the playerq.player.add_flag('flag_name')
# Remove a flag from the playerq.player.remove_flag('flag_name')Note: Flags are boolean only. There is no support for numeric flags, expiry times, or flag values in the current implementation.
Levelable System Functions
Section titled “Levelable System Functions”# Get the current level of a levelable skillq.player.levelable_level('levelable_id') # Returns current level as number
# Get the current experience points of a levelable skillq.player.levelable_experience('levelable_id') # Returns current XP as number
# Check if player has a specific levelable skill unlockedq.player.has_levelable('levelable_id') # Returns 1.0 if unlocked, 0.0 if not
# Give a player access to a levelable skillq.player.give_levelable('levelable_id')
# Add experience to a levelable skillq.player.progress_levelable('levelable_id', 100) # Adds 100 XP, returns 1.0 on success
# Remove a levelable skill from the playerq.player.remove_levelable('levelable_id')Entity Visibility Functions
Section titled “Entity Visibility Functions”# Make player start seeing a specific entityq.player.start_watching_entity('entity_uuid')
# Make player stop seeing a specific entityq.player.stop_watching_entity('entity_uuid')Visual Effects Functions
Section titled “Visual Effects Functions”# Spawn a snowstorm particle at a position for the playerq.player.snowstorm_particle('particle_id', x, y, z)
# Play an animation on an entity that only this player can seeq.player.play_per_player_entity_animation('entity_uuid', 'animation_name') # Returns 1.0 on successMovement and Physics Functions
Section titled “Movement and Physics Functions”# Apply a force push to the playerq.player.push(x, y, z, force) # x, y, z = direction vector, force = strengthCommunication Functions
Section titled “Communication Functions”# Send a formatted message to the player using MiniMessage formattingq.player.tell_minimessage('<red>Warning!</red> <gold>Something happened</gold>')Command and Script Execution Functions
Section titled “Command and Script Execution Functions”# Execute a server command, replacing {player} with the player's nameq.player.execute_command('give {player} minecraft:diamond 1')
# Launch a timeline sequence for the playerq.player.launch_timeline('timeline_name')Battle Management Functions
Section titled “Battle Management Functions”# Force the player to exit their current battleq.player.stop_battle() # Returns 1.0 on successPath Visualization Functions (Debug)
Section titled “Path Visualization Functions (Debug)”# Toggle path visualization on/offq.player.toggle_path_visualization() # Returns 1.0 if enabled, 0.0 if disabled
# Show or hide path visualizationq.player.show_path_visualization(1.0) # 1.0 to show, 0.0 to hideq.player.show_path_visualization(0.0)
# Preview a specific pathq.player.preview_path('path_id') # Returns 1.0 on success, 0.0 if path not foundQuest Backpack Functions
Section titled “Quest Backpack Functions”The quest backpack is a separate inventory for quest-related items that persists across sessions.
# Add an item to the backpackq.player.backpack_add_item('minecraft:diamond') # Adds 1 item, returns 1.0 on successq.player.backpack_add_item('minecraft:diamond', 5) # Adds 5 items
# Check if backpack has an itemq.player.backpack_has_item('minecraft:diamond') # Returns 1.0 if has at least 1q.player.backpack_has_item('minecraft:diamond', 5) # Returns 1.0 if has at least 5
# Remove items from backpackq.player.backpack_remove_item('minecraft:diamond', 1) # Removes 1, returns count removed
# Count items in backpackq.player.backpack_count_item('minecraft:diamond') # Returns count as number
# Check free slotsq.player.backpack_free_slots() # Returns number of empty slots
# Clear all itemsq.player.backpack_clear() # Returns 1.0
# Open backpack GUI for playerq.player.backpack_open() # Returns 1.0
# Configured item functions (use item IDs from config)q.player.backpack_give_configured('quest_key', 1) # Give configured itemq.player.backpack_has_configured('quest_key', 1) # Check for configured itemq.player.backpack_remove_configured('quest_key', 1) # Remove configured itemBuff System Functions
Section titled “Buff System Functions”Apply and manage temporary buffs on players.
# Check if player has a specific buffq.player.has_buff('speed_boost') # Returns 1.0 if buff active
# Get buff detailsq.player.buff_amplifier('speed_boost') # Returns amplifier level or -1.0q.player.buff_remaining_ticks('speed_boost') # Returns remaining ticks or -1.0q.player.buff_count('speed_boost') # Returns count of this buff type
# Apply a buff (duration in ticks, -1 for infinite)q.player.apply_buff('speed_boost') # Default duration, amplifier 0q.player.apply_buff('speed_boost', 1200) # 1 minute (1200 ticks)q.player.apply_buff('speed_boost', 1200, 2) # Duration with amplifier 2q.player.apply_buff('speed_boost', 1200, 2, 'quest') # With source tag
# Remove buffsq.player.remove_buff('speed_boost') # Remove by ID, returns count removedq.player.remove_buff_by_source('quest') # Remove all buffs from sourceq.player.clear_buffs() # Remove all buffs, returns countCutscene Functions
Section titled “Cutscene Functions”Control cinematic cutscene playback.
# Play a cutscene for the playerq.player.play_cutscene('intro_cutscene') # Returns 1.0 on success
# Stop current cutsceneq.player.stop_cutscene() # Returns 1.0
# Check cutscene stateq.player.in_cutscene() # Returns 1.0 if in cutsceneq.player.cutscene_progress() # Returns 0.0-1.0 progressParty System Functions
Section titled “Party System Functions”Access party information for the player.
# Get party struct (returns struct with party functions)q.player.player_party()
# Party struct functions:q.player.player_party().exists() # 1.0 if in a partyq.player.player_party().size() # Number of membersq.player.player_party().is_leader() # 1.0 if player is leaderq.player.player_party().has_member('PlayerName') # 1.0 if member existsq.player.player_party().leader_name() # Leader's name stringq.player.player_party().name() # Party name stringq.player.player_party().max_members() # Max allowed membersq.player.player_party().is_public() # 1.0 if party is publicAdditional Levelable Functions
Section titled “Additional Levelable Functions”# Get the currently active levelableq.player.active_levelable() # Returns levelable ID or 'none'
# Check if a levelable is currently activeq.player.is_levelable_active('trainer_rank') # Returns 1.0 if active
# Switch the active levelable (for SINGLE_ACTIVE mode)q.player.switch_active_levelable('trainer_rank') # Returns 1.0 on success
# Get the current levelable modeq.player.levelable_mode() # Returns 'exclusive', 'single_active', or 'multi_active'Journey NPC Functions
Section titled “Journey NPC Functions”These functions are available in NPC contexts (Cobblemon NPC dialogues, interactions). All functions are called on the npc object.
Animation and Particle Functions
Section titled “Animation and Particle Functions”# Play an animation on the NPCnpc.play_animation('animation_name') # Show to all nearby playersnpc.play_animation('animation_name', 'player_uuid') # Show to specific player only
# Spawn a particle effect attached to the NPCnpc.snowstorm_entity_particle('particle_id', 'locator') # All playersnpc.snowstorm_entity_particle('particle_id', 'locator', 'player_uuid') # Specific player
# Spawn a particle effect at a position relative to the NPCnpc.snowstorm_particle('particle_id', x, y, z) # All playersnpc.snowstorm_particle('particle_id', x, y, z, 'player_uuid') # Specific playerCommunication Functions
Section titled “Communication Functions”# Make the NPC say a messagenpc.say('Hello! I am %npc%!') # %npc% is replaced with NPC namenpc.say('Hello, player!', 'player_uuid') # Send to specific player onlyDistance and Location Functions
Section titled “Distance and Location Functions”# Get distance between NPC and a specific playernpc.distance_to_player('player_uuid') # Returns distance in blocksPath Walking System Functions
Section titled “Path Walking System Functions”# Start walking a pathnpc.walk_path('path_id') # Returns 1.0 on success, 0.0 on failure
# Stop walking current pathnpc.stop_walking() # Returns 1.0 on success, 0.0 on failure
# Pause path walkingnpc.pause_walking() # Returns 1.0 on success, 0.0 on failure
# Resume path walkingnpc.resume_walking() # Returns 1.0 on success, 0.0 on failure
# Check if NPC is currently walking a pathnpc.is_walking_path() # Returns 1.0 if walking, 0.0 if not
# Get walking progress percentagenpc.walking_progress() # Returns 0.0-100.0 percentage
# Assign a path to the NPCnpc.assign_path('path_id') # Auto-start enabled by defaultnpc.assign_path('path_id', 0.0) # Auto-start disabled (0.0 = false)
# Unassign the current path from the NPCnpc.unassign_path() # Returns 1.0 on success
# Check if NPC has an assigned pathnpc.has_assigned_path() # Returns 1.0 if has path, 0.0 if not
# Get the assigned path IDnpc.get_assigned_path() # Returns path ID string or empty stringNPC Visibility Functions
Section titled “NPC Visibility Functions”Control per-player NPC visibility with conditional logic.
# Set a visibility condition for all playersnpc.set_visibility_condition("q.player.has_flag('can_see_ghosts')")
# Set visibility condition for a specific playernpc.set_player_visibility('player-uuid', "q.player.levelable_level('perception') >= 10")
# Force show/hide for specific player (bypasses conditions)npc.force_show_to_player('player-uuid') # Returns 1.0 on successnpc.force_hide_from_player('player-uuid') # Returns 1.0 on success
# Check if NPC is visible to a playernpc.is_visible_to_player('player-uuid') # Returns 1.0 if visible
# Force visibility update for all playersnpc.update_visibility() # Returns 1.0Cobblemon Core Functions
Section titled “Cobblemon Core Functions”Journey integrates with Cobblemon’s extensive Molang functions. For the complete list of Cobblemon functions, refer to Cobblemon’s documentation.
Math Functions
Section titled “Math Functions”# Basic mathmath.abs(-5) # Absolute value: 5math.ceil(4.2) # Ceiling: 5math.floor(4.8) # Floor: 4math.round(4.6) # Round: 5math.sqrt(16) # Square root: 4math.pow(2, 3) # Power: 8
# Trigonometric functionsmath.sin(90) # Sinemath.cos(0) # Cosinemath.tan(45) # Tangent
# Random functionsmath.random() # Random 0.0-1.0math.random(1, 10) # Random integer 1-10Advanced Molang Techniques
Section titled “Advanced Molang Techniques”Complex Conditional Logic
Section titled “Complex Conditional Logic”# Nested conditions for quest eligibilityq.player.has_completed_task('gym_badge_1') &&q.player.has_completed_task('gym_badge_2') &&q.player.levelable_level('trainer_rank') >= 25 ? 1.0 : 0.0Zone-Specific Logic
Section titled “Zone-Specific Logic”# Different behavior per zoneq.player.is_in_zone('pvp_arena_uuid') ? (q.player.levelable_level('combat') >= 30 ? 1.0 : 0.0) :q.player.is_in_zone('safe_zone_uuid') ? 1.0 : 0.0Pokémon-Based Conditions
Section titled “Pokémon-Based Conditions”# Check for specific Pokémon conditionsq.player.has_party_pokemon_matching('species=pikachu shiny=true') &&q.player.has_party_pokemon_matching('species=raichu') ? 1.0 : 0.0
# Find slot and check leveltemp.pikachu_slot = q.player.party_slot_for_pokemon('species=pikachu');temp.pikachu_slot >= 0.0 ? 1.0 : 0.0Performance Best Practices
Section titled “Performance Best Practices”Minimize Function Calls
Section titled “Minimize Function Calls”# Bad: Multiple callsq.player.has_completed_task('task1') && q.player.has_completed_task('task2')
# Better: Use boolean logic efficientlyq.player.has_completed_task('task1') && q.player.has_completed_task('task2')Use Short-Circuit Evaluation
Section titled “Use Short-Circuit Evaluation”# Check cheaper conditions firstq.player.has_flag('eligible') &&q.player.has_completed_task('prerequisite') &&q.player.has_party_pokemon_matching('legendary=true')Important Notes
Section titled “Important Notes”Differences from Documented Systems
Section titled “Differences from Documented Systems”Journey’s MoLang implementation is functional but limited compared to what may be described elsewhere. Specifically:
NOT AVAILABLE:
query.player.*query accessors (useplayer.*functions directly)query.npc.*query accessors (usenpc.*functions directly)query.world_time,query.time_of_day,query.weather(world state queries)- Numeric flags or flag value operations
- Flag expiry times
- Player statistics beyond what’s in Journey data
AVAILABLE:
- All
player.*functions listed in this document - All
npc.*functions listed in this document - Standard Cobblemon query functions (see Cobblemon docs)
- Standard math functions
Event Context Data
Section titled “Event Context Data”When events trigger (e.g., POKEMON_CAUGHT, ENTER_ZONE), they provide event-specific data through the q namespace:
# Example: In a POKEMON_CAUGHT event filterq.pokemon.species.identifier == 'cobblemon:pikachu' && q.pokemon.is_shiny
# Example: In an ENTER_ZONE event filterq.zone.name == 'Pallet Town'
# Example: In a BATTLE_VICTORY event filterq.battle.is_wild && q.battle.team.contains_starterSee the Events Documentation for details on what data each event provides.
This documentation reflects the actual implementation of Journey’s MoLang functions as of the current version.