ComponentManager
Manages components and lets you create components.
Functions
toComponent
This is important!
We have a bansystem in our mod. In order for addons to work with it. All interactables and components NEED to use this function of ALL interactables and components.
If you do not do that and we notice that, We will warn you about this issue. Ignoring this warning will result to a BAN on the addon. There might be any additional consequences added.
sm.scrapcomputers.componentManager.toComponent( classData, componentType, isAComponent, automaticRefreshGen )
Hooks your class so you can create components easly. For addon developers, this is required to be called on all of your components and interactables.
- For components: All variables must be used,
isAComponent
would be true. - For Interactables: Same for components but you can set componentType to nil and
isAComponent
to false.
Arguments:
- classData [ ShapeClass ] The interactable's (or component) class.
- componentType [ string ] The type of component, Make sure this does not be a conflict with other addons or the mod itself!
- isAComponent [ boolean ] Set this to true if your interactable is a component!
- automaticRefreshGen [ boolean? ] If this is nil or true, It will generate onRefresh Functions. (Defaults to true)
How to use this function
If you do not know how to use this function, this short guide will help you.
Add this:
-- For Components
sm.scrapcomputers.componentManager.toComponent( yourClass, "YourComponentType", true )
-- For Interactables
sm.scrapcomputers.componentManager.toComponent( yourClass, "YourComponentType", false )
-- DO NOT ADD ANY FURTHER CODE BELOW HERE!
getComponents
sm.scrapcomputers.componentManager.getComponents( componentType, interactable, viaChildren, flags, getPrivateData )
Gets all connected components of the interactable and returns it.
Arguments:
- componentType [ string ] The component type to get.
- interactable [ Interactable ] The interactable to search through.
- viaChildren [ boolean ] If it should get components via children or parents.
- flags [ integer? ] The flags to use to get the components.
- getPrivateData [ boolean? ] If you set this to true, You get data from components that normally wont be for the computer api to use.
Returns:
- [ table ] All connected components it has discovered.