Module ORGM

ORGM Rechambered

The core ORGM table of ORGM Rechambered.

All functions and tables can be accessed via the global table named ORGM. This mod’s core philosophy is to place as little as possible in the global namespace for performance reasons as Zomboid’s lua global namespace is already heavily polluted. Because of this, you should always pull the ORGM table (or it’s sub-tables) into the local namespace.

local ORGM = ORGM

Example

-- pull tables into local namespace
local ORGM = ORGM
local Firearm = ORGM.Firearm
local Cylinder = ORGM.ReloadableWeapon.Cylinder
local Hammer = ORGM.ReloadableWeapon.Hammer

-- Spin the cylinder and cock the hammer for a IsoPlayer.
local function spinAndCock(playerObj)
    local item = Firearm.getFirearm(playerObj)
    if not item return end
    -- check if its rotary fed
    if not Firearm.isRotary(item) then return end
    -- rotate the cylinder
    Cylinder.rotate(item:getModData(), nil, playerObj, true, item)
    -- Can't cock a double action only
    if Firearm.Hammer.isDAO() then return end
    Hammer.cock(item:getModData(), playerObj, true, item)
end

Info:

  • Copyright: 2018 File: shared/1LoadOrder/ORGMCore.lua
  • Release: 3.09
  • Author: Fenris_Wolf.

Modules

Server Contains all ORGM server-side functions, see: ORGM.Server
Client Contains all ORGM client-side functions, see: ORGM.Client.
ReloadableWeapon Functions for controlling and performing actions with firearms, see: ORGM.ReloadableWeapon.
Firearm Contains all firearm functions, see: ORGM.Firearm.
Ammo Contains all ammo functions, see: ORGM.Ammo.
Component Contains all component functions, see: ORGM.Component.
Magazine Contains all magazine functions, see: ORGM.Magazine.
Maintance Contains all maintance functions, see: ORGM.Maintance.
Callbacks Contains all callback functions, see: ORGM.Callbacks.
Sounds Contains all sound setup functions, see: ORGM.Sounds.

Constants

AUTHOR Author of the mod.
BUILD_HISTORY this table is used to track build #’s for backwards compatibility.
BUILD_ID Set automatically.

Logging Constants

ERROR integer 0
WARN integer 1
INFO integer 2
DEBUG integer 3
VERBOSE integer 4

Trigger Constants

SINGLEACTION integer 1
DOUBLEACTION integer 2
DOUBLEACTIONONLY integer 3

Feed System Constants

AUTO integer 1
BOLT integer 2
LEVER integer 3
PUMP integer 4
BREAK integer 5
ROTARY integer 6

Auto Feed Constants

BLOWBACK integer 1
DELAYEDBLOWBACK integer 2
SHORTGAS integer 3
LONGGAS integer 4
DIRECTGAS integer 5
LONGRECOIL integer 6
SHORTRECOIL integer 7

Category Constants

PISTOL integer 1
REVOLVER integer 2
SUBMACHINEGUN integer 3
RIFLE integer 4
SHOTGUN integer 5

Select Fire Constants

SEMIAUTOMODE integer 0
FULLAUTOMODE integer 1

Rarity Constants

COMMON Common
RARE Rare
VERYRARE VeryRare

String Tables

ActionTypeStrings Contains string names for actionType constants.
TriggerTypeStrings Contains string names for triggerType constants.
AutoActionTypeStrings Contains string names for autoType constants.

Settings

Settings table containing all ORGM settings these are all defined below in the ORGM.SettingsValidator table
SettingsValidator This table handles all the settings to be defined in ORGM.Settings, expected value types, default values, min/max (for integers and floats) and any Functions to run when updating this setting.

Utility functions

log (level, text) Basic logging function.
tableContains (thisTable, value) Checks if a value is in the specified table.
tableRemove (thisTable, value) Removes a entry by value in a table.
isModLoaded (mod) Checks if a mod has been loaded or not.
getTableData (itemType, moduleName, instance, thisTable) Fetches data from the specified table.
validateRegister (name, dataTable, modTable) Generic item register validation.
validateSettingKey (key) Runs error checks on new values passed into the ORGM.Settings table.
readSettingsFile () Reads the file located at Zomboid/Lua/ORGM.ini, and loads those settings into the ORGM.Settings table.
writeSettingsFile () Writes the key/value pairs in the ORGM.Settings table to the Zomboid/Lua/ORGM.ini file.
getFirearm (playerObj) Gets the equipped firearm for a player


Modules

Server
Contains all ORGM server-side functions, see: ORGM.Server
Client
Contains all ORGM client-side functions, see: ORGM.Client.
ReloadableWeapon
Functions for controlling and performing actions with firearms, see: ORGM.ReloadableWeapon.

These work on both ISReloadableWeapon objects, and a InventoryItem’s modData.

Firearm
Contains all firearm functions, see: ORGM.Firearm.
Ammo
Contains all ammo functions, see: ORGM.Ammo.
Component
Contains all component functions, see: ORGM.Component.
Magazine
Contains all magazine functions, see: ORGM.Magazine.
Maintance
Contains all maintance functions, see: ORGM.Maintance.
Callbacks
Contains all callback functions, see: ORGM.Callbacks.
Sounds
Contains all sound setup functions, see: ORGM.Sounds.

