Rockets control

Control Module - Rockets - Stores rocket stats for each force.

Usage


    -- import the module from the control modules
    local Rockets = require 'modules.control.rockets' --- @dep modules.control.rockets

    -- Some basic information is stored for each silo that has been built
    -- the data includes: the tick it was built, the rockets launched from it and more
    Rockets.get_silo_data(rocket_silo_entity)

    -- Some information is also stored for each force
    Rockets.get_stats('player')

    -- You can get the rocket data for all silos for a force by using get_silos
    Rockets.get_silos('player')

    -- You can get the launch time for a rocket, meaning what game tick the 50th rocket was launched
    Rockets.get_rocket_time('player', 50)

    -- The rolling average will work out the time to launch one rocket based on the last X rockets
    Rockets.get_rolling_average('player', 10)

Dependencies

utils.event
utils.global
config.rockets

Functions

get_silo_data(silo) Gets the silo data for a given silo entity
get_silo_data_by_name(silo_name) Gets the silo data for a given silo entity
get_silo_entity(silo_name) Gets the silo entity from its silo name, reverse to get_silo_data
get_stats(force_name) Gets the rocket stats for a force
get_silos(force_name) Gets all the rocket silos that belong to a force
get_rocket_time(force_name, rocket_number) Gets the launch time of a given rocket, due to cleaning not all counts are valid
get_rocket_count(force_name) Gets the number of rockets that a force has launched
get_game_rocket_count() Gets the total number of rockets launched by all forces
get_rolling_average(force_name, count) Gets the rolling average time to launch a rocket

Fields

silo_data.launched Adds this 1 to the launch count for this silo

Dependencies

# utils.event
# utils.global
# config.rockets

Functions

# get_silo_data(silo)

Gets the silo data for a given silo entity

Parameters: Returns:
  • (table) the data table for this silo, contains rockets launch, silo status, and its force
# get_silo_data_by_name(silo_name)

Gets the silo data for a given silo entity

Parameters:
  • silo_name : (string) the silo name that is stored in its data
Returns:
  • (table) the data table for this silo, contains rockets launch, silo status, and its force
# get_silo_entity(silo_name)

Gets the silo entity from its silo name, reverse to get_silo_data

Parameters:
  • silo_name : (string) the silo name that is stored in its data
Returns:
# get_stats(force_name)

Gets the rocket stats for a force

Parameters:
  • force_name : (string) the name of the force to get the stats for
Returns:
  • (table) the table of stats for the force
# get_silos(force_name)

Gets all the rocket silos that belong to a force

Parameters:
  • force_name : (string) the name of the force to get the silos for
Returns:
  • (table) an array of silo data that all belong to this force
# get_rocket_time(force_name, rocket_number)

Gets the launch time of a given rocket, due to cleaning not all counts are valid

Parameters:
  • force_name : (string) the name of the force to get the count for
  • rocket_number : (number) the number of the rocket to get the launch time for
Returns:
  • (number) the game tick that the rocket was lanuched on
# get_rocket_count(force_name)

Gets the number of rockets that a force has launched

Parameters:
  • force_name : (string) the name of the force to get the count for
Returns:
  • (number) the number of rockets that the force has launched
# get_game_rocket_count()

Gets the total number of rockets launched by all forces

Returns:
  • (number) the total number of rockets launched this game
# get_rolling_average(force_name, count)

Gets the rolling average time to launch a rocket

Parameters:
  • force_name : (string) the name of the force to get the average for
  • count : (number) the distance to get the rolling average over
Returns:
  • (number) the number of ticks required to launch one rocket

Fields

# silo_data.launched

Adds this 1 to the launch count for this silo