Module ORGM.Magazine

Magazine Functions

This file contains functions for dealing with magazines and their data.

Info:

  • Copyright: 2018 File: shared/2LoadOrder/ORGMMagazines.lua
  • Release: 3.09
  • Author: Fenris_Wolf

Functions

register (name, magazineData) Registers a magazine type with ORGM.
deregister (name) Deregisters a magazine from ORGM
random ([thisTable]) Returns the name of a random magazine item.
getTable () Gets the table of registered magazines.
getData (itemType[, moduleName]) Gets the data of a registered magazine, supports module checking.
isMagazine (itemType[, moduleName]) Checks if a item is a ORGM magazine.
setup (magData, magItem) Sets up a magazine, applying key/values into the items modData.
findIn (magType, ammoType, containerItem) Finds the best matching magazine in a container.


Functions

Methods
register (name, magazineData)
Registers a magazine type with ORGM.

This must be called before any firearm registers that plan to use that magazine.

Parameters:

  • name string name of the magazine without module prefix
  • magazineData table

    table containing the magazine data.

    Valid table keys/value pairs are:
    
    moduleName = nil | string, module name this item is from. If nil, ORGM is used
    
    ammoType = string, the name of a ammo AmmoGroup (not real ammo name)
    
    reloadTime = nil | integer, if nil then ORGM.Settings.DefaultMagazineReoadTime is used
    
    maxCapacity = int, the max amount of bullets this magazine can hold
    
    ejectSound = nil | string, the string name of a sound file. If nil 'ORGMMagLoad' is used
    
    insertSound = nil | string, the string name of a sound file. If nil 'ORGMMagLoad' is used
    

Returns:

    bool true on success.
deregister (name)
Deregisters a magazine from ORGM WARNING: Incomplete code, do not use.

Parameters:

  • name string name of the magazine to deregister.

Returns:

    bool true on success
random ([thisTable])
Returns the name of a random magazine item.

Parameters:

  • thisTable table table to select from. (optional)

Returns:

    string the random magazine name.
getTable ()
Gets the table of registered magazines.

Returns:

    table all registered magazines setup by ORGM.Magazine.register
getData (itemType[, moduleName])
Gets the data of a registered magazine, supports module checking.

Parameters:

  • itemType string or InventoryItem
  • moduleName string module to compare (optional)

Returns:

    nil or table data of a registered magazine setup by ORGM.Magazine.register
isMagazine (itemType[, moduleName])
Checks if a item is a ORGM magazine.

Parameters:

  • itemType string or InventoryItem
  • moduleName string module to compare (optional)

Returns:

    bool true if it is a ORGM registered magazine
setup (magData, magItem)
Sets up a magazine, applying key/values into the items modData.

This should be called whenever a magazine is spawned.

Basically the same as ReloadUtil:setupMagazine and ISORGMMagazine:setupReloadable but called without needing a player or reloadable object.

Parameters:

findIn (magType, ammoType, containerItem)
Finds the best matching magazine in a container.

Search is based on the given magazine name and preferred load (can be specific round name, nil/any, or mixed), and the currentCapacity.

This is called when reloading some guns and all magazines.

Note magType and ammoType should NOT have the “ORGM.” prefix.

Parameters:

  • magType string name of a magazine
  • ammoType nil or string ‘any’, ‘mixed’ or a specific ammo name
  • containerItem ItemContainer

Returns:

    nil or InventoryItem
generated by LDoc 1.4.3 Last updated 2019-04-11 18:37:45