Constants

AUTHOR
Author of the mod.
BUILD_HISTORY
this table is used to track build #’s for backwards compatibility. All guns will be stamped with a index number - the build it was last used in. A table exists changes to firearms (name = buildnumber). If the gun build id < lastChanged build id then the gun needs to be reset to default values (fixed for the new version.)
BUILD_ID
Set automatically. The current version number.

Logging Constants

These are passed to and checked when making calls to ORGM.log.
ERROR
integer 0
WARN
integer 1
INFO
integer 2
DEBUG
integer 3
VERBOSE
integer 4

Trigger Constants

SINGLEACTION
integer 1
DOUBLEACTION
integer 2
DOUBLEACTIONONLY
integer 3

Feed System Constants

AUTO
integer 1
BOLT
integer 2
LEVER
integer 3
PUMP
integer 4
BREAK
integer 5
ROTARY
integer 6

Auto Feed Constants

BLOWBACK
integer 1
DELAYEDBLOWBACK
integer 2
SHORTGAS
integer 3
LONGGAS
integer 4
DIRECTGAS
integer 5
LONGRECOIL
integer 6
SHORTRECOIL
integer 7

Category Constants

PISTOL
integer 1
REVOLVER
integer 2
SUBMACHINEGUN
integer 3
RIFLE
integer 4
SHOTGUN
integer 5

Select Fire Constants

SEMIAUTOMODE
integer 0
FULLAUTOMODE
integer 1

Rarity Constants

COMMON
Common
RARE
Rare
VERYRARE
VeryRare

String Tables

ActionTypeStrings
Contains string names for actionType constants.

Fields:

  • Auto
  • Bolt
  • Lever
  • Pump
  • Break
  • Rotary
TriggerTypeStrings
Contains string names for triggerType constants.

Fields:

  • SingleAction
  • DoubleAction
  • DoubleActionOnly
AutoActionTypeStrings
Contains string names for autoType constants.

Fields:

  • Blowback
  • Delayed Blowback
  • Short Gas Piston
  • Long Gas Piston
  • Direct Impingement Gas
  • Long Recoil
  • Short Recoil

Settings

Settings
table containing all ORGM settings these are all defined below in the ORGM.SettingsValidator table
SettingsValidator
This table handles all the settings to be defined in ORGM.Settings, expected value types, default values, min/max (for integers and floats) and any Functions to run when updating this setting.

Utility functions

These are important core functions, utility functions, and functions for manuplating the ORGM.Settings table.

File: shared/1LoadOrder/ORGMUtil.lua

log (level, text)
Basic logging function.

Prints a message to the console and console.txt log, if ORGM.Settings.LogLevel is equal or less then the level arguement.

Parameters:

  • level int logging level constant
  • text string text message to log.

Usage:

    ORGM.log(ORGM.WARN, "this is a warning log message")
tableContains (thisTable, value)
Checks if a value is in the specified table.

This is for scanning unsorted lists/dictionary tables by using a pairs() loop.

Parameters:

  • thisTable table table to check
  • value any data value to look for

Returns:

    bool

Usage:

    local result = ORGM.tableContains({"a", "b", "c"}, "b")
tableRemove (thisTable, value)
Removes a entry by value in a table.

Parameters:

  • thisTable table table to check
  • value any data value to remove

Returns:

    bool true if removed

Usage:

    ORGM.tableRemove({"a", "b", "c"}, "b")
isModLoaded (mod)
Checks if a mod has been loaded or not.

Parameters:

Returns:

    bool

Usage:

    local result = ORGM.isModLoaded("Hydrocraft")
getTableData (itemType, moduleName, instance, thisTable)
Fetches data from the specified table.

Internal function.

Used by the various ORGM.*.getData() (ie: ORGM.Firearm.getData, ORGM.Ammo.getData, etc) functions.

It is not advised to call directly, use one of the wrapper functions.

Parameters:

Returns:

    nil or table
validateRegister (name, dataTable, modTable)
Generic item register validation.

Internal function.

Used by the various ORGM.*.register() (ie: ORGM.Firearm.register, ORGM.Ammo.register, etc) functions.

Ensures the item hasn’t previously been registered, and that the item is in the scripts/*.txt files. This is called automatically when registering ORGM items.

Parameters:

Returns:

    bool false if this item should not be registered.
validateSettingKey (key)
Runs error checks on new values passed into the ORGM.Settings table.

Ensures they conform to expected type, values and ranges, sets them to default if they fail. It also runs any onUpdate() functions defined for that setting in the SettingsValidator.

Parameters:

See also:

Usage:

    ORGM.Setting.CasesEnabled = false
    ORGM.validateSettingKey('CasesEnabled')
readSettingsFile ()
Reads the file located at Zomboid/Lua/ORGM.ini, and loads those settings into the ORGM.Settings table.

See also:

writeSettingsFile ()
Writes the key/value pairs in the ORGM.Settings table to the Zomboid/Lua/ORGM.ini file.

This is disabled for MP clients.

getFirearm (playerObj)
Gets the equipped firearm for a player

Parameters:

  • playerObj IsoPlayer

Returns:

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