law_group_name = {
	
	### brief = default ( database key, optional )
	# New rulers will use this law by default, provided its "should_start_with" trigger
	# returns true or is undefined
	#
	default = law_name

	### brief: cumulative ( bool, optional )
	# If set, each subsequent law in the group will provide all effects of the previous law
	# default = no
	#
	cumulative = no

	### brief: flag ( flag )
	# See below for flags with special treatment in code. These flags may also be checked
	# in the data/GUI system with LawGroup.HasFlag('some_arbitrary_flag')
	#
	flag = some_arbitrary_flag

	### brief: cumulative ( bool, optional )
	# If set, this law group is considered part of the Treasury Budget set, and will be displayed within a specific
	# budget interface.
	# default = no
	#
	is_treasury_budget_group = no

	### brief: can_change_law_group ( trigger )
	# Optional trigger for law groups that maybe some rulers should see but cant change
	# Default is leaving this empty - and then it will always be true
	# If this trigger fails - the lawgroup will still be visible but can't be changed by the ruler
	#
	can_change_law_group = { }

	law_name = {

		### brief: can_keep ( trigger )
		# Requirements for keeping the law. If this invalidates, the law will
		# be replaced with the default law (see own section) within a month.
		# Also checked after changing faith since doctrinal changes are likely
		# to invalidate laws. Always true if not specified.
		# Root scope = ruler with the law
		#
		can_keep = { }

		### brief: can_have ( trigger )
		# Requirements for adopting the law in the ruler's scope. If this is true,
		# the character is allowed to adopt the law and the law will show as
		# available (but it can be currently disabled if can_pass is false).
		# Always true if not specified.
		# Root scope = ruler for whom we are checking the law
		#
		can_have = { }

		### brief: can_pass ( trigger )
		# Requirements for adopting the law in the ruler's scope. For more
		# temporary conditions, e.g. being at war ("I can have the law, but
		# can't pass it right now"). Always true if not specified.
		# Root scope = ruler for whom we are checking the law
		#
		can_pass = { }

		### brief: should_start_with ( trigger )
		# If these conditions are true, this is a valid law for a ruler to start
		# with. Note that it always includes the can_keep check.
		# Root scope = ruler for whom we are checking the law
		#
		should_start_with = { }

		### brief: can_title_have ( trigger )
		# Requirements for titles being able to have this law. Always false if
		# not specified.
		# Root scope = title for which we are checking the law
		#
		can_title_have = { }

		### brief: can_realm_have ( trigger )
		# Requirements for characters being able to apply this law at realm level.
		# Always false if not specified.
		# By default, the following succession orders imply they can be applied to the whole realm:
		#	* inheritance
		#	* theocracy
		#	* company
		#	* generate
		#	* appointment
		# Root scope = character for which we are checking the law
		#
		can_realm_have = { }

		### brief: should_show_for_title ( trigger )
		# Should this law be shown in the UI for titles?
		#
		should_show_for_title = { }

		### brief: pass_cost ( scripted cost )
		# The cost of enacting this law
		# Root scope = ruler wanting to pass the law
		#
		pass_cost = { gold/piety/prestige = ... }

		### brief: revoke_cost ( scripted cost )
		# The cost of revoking or clearing this law
		# Root scope = ruler wanting to revoke the law
		#
		revoke_cost = { gold/piety/prestige = ... }

		### brief: modifier ( character modifier )
		# Modifier applied to the ruler when this law is active
		#
		modifier = { }

		### brief: flag ( flag )
		# See below for flags treated specially. Can be checked in script
		# with has_realm_law_flag = some_arbitrary_flag.
		# See below for flags treated specially in code.
		#
		flag = some_arbitrary_flag

		### brief: triggered_flag ( flag )
		# Checks and adds flag only if the trigger's condition is met.
		# Both trigger and flag *must* be specified within this block.
		#
		triggered_flag = {

			# Some trigger, root is the ruler character scope
			#
			trigger = { ... }

			# See below for flags treated specially in code. Can be checked in
			# script with has_realm_law_flag = some_arbitrary_flag
			#
			flag = some_arbitrary_flag
		}

		### brief: shown_in_encyclopedia ( bool, optional )
		# If this law should show up in the Encyclopedia
		# default = yes
		#
		shown_in_encyclopedia = yes

		### brief: on_pass ( effect )
		# Effect run just before law change.
		# Effect run on the ruler when the law is added. Does *NOT* get run
		# when default laws are initialized, nor when inheriting a law from
		# someone else.
		# Root = ruler in question
		# If this is done on a title, the title is accessible as scope:title
		#
		on_pass = { }

		### brief: on_after_pass ( effect )
		# Effect run just after law change.
		# Effect run on the ruler when the law is added. Does *NOT* get run
		# when default laws are initialized, nor when inheriting a law from
		# someone else.
		# Root = ruler in question
		# If this is done on a title, the title is accessible as scope:title
		#
		on_after_pass = { }

		### brief: on_revoke ( effect )
		# Effect run on ruler when the law is removed. Does *NOT* get run when
		# law is removed due to inheriting a law from someone else.
		# Root = ruler in question
		# If this is done on a title, the title is accessible as scope:title
		#
		on_revoke = { }

		### brief: succession ( struct, optional )
		# Succession rules. Any new law with a rule set will override the
		# previous law's rule set.
		# Overriding is in law definition order
		#
		succession = {

			### brief: order_of_succession ( enum )
			# Which order of succession ( provided by code ) does this law use?
			#
			# Options:
			#	inheritance
			#	election
			#	appointment ( requires traversal, division and rank be undefined )
			#	theocratic
			#	company
			#	generate
			#	generate_from_template 
			#	player_heir
			#	noble_family
			#
			order_of_succession = inheritance

			### brief: title_division ( enum )
			# Used to determine how titles are split during succession
			# Requires order_of_succession = inheritance or noble_family
			#
			# Options:
			#	partition ( only available when traversal_order = children )
			#	single_heir ( only valid for inheritance and noble_family order_of_succession )
			#
			title_division = partition

			### brief: traversal_order ( enum )
			# Determines which set of characters is considered when building
			# the line of succession.
			# 
			# Options:
			#	children( may only be defined if title_division = partition )
			#	dynasty
			#	dynasty_house
			#
			traversal_order = children/dynasty_house/dynasty

			### brief: rank ( enum )
			# Determines how characters in the line of succession are sorted
			#
			# Options:
			#	oldest
			#	youngest
			#
			rank = oldest

			### brief: pool_character_config ( database key, situational )
			# Entry in common/pool_character_selectors, used when choosing a
			# character from the pool or generating a new character.
			# Only available for theocratic, company, and generate.
			#
			pool_character_config = key

			### brief: election_type ( database key, situational )
			# Entry in common/succession_election, used to determine which type
			# of election should be used for succession.
			# Only available for election.
			#
			election_type = key

			### brief: appointment_type ( database key, situational )
			# Entry in common/succession_appointment, used to determine which type
			# of appointment should be used for succession.
			# Only available for appointment.
			#
			appointment_type = key


			### Generic Rules

			### brief: gender_law ( enum, optional )
			# Used to determine which gender(s) are valid for succession.
			#
			# Options:
			#	male_only
			#	male_preference
			#	equal
			#	female_preference
			#	female_only
			#
			gender_law = equal

			### brief: gender_law ( enum, optional )
			# Used to determine which faith(s) are valid for succession.
			# If no character fulfilling this requirement is found, the restriction
			# is ignored (but titles with the flag destroy_if_invalid_heir = yes
			# will be destroyed).
			#
			# Options:
			#	same_faith
			#	same_religion
			#	same_family
			#
			faith = same_faith

			### brief: create_primary_tier_titles ( bool, optional )
			# If set, then under partition all titles you can create of your primary
			# tier will be created for free, resulting in a more split-up realm
			# default = no
			#
			create_primary_tier_titles = no

			### brief: primary_heir_minimum_share ( fixed point, optional )
			# If defined, the primary heir will get at least this portion of
			# titles, which means if there's a lot of heirs the primary still
			# gets a guaranteed amount of land
			#
			primary_heir_minimum_share = 0.5

			### brief: exclude_rulers ( bool, optional )
			# If set, the title can not be inherited by rulers (anyone with titles)
			# default = no
			#
			exclude_rulers = no

			### brief: limit_to_courtiers ( bool, optional )
			# If set, only immediate courtiers and away courtiers of a ruler
			# will be allowed to inherit
			# default = no
			#
			limit_to_courtiers = no
		}

		### brief: ai_will_do ( value )
		# Script value in the ruler scope. If above 0, the AI will enact this
		# law if able. Law enactment is checked in the RARE_TASK_TICK. If multiple
		# laws are possible, the AI will enact the one with the highest score.
		# Root scope = ruler in question
		#
		ai_will_do = { ... }
	}

	# Multiple laws can be defined in a single law group.
	another_law_name = {}
}

