Module helpers
Assorted helper functions
Add the values from table1 to table2, if they don't already exist.
Functions
| boomstick_api.validate_table (keys, data) | Given a table and a set of keys, validate that the keys in the table exist. | 
| boomstick_api.get_random_entry (table) | Returns a random item from a table. | 
| boomstick_api.get_random_sound (table) | Given a table of sounds, randomly select one and return a SimpleSoundSpec. | 
| boomstick_api.debug (string, table) | Wrapper for minetest.debug()that will check if a debug flag is set in the mod settings before logging. | 
| boomstick_api.mod_exists (modname) | Returns true if a mod exists | 
| boomstick_api.play_random_sound_on_player (sounds, player) | Randomly select a sound from a table of sounds, handling the creation of SimpleSoundSpecs, sound parameter tables, and getting player position. | 
| boomstick_api.play_random_sound (sounds, pos) | Randomly select a sound from a table of sounds, handling the creation of SimpleSoundSpec and sound parameter tables. | 
| boomstick_api.play_sound_on_player (sound, player) | Wrapper for minetest.sound_play()that handles the creation of SimpleSoundSpec and sound parameter tables, and getting player position. | 
| boomstick_api.play_sound (sound, pos) | Wrapper for minetest.sound_play()that handles the creation of SimpleSoundSpec and sound parameter tables. | 
Functions
- boomstick_api.validate_table (keys, data)
- 
    Given a table and a set of keys, validate that the keys in the table exist.
    Parameters:- keys
- Table containing keys
 
- data
- Table to be validated.
 
 Returns:- 
        boolean - Whether or not the table has all keys.
    
 
- keys
- boomstick_api.get_random_entry (table)
- 
    Returns a random item from a table.
    Parameters:- table containing items
 Returns:- 
        item from the table.
    
 
- boomstick_api.get_random_sound (table)
- 
    Given a table of sounds, randomly select one and return a SimpleSoundSpec.
 This allows weapons (or anything with a sound) to randomly play different
 sounds to add variety.
    Parameters:- table A table of strings, containing filenames of sounds.
 Returns:- 
        table - A SimpleSoundSpec with the name set to a random sound.
    
 
- boomstick_api.debug (string, table)
- 
    Wrapper for minetest.debug()that will check if a debug flag is set in the mod settings before logging. This is a work in progress.Parameters:- string
- A string to log to the Minetest console for debugging purposes.
 
- table
- A table containing printf-style arguments to be passed to string.format()
 
- A table containing printf-style arguments to be passed to 
 Returns:- 
        table - A SimpleSoundSpec with the name set to a random sound.
    
 
- string
- boomstick_api.mod_exists (modname)
- 
    Returns true if a mod exists
    Parameters:- modname
            string
- The name of a mod.
 
 Returns:- 
        boolean - Whether or not a mod exists.
    
 
- modname
            string
- boomstick_api.play_random_sound_on_player (sounds, player)
- 
    Randomly select a sound from a table of sounds, handling the creation of SimpleSoundSpecs, sound parameter tables, and getting player position.
    Parameters:- sounds
- A list of tables, each containing a namevalue, with optionalgain, andmax_hear_distancevalues.
 
- A list of tables, each containing a 
- player
- A player ObjectRef. The sound will originate at the players position.
 
 Usage:local my_sounds = { {name = "my_sound_1"}, {name = "my_sound_2", gain = 0.25, max_hear_distance = 5}, } boomstick_api.play_random_sound_on_player(my_sounds, player) 
- sounds
- boomstick_api.play_random_sound (sounds, pos)
- 
    Randomly select a sound from a table of sounds, handling the creation of SimpleSoundSpec and sound parameter tables.
    Parameters:- sounds
- A list of tables, each containing a namevalue, with optionalgain, andmax_hear_distancevalues.
 
- A list of tables, each containing a 
- pos
- A Minetest vector where the sound should originate from.
 
 Usage:local my_sounds = { {name = "my_sound_1"}, {name = "my_sound_2", gain = 0.25, max_hear_distance = 5}, } boomstick_api.play_random_sound(empty_weapon_sounds, pos) 
- sounds
- boomstick_api.play_sound_on_player (sound, player)
- 
    Wrapper for minetest.sound_play()that handles the creation of SimpleSoundSpec and sound parameter tables, and getting player position.Parameters:- sound
- A table containing a namevalue, with optionalgain, andmax_hear_distancevalues.
 
- A table containing a 
- player
- A player ObjectRef. The sound will originate at the players position.
 
 Usage:boomstick_api.play_sound({ name = "mysound", gain = 1.0, max_hear_distance = 5 }, player)
- sound
- boomstick_api.play_sound (sound, pos)
- 
    Wrapper for minetest.sound_play()that handles the creation of SimpleSoundSpec and sound parameter tables.Parameters:- sound
- A table containing a namevalue, with optionalgain, andmax_hear_distancevalues.
 
- A table containing a 
- pos
- A Minetest vector where the sound should originate from.
 
 Usage:boomstick_api.play_sound({ name = "mysound", gain = 1.0, max_hear_distance = 5 }, pos)
- sound