Toggle System

The Toggle System collection object provides access to other objects related to the toggle system. These are objects on the battlefield that can be turned on and off, such as barricades and map barriers. The toggle_system object provides access to a list of individual battle_toggle_slot objects from an internal numbered list. The function toggle_system:toggle_slot provides access to an individual toggle slot by index, while toggle_system:toggle_slot_count returns the size of the list.

A handle to the toggle system object may be obtained by calling battle:toggle_system.

Example:

toggle_system = bm:toggle_system()
Loaded in Campaign Loaded in Campaign
Loaded in Battle Loaded in Battle
Loaded in Frontend Loaded in Frontend
Back to top

Functionality

toggle_system:toggle_slot(number index)

Returns the toggle slot at the specified index value in the collection. The list is 1-based, the toggle slot at index 1 is the first toggle slot in the list.

Parameters:

1

number

index

Returns:

  1. battle_toggle_slot toggle_slot

toggle_system:toggle_slot_script_id(number index)

Returns the toggle slot with the specified script_id.

Parameters:

1

number

index

Returns:

  1. battle_toggle_slot toggle_slot

toggle_system:toggle_slot_count()

Returns the size of the toggle slot list.

Returns:

  1. number count

toggle_system:map_barrier(number index)

Returns the map barrier at the specified index value in the collection. The list is 1-based, the map barrier at index 1 is the first map barrier in the list.

Parameters:

1

number

index

Returns:

  1. battle_map_barrier map_barrier

toggle_system:map_barrier_script_id(string script id)

Returns the map barrier with the specified script id.

Parameters:

1

string

script id

Returns:

  1. battle_map_barrier toggle slot

toggle_system:map_barrier_count()

Returns the size of the map barrier list.

Returns:

  1. number count

toggle_system:allow_army_interaction(boolean allow/forbids use of toggleables)

Allows/Stops all armies to interact with toggleables

Parameters:

1

boolean

allow/forbids use of toggleables

Returns:

  1. nil

toggle_system:disable_and_refund_all_buildings()

Disable and refunds all built buildings

Returns:

  1. nil

Map Barrier

Map Barrier objects represent map barriers on the battlefield. Map barriers are a special type of toggleable object that represent large barriers that block pathfinding on the battle map. They are distinct from barricades which are constructed within settlements. The visual style of a map barrier is often unique to its particular map.

Handles to map barrier objects may be obtained through the battle_toggle_system and battle_toggle_slot interfaces.

Back to top

Functionality

map_barrier:enabled()

Returns if the map barrier is enabled

Returns:

  1. boolean true/false

map_barrier:highlight([boolean show highlight])

Activates or deactivates a map barrier highlight.

Parameters:

1

boolean

optional, default value=true

show highlight

Returns:

  1. nil

map_barrier:enable(battle_army army)

Enables the map barrier. The army that is enabling the barrier must be specified.

Parameters:

1

battle_army

army

Returns:

  1. nil

map_barrier:disable(battle_army army)

Disables the map barrier. The army that is disabling the barrier must be specified.

Parameters:

1

battle_army

army

Returns:

  1. nil

map_barrier:position(battle_vector position)

Returns the position of the map barrier.

Parameters:

1

battle_vector

position

Returns:

  1. nil

map_barrier:record_key()

Returns the record key of the map barrier.

Returns:

  1. string record_key

map_barrier:composite_scenes()

Returns the composite_scenes of the map barrier.

Returns:

  1. battle_composite_scenes_list composite_scenes_list

map_barrier:has_toggle_slot()

Returns whether the map barrier is linked to a toggle slot.

Returns:

  1. boolean is linked to toggle slot

map_barrier:toggle_slot()

Returns the toggle slot linked with the barrier. If no toggleable is linked then nothing is returned.

Returns:

  1. battle_toggle_slot toggle slot

Toggle Slot

Toggle Slot objects represent toggle slots on the battlefield. They are abstract objects, linked to other object types like battle_map_barrier that represent physical objects on the battlefield. It is through the battle_toggle_slot interface that these objects can be activated and deactivated.

Back to top

Functionality

toggle_slot:is_held_by_alliance()

Returns whether the toggle slot is currently held by an alliance.

Returns:

  1. boolean is held by alliance

toggle_slot:holding_alliance()

Returns a handle to the holding alliance. If no alliance holds the toggleable slot then nothing is returned.

Returns:

  1. battle_alliance holding alliance

toggle_slot:has_map_barrier()

Returns whether the toggle slot is linked to a map barrier.

Returns:

  1. boolean is linked to map barrier

toggle_slot:map_barrier()

Returns the map barrier linked with the toggle slot. If no map barrier is linked then nothing is returned.

Returns:

  1. battle_map_barrier map barrier

toggle_slot:unique_ui_id()

Returns the unique id for this toggle slot that the UI system uses.

Returns:

  1. number ui id

toggle_slot:unique_id()

Returns the unique id for this toggle slot.

Returns:

  1. number id

toggle_slot:script_id()

Returns the script id of the toggle slot. If no script id has been set in the map data then a blank string is returned.

Returns:

  1. string script id

toggle_slot:highlight([boolean show highlight])

Activates or deactivates a highlight on a slot building place.

Parameters:

1

boolean

optional, default value=true

show highlight

Returns:

  1. nil

toggle_slot:position()

Returns the position

Returns:

  1. battle_vector position

toggle_slot:slot_type()

Returns the slot type of the toggle slot as a string. Slot types are listed in the toggle_system_types database table.

Returns:

  1. string slot type
Last updated 7/9/2024 11:45:05 AM