### NOTES ###

### Inheritance ###
Any heir that goes up one or more tier due to inheritance gets the laws of the dead ruler.
Note that currently the law conditions are not checked in any way for law inheritance.

### Default law ###
All rulers have a single law from each group.
If a group has a default set, that law will be checked first.
Otherwise, or if it is invalid, the laws are checked in definition order.
The first checked law where "should_start_with" returns true (or does not exist) gets used. Note that "can_pass" is ignored entirely when determining a default law.
When a default law is set, "on_pass" is *not* executed

### Title Succession Laws ###
Laws are usually defined for realm. However some succession laws are valid for titles.
This is primary based on order_of_succession:

	Title only:
		player_heir
		election
		noble_family
		generate_from_template
	Realm only:
		inheritance ( title_division = partition )
		theocratic
		company
		generate
	Realm & Title:
		inheritance ( title_division = single_heir )
		appointment

### Associated Localization ###
The key of the law will be used as its name. E.G., law_name: "Law Name"
The key plus "_effects" can optionally be defined to provide custom effects. E.G., law_name_effects: "Does some law thingy"
The key plus "_effects_not_in_prev" can optionally be defined to provide custom effects that should *not* be included when listing effects inherited from earlier laws. E.G., law_name_effects_not_in_prev: "Does some law thingy"

CHARACTER.GetActiveLawInGroupWithFlag('realm_law') - Will get the character's active law in a group. The group must have the given flag. Note that it does not work for dead characters

### Hardcoded Flags ###
Some flags have special meaning, and are used by the game code.

Law Groups:
flag = realm_law - Will show up in My Realm window

Laws:
flag = titles_cannot_leave_realm_on_succession - Disables titles leaving realm when received on succession by someone outside the realm - the respective heirs will be disqualified from succession
flag = men_can_have_multiple_spouses - Allows multiple spouses (if also allowed by faith)
flag = men_can_have_consorts - Allows consorts (if also allowed by faith)
flag = women_can_have_multiple_spouses - Allows multiple spouses (if also allowed by faith)
flag = women_can_have_consorts - Allows consorts (if also allowed by faith)
