Skip to main content
Skip to main content

HandToolUtil

HandToolUtil

Description

Util class for hand tools and anything relating to them.

Functions

addHandToolHolderTarget

Description

Adds the default hand tool holder target, which allows a hand tool to target hand tool holders for taking and storing hand tools.

Definition

addHandToolHolderTarget(PlayerTargeter playerTargeter, float? minDistance, float? maxDistance)

Arguments

PlayerTargeterplayerTargeterThe player targeter to add to.
float?minDistanceThe optional minimum distance that a hand tool holder can be targeted.
float?maxDistanceThe optional maximum distance that a hand tool holder can be targeted.

Code

function HandToolUtil.addHandToolHolderTarget(playerTargeter, minDistance, maxDistance)

-- Default the distances.
minDistance = minDistance or HandToolUtil.HOLDER_DEFAULT_MINIMUM_DISTANCE
maxDistance = maxDistance or HandToolUtil.HOLDER_DEFAULT_MAXIMUM_DISTANCE

-- Add the click box target and filter based on hand tool targeters.
playerTargeter:addTargetType( HandToolHolder , HandToolUtil.CLICK_BOX_TARGET_MASK, minDistance, maxDistance)
playerTargeter:addFilterToTargetType( HandToolHolder , function (hitNode, x, y, z)
return hitNode ~ = nil and hitNode ~ = 0 and g_currentMission.handToolSystem:getHandToolHolderByClickBox(hitNode) ~ = nil
end )
end

linkAndTransformRelativeToParent

Description

Links rootNode to be a child of parentNode, then transforms the root node so that the child node and parent node have the same translation and rotation.

Definition

linkAndTransformRelativeToParent(integer rootNode, integer childNode, integer parentNode)

Arguments

integerrootNodeThe root node whose position and rotation are changed, and who will be made a child of parentNode.
integerchildNodeThe node whose transform is used to transform the root node.
integerparentNodeThe node whose orientation and translation will be used to match the given childNode. This node is not moved or rotated in any way.

Code

function HandToolUtil.linkAndTransformRelativeToParent(rootNode, childNode, parentNode)

-- Link the root node to the parent node.
link(parentNode, rootNode)

HandToolUtil.transformRelativeToParent(rootNode, childNode, parentNode)
end