Skip to content

Mod Reference Lua Functions

Ian Norton edited this page Jun 1, 2023 · 13 revisions

CC2 Lua Functions and Patterns

Native Functions

These are functions that lua scripts can call to interact with the core C/C++ game process, such as getting the ID or type of the currently controlled vehicle, the angle the current camera is pointing or to issue a production order. Most of these functions are named like update_* such as update_get_camera_heading()

e_active_input = update_get_active_input_type()

is_keyboard = update_get_active_input_type() == e_active_input.keyboard

Will return the current input mode value as one of e_active_input

string = update_get_loc(e_loc)

lang_pause = update_get_loc(e_loc.interaction_pause)

Will return the localised string from one of the index values defined in e_loc

vehicle = update_get_screen_vehicle()

Returns the Vehicle object handle for the vehicle that the screen is attached to.

update_play_sound(e_audio_effect_type)

update_play_sound(e_audio_effect_type.telemetry_2_radar)

Will trigger playback of one of the wav clips defined in e_audio_effect_type.

Note, this is only provided when you are on-foot. this function is not mapped when you are using an attached vehicle camera.

update_set_screen_state_exit()

When called, the current screen/camera is exited. Eg, if you are viewing a camera from a vehicle control seat, you are returned to the control screen. If you are on the control screen, you are exited from the screen and remain in the seat.

Vehicle Objects

Clone this wiki locally