Skip to main content
Skip to main content

HandToolStorable

HandToolStorable

Description

The hand tool specialisation for any hand tool that can be stored in a HandToolHolder.

Functions

getHolsterNodeByType

Description

Definition

getHolsterNodeByType()

Arguments

anytypeName

Code

function HandToolStorable:getHolsterNodeByType(typeName)
local spec = self.spec_storable
if spec.holderHolsterNodes = = nil then
return nil
end

return spec.holderHolsterNodes[typeName]
end

onLoad

Description

Definition

onLoad()

Arguments

anyxmlFile

Code

function HandToolStorable:onLoad(xmlFile)
local spec = self.spec_storable

-- A collection of nodes keyed by holder type.If a holder's type is not a key in this table, then the tool cannot be stored in it.
spec.holderHolsterNodes = { }

for _, key in xmlFile:iterator( "handTool.storable.holderType" ) do
local holderType = xmlFile:getValue(key .. "#type" , nil )
if holderType = = nil then
Logging.xmlError(xmlFile, "HandToolStorable has a holder type with a missing type!" )
continue
end

local holderNode = xmlFile:getValue(key .. "#node" , nil , self.components, self.i3dMappings)
if holderNode ~ = nil then
spec.holderHolsterNodes[holderType] = holderNode
end
end
end

prerequisitesPresent

Description

Definition

prerequisitesPresent()

Arguments

anyspecializations

Code

function HandToolStorable.prerequisitesPresent(specializations)
return true
end

registerEventListeners

Description

Definition

registerEventListeners()

Arguments

anyhandToolType

Code

function HandToolStorable.registerEventListeners(handToolType)
SpecializationUtil.registerEventListener(handToolType, "onLoad" , HandToolStorable )
end

registerFunctions

Description

Definition

registerFunctions()

Arguments

anyhandToolType

Code

function HandToolStorable.registerFunctions(handToolType)
SpecializationUtil.registerFunction(handToolType, "getHolsterNodeByType" , HandToolStorable.getHolsterNodeByType)
end

registerXMLPaths

Description

Definition

registerXMLPaths()

Arguments

anyxmlSchema

Code

function HandToolStorable.registerXMLPaths(xmlSchema)
local basePath = "handTool.storable.holderType(?)"

xmlSchema:setXMLSpecializationType( "HandToolStorable" )
xmlSchema:register(XMLValueType.STRING, basePath .. "#type" , "The type of holder that can be used" , nil , true )
xmlSchema:register(XMLValueType.NODE_INDEX, basePath .. "#node" , "The node used to orient the tool in the holder" )
xmlSchema:setXMLSpecializationType()
end