Skip to content

Conditional Visibility

Conner Olsen edited this page Aug 19, 2026 · 10 revisions

Any CMM setting or CMF element (action bar buttons) can optionally use a Scripted GUI for dynamic visibility or enabled state.

CMM Settings

Create a Scripted GUI named [Your_Mod_ID]__[Your_Setting_ID]_on_changed with an is_shown block to conditionally hide a setting:

cmm_example__example_toggle_on_changed = {
	scope = country

	is_shown = {
		# Only show this setting if another setting is enabled
		"variable_map(cmm|flag:cmm_example__some_other_setting)" >= 1
	}
}

Add an is_valid block to grey out and disable a setting's control while keeping it visible:

cmm_example__example_toggle_on_changed = {
	scope = country

	is_valid = {
		# Only allow changing this setting while another setting is enabled
		"variable_map(cmm|flag:cmm_example__some_other_setting)" >= 1
	}
}

is_shown and is_valid can be combined in the same Scripted GUI.

A group with no visible settings is hidden automatically, and this cascades upward: a tab with no visible groups, and a mod with no visible tabs, are hidden too.

For settings lists, add is_shown or is_valid to the list's _on_changed Scripted GUI:

cmm_example__example_list_on_changed = {
	scope = country

	is_shown = {
		# condition
	}

	effect = {
		cmm_apply_list_change = {
			setting = cmm_example__example_list
		}
	}
}

Action Bar Buttons

Create a Scripted GUI named the same as the element and register it with cmf_register_scripted_gui:

# In your registration effect, after cmf_add_action_bar_element:
cmf_register_scripted_gui = {
	element = cmf_action_bar_element_example
}
cmf_action_bar_element_example = {
	scope = country

	is_valid = {
		# Optional: button is greyed out when this returns false
	}

	is_shown = {
		# Optional: button is hidden when this returns false
	}
}

Button clicks are handled via cmf_on_callback.

Clone this wiki locally