BK-201 Posted August 27, 2024 Share Posted August 27, 2024 In my mods I usually need to add the ability for the player to apply a certain prefab to another prefab. AddComponentAction("USEITEM", "unnecessary_component", function(inst, doer, target, actions, right) -- do something end) It bothers me that I have to create a empty unnecessary_component every time for the item the player needs to apply. For example, if you want to add the use of boards on an item in the world, you will need to create an "unnecessary_component" and add it to the "boards". AddPrefabPostInit("boards", function( inst ) inst:AddComponent("unnecessary_component") end) Maybe there is an alternative way to bind an action to a prefab? An abstract function called "AddPrefabAction" in which you need to specify not the item component, but the name of the prefab itself. AddPrefabAction("USEITEM", "boards", function(inst, doer, target, actions, right) -- do something end) Link to comment https://forums.kleientertainment.com/forums/topic/159371-alternative-to-addcomponentaction-how-else-to-bind-an-action-to-a-prefab/ Share on other sites More sharing options...
-LukaS- Posted August 27, 2024 Share Posted August 27, 2024 As far as I know, creating a dummy component is the easiest way of binding a custom action to a prefab, or a set of prefabs for that matter. There is another way if you really don't like creating dummy components and that's to set up either `leftclickoverride` or `rightclickoverride` from the PlayerActionPicker component but that method is way more complicated and requires more code in general. Link to comment https://forums.kleientertainment.com/forums/topic/159371-alternative-to-addcomponentaction-how-else-to-bind-an-action-to-a-prefab/#findComment-1744263 Share on other sites More sharing options...
BK-201 Posted August 27, 2024 Author Share Posted August 27, 2024 -LukaS-, thanks for the answer. I am reassured by the understanding that the existence of such dummy components is normal in such a situation. 1 Link to comment https://forums.kleientertainment.com/forums/topic/159371-alternative-to-addcomponentaction-how-else-to-bind-an-action-to-a-prefab/#findComment-1744296 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now