Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Please sign up or log in to edit the wiki.

Module:Item/WeaponAttachment

From the Star Citizen Wiki, the fidelity™ encyclopedia
Revision as of 18:52, 9 March 2024 by Alistair3149 (talk | contribs) (Created page with "require( 'strict' ) local p = {} local MODULE_NAME = 'WeaponAttachment' local TNT = require( 'Module:Translate' ):new() local smwCommon = require( 'Module:Common/SMW' ) local data = mw.loadJsonData( 'Module:Item/' .. MODULE_NAME .. '/data.json' ) local config = mw.loadJsonData( 'Module:Item/config.json' ) --- Wrapper function for Module:Translate.translate --- --- @param key string The translation key --- @param addSuffix boolean|nil Adds a language suffix if config...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Module documentation[view][edit][history][purge]
This documentation is transcluded from Module:Item/WeaponAttachment/doc. Changes can be proposed in the talk page.
Function list
L 18 — translate
L 26 — p.addSmwProperties
L 43 — p.addSmwAskProperties
L 58 — p.addInfoboxData
L 107 — p.addCategories
L 116 — p.getShortDescription

require( 'strict' )

local p = {}

local MODULE_NAME = 'WeaponAttachment'

local TNT = require( 'Module:Translate' ):new()
local smwCommon = require( 'Module:Common/SMW' )
local data = mw.loadJsonData( 'Module:Item/' .. MODULE_NAME .. '/data.json' )
local config = mw.loadJsonData( 'Module:Item/config.json' )


--- Wrapper function for Module:Translate.translate
---
--- @param key string The translation key
--- @param addSuffix boolean|nil Adds a language suffix if config.smw_multilingual_text is true
--- @return string If the key was not found in the .tab page, the key is returned
local function translate( key, addSuffix, ... )
    return TNT:translate( 'Module:Item/' .. MODULE_NAME .. '/i18n.json', config, key, addSuffix, {...} )
end


--- Adds the properties valid for this item to the SMW Set object
---
--- @param smwSetObject table
function p.addSmwProperties( apiData, frameArgs, smwSetObject )
    smwCommon.addSmwProperties(
        apiData,
        frameArgs,
        smwSetObject,
        translate,
        config,
        data,
        'Item/' .. MODULE_NAME
    )
end


--- Adds all SMW parameters set by this Module to the ASK object
---
--- @param smwAskObject table
--- @return nil
function p.addSmwAskProperties( smwAskObject )
    smwCommon.addSmwAskProperties(
        smwAskObject,
        translate,
        config,
        data
    )
end


--- Adds entries to the infobox
---
--- @param infobox table The Module:InfoboxNeue instance
--- @param smwData table Data from Semantic MediaWiki
--- @return nil
function p.addInfoboxData( infobox, smwData )
    -- Optics attachments
    if smwData[ translate( 'SMW_Type' ) ] == 'WeaponAttachment.IronSight' then
        infobox:renderSection( {
            content = {
                infobox:renderItem( {
                    label = translate( 'LBL_OpticsMagnification' ),
                    data = smwData[ translate( 'SMW_OpticsMagnification' ) ],
                } ),
                infobox:renderItem( {
                    label = translate( 'LBL_OpticsType' ),
                    data = smwData[ translate( 'SMW_OpticsType' ) ],
                } ),
                infobox:renderItem( {
                    label = translate( 'LBL_ZeroingRange' ),
                    data = smwData[ translate( 'SMW_ZeroingRange' ) ],
                } ),
                infobox:renderItem( {
                    label = translate( 'LBL_ZeroingRangeIncrement' ),
                    data = smwData[ translate( 'SMW_ZeroingRangeIncrement' ) ],
                } ),
                infobox:renderItem( {
                    label = translate( 'LBL_AutoZeroingTime' ),
                    data = smwData[ translate( 'SMW_AutoZeroingTime' ) ],
                } )
            },
            col = 2
        } )
    elseif smwData[ translate( 'SMW_Type' ) ] == 'WeaponAttachment.Magazine' then
        infobox:renderSection( {
            content = {
                infobox:renderItem( {
                    label = translate( 'LBL_Ammo' ),
                    data = smwData[ translate( 'SMW_Ammo' ) ],
                } )
            },
            col = 2
        } )
    end
end


--- Add categories that are set on the page.
--- The categories table should only contain category names, no MW Links, i.e. 'Foo' instead of '[[Category:Foo]]'
---
--- @param categories table The categories table
--- @param frameArgs table Frame arguments from Module:Arguments
--- @param smwData table Data from Semantic MediaWiki
--- @return nil
function p.addCategories( categories, frameArgs, smwData )

end

--- Return the short description for this object
---
--- @param frameArgs table Frame arguments from Module:Arguments
--- @param smwData table Data from Semantic MediaWiki
--- @return string|nil
function p.getShortDescription( frameArgs, smwData )
	
end


return p