ShapeClass.client_getAvailableParentConnectionCount

Called to check how many more parent (input) connections with the given type flag the Interactable will accept. Return 1 or more to allow a connection of this type.

Kind: Callback

Environments: Game

Game

Callback side: Client

ShapeClass:client_getAvailableParentConnectionCount( flags )

Open the full Game reference

-- Example of implementation where logic and power shares the same slot but electricity counts as separate
MyIteractable.maxParentCount = 2
MyIteractable.connectionInput = sm.interactable.connectionType.logic + sm.interactable.connectionType.power + sm.interactable.connectionType.electricity

function MyIteractable.client_getAvailableParentConnectionCount( self, flags )
    if bit.band( flags, bit.bor( sm.interactable.connectionType.logic, sm.interactable.connectionType.power ) ) ~= 0 then
        return 1 - self:getParents( bit.bor( sm.interactable.connectionType.logic, sm.interactable.connectionType.power ) )
    end
    if bit.band( flags, sm.interactable.connectionType.electricity ) ~= 0 then
        return 1 - self:getParents( sm.interactable.connectionType.electricity )
    end
    return 0
end

Note: maxParentCount must be 1 or more for this callback to be called.

Parameters:

Name Type Description
self table The class instance.
flags integer Connection type flags.

Returns:

Type Description
integer The number of available connections.