RexySeven Posted October 23 Share Posted October 23 Hello My goal was to make something similar to Wanda's Clockmaker's Tools but instead of disassembling clocks - it can disassemble any item into it's crafting components. I used and modified official code as a basis and didn't get any results, I can only craft the item and it doesn't do anything, can't even uncraft Wanda's clocks anymore. I'm attaching prefab file and component file. If anyone have any leads on what to change, please tell me. toolboxw.lua toolboxw.lua Link to comment Share on other sites More sharing options...
_zwb Posted October 23 Share Posted October 23 You need to call AddComponentAction on your custom component. Check componentaction.lua and modutil.lua for more info Link to comment Share on other sites More sharing options...
RexySeven Posted October 23 Author Share Posted October 23 2 hours ago, _zwb said: You need to call AddComponentAction on your custom component. Check componentaction.lua and modutil.lua for more info Something like this? (I don't know if crafted items have specific tag attached, so I just left it blank) function AddComponentAction:DISMANTLE_ITEM Item_Dismantler = function (inst, doer, target, actions) if doer:HasTag("wusty") and target:HasTag("---") then table.insert(actions, ACTIONS.DISMANTLE_ITEM) end end end Link to comment Share on other sites More sharing options...
_zwb Posted October 23 Share Posted October 23 In modmain.lua: AddComponentAction("INVENTORY", "your_component_name", function(inst, doer, target, actions) --[[your actual function here]]-- end Link to comment Share on other sites More sharing options...
RexySeven Posted October 24 Author Share Posted October 24 9 hours ago, _zwb said: In modmain.lua: AddComponentAction("INVENTORY", "your_component_name", function(inst, doer, target, actions) --[[your actual function here]]-- end Since I have a character mod, I'm not sure if this goes into modmain maybe in prefabs/toolboxw? Link to comment Share on other sites More sharing options...
_zwb Posted October 24 Share Posted October 24 12 hours ago, RexySeven said: Since I have a character mod, I'm not sure if this goes into modmain maybe in prefabs/toolboxw? It goes in modmain Link to comment Share on other sites More sharing options...
RexySeven Posted October 24 Author Share Posted October 24 1 hour ago, _zwb said: It goes in modmain Character stops working when I add code into modmain AddComponentAction("INVENTORY", "DISMANTLE_ITEM", function(inst, doer, target, actions) Item_Dismantler = function (inst, doer, target, actions) if doer:HasTag("wusty") then table.insert(actions, ACTIONS.DISMANTLE_ITEM) end end end end Link to comment Share on other sites More sharing options...
_zwb Posted October 24 Share Posted October 24 19 minutes ago, RexySeven said: Character stops working when I add code into modmain AddComponentAction("INVENTORY", "DISMANTLE_ITEM", function(inst, doer, target, actions) Item_Dismantler = function (inst, doer, target, actions) if doer:HasTag("wusty") then table.insert(actions, ACTIONS.DISMANTLE_ITEM) end end end end In modmain.lua AddComponentAction("INVENTORY", "toolboxw", function(inst, doer, target, actions) if doer:HasTag("wusty") then table.insert(actions, GLOBAL.ACTIONS.DISMANTLE_ITEM) end end) you would have to either modify ACTIONS.DISMANTLE_ITEM or add a new action for your component Link to comment Share on other sites More sharing options...
RexySeven Posted October 24 Author Share Posted October 24 34 minutes ago, _zwb said: In modmain.lua AddComponentAction("INVENTORY", "toolboxw", function(inst, doer, target, actions) if doer:HasTag("wusty") then table.insert(actions, GLOBAL.ACTIONS.DISMANTLE_ITEM) end end) you would have to either modify ACTIONS.DISMANTLE_ITEM or add a new action for your component isn't that the action in the component\toolboxw? my game crashed asking for missing loot table function Item_Dismantler:Dismantle(target, doer) local owner = target.components.inventoryitem:GetGrandOwner() local receiver = owner ~= nil and not (owner.components.inventory or owner.components.container) or nil local pt = receiver ~= nil and self.inst:GetPosition() or doer:GetPosition() local loot = target.components.lootdropper:GetFullRecipeLoot(AllRecipes[target.prefab]) target:Remove() -- We remove the target before giving the loot to make more space in the inventory SpawnPrefab("brokentool").Transform:SetPosition(doer.Transform:GetWorldPosition()) end Link to comment Share on other sites More sharing options...
_zwb Posted October 24 Share Posted October 24 2 hours ago, RexySeven said: my game crashed asking for missing loot table Because you didn't set a recipe for the item to be dismantled? I can't help much without a crash log Link to comment Share on other sites More sharing options...
RexySeven Posted October 25 Author Share Posted October 25 6 hours ago, _zwb said: Because you didn't set a recipe for the item to be dismantled? I can't help much without a crash log Here's the log I just thought I had recipe table stated in component, but it seems like that's not the case x( client_log.txt Link to comment 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