Tesumoto Posted December 28, 2016 Share Posted December 28, 2016 (edited) Hello! I created a mod to increase walls strength on x10. But then came another player and broke my wall with a hammer for 3 hitting. The strength of the wall increased, if you hits them with an axe or a spear. But hammer ignores the fact that I raised HP for walls. I want that other players could not easily destroy my walls. But I do not want the immortal walls. I just need improve the resistance of the walls to the hammer. Can you help me with this? Edited December 28, 2016 by Tezumoto Link to comment https://forums.kleientertainment.com/forums/topic/72914-need-help-for-creating-mod-interacting-with-walls/ Share on other sites More sharing options...
CarlZalph Posted December 28, 2016 Share Posted December 28, 2016 Check out the workable component's SetMaxWork and SetWorkLeft functions. Link to comment https://forums.kleientertainment.com/forums/topic/72914-need-help-for-creating-mod-interacting-with-walls/#findComment-853657 Share on other sites More sharing options...
Tesumoto Posted December 28, 2016 Author Share Posted December 28, 2016 (edited) 43 minutes ago, CarlZalph said: Check out the workable component's SetMaxWork and SetWorkLeft functions. Now I use this code: local Effectiveness = GetModConfigData("Effectiveness") local old_ACTION_HAMMER = GLOBAL.ACTIONS.HAMMER.fn GLOBAL.ACTIONS.HAMMER.fn = function(act) if act.target and act.target.prefab and (act.target.prefab == 'wall_stone' or act.target.prefab == 'wall_moonrock' or act.target.prefab == 'wall_ruins') then if act.invobject and act.invobject.components.tool then act.invobject.components.tool:SetAction(GLOBAL.ACTIONS.HAMMER, Effectiveness) end return old_ACTION_HAMMER(act) else if act.invobject and act.invobject.components.tool then act.invobject.components.tool:SetAction(GLOBAL.ACTIONS.HAMMER, 1) end return old_ACTION_HAMMER(act) end end But with this code walls are destroyed in different hits (rock, moon and ruins walls). I can simply set a specific number of beats for all selected walls? Edited December 28, 2016 by Tezumoto Link to comment https://forums.kleientertainment.com/forums/topic/72914-need-help-for-creating-mod-interacting-with-walls/#findComment-853663 Share on other sites More sharing options...
Aquaterion Posted December 28, 2016 Share Posted December 28, 2016 (edited) you should be able to do (in modmain.lua): local wallmaterials = { MATERIALS.STONE, MATERIALS.WOOD, MATERIALS.HAY, "ruins", MATERIALS.MOONROCK} for id,material in pairs(wallmaterials) do AddPrefabPostInit("wall_" .. material, function(inst) if not GLOBAL.TheWorld.ismastersim then return inst end if inst.components.workable then --use these 2 lines: inst.components.workable:SetMaxWork(200)-- these lines sets all walls to 200 hammer hits inst.components.workable:SetWorkLeft(200) --or these 4 lines(not all 6): local maxwork = inst.components.workable.maxwork local multiplier = 3 inst.components.workable:SetMaxWork(maxwork * multiplier)--these lines instead multiple the amount of hammer hits inst.components.workable:SetMaxWork(maxwork * multiplier)--depending on multiplier, or in ur case "Effectiveness" end return inst end) end  Edited December 28, 2016 by Aquaterion fixed an issue Link to comment https://forums.kleientertainment.com/forums/topic/72914-need-help-for-creating-mod-interacting-with-walls/#findComment-853671 Share on other sites More sharing options...
Tesumoto Posted December 28, 2016 Author Share Posted December 28, 2016 11 minutes ago, Aquaterion said: you should be able to do (in modmain.lua): local wallmaterials = { MATERIALS.STONE, MATERIALS.WOOD, MATERIALS.HAY, "ruins", "MATERIALS.MOONROCK} for id,material in pairs(wallmaterials) do AddPrefabPostInit("wall_" .. material, function(inst) if not GLOBAL.TheWorld.ismastersim then return inst end if inst.components.workable then --use these 2 lines: inst.components.workable:SetMaxWork(200)-- these lines sets all walls to 200 hammer hits inst.components.workable:SetWorkLeft(200) --or these 4 lines(not all 6): local maxwork = inst.components.workable.maxwork local multiplier = 3 inst.components.workable:SetMaxWork(maxwork * multiplier)--these lines instead multiple the amount of hammer hits inst.components.workable:SetMaxWork(maxwork * multiplier)--depending on multiplier, or in ur case "Effectiveness" end return inst end) end  I must use this code without my old code? Link to comment https://forums.kleientertainment.com/forums/topic/72914-need-help-for-creating-mod-interacting-with-walls/#findComment-853676 Share on other sites More sharing options...
Aquaterion Posted December 28, 2016 Share Posted December 28, 2016 (edited) Just now, Tezumoto said: I must use this code without my old code? yeah, make sure to read the comments and pick which part of my code you want to use. And to implement your Effective variable Edited December 28, 2016 by Aquaterion Link to comment https://forums.kleientertainment.com/forums/topic/72914-need-help-for-creating-mod-interacting-with-walls/#findComment-853677 Share on other sites More sharing options...
Tesumoto Posted December 28, 2016 Author Share Posted December 28, 2016 4 minutes ago, Aquaterion said: yeah, make sure to read the comments and pick which part of my code you want to use How do I change the code so that I could through the settings change the number of hits? local wallmaterials = { MATERIALS.STONE, MATERIALS.MOONROCK, MATERIALS.RUINS} for id,material in pairs(wallmaterials) do AddPrefabPostInit("wall_" .. material, function(inst) if not GLOBAL.TheWorld.ismastersim then return inst end if inst.components.workable then inst.components.workable:SetMaxWork(200)-- these lines sets all walls to 200 hammer hits inst.components.workable:SetWorkLeft(200) end return inst end) end  Link to comment https://forums.kleientertainment.com/forums/topic/72914-need-help-for-creating-mod-interacting-with-walls/#findComment-853678 Share on other sites More sharing options...
Aquaterion Posted December 28, 2016 Share Posted December 28, 2016 Just now, Tezumoto said: How do I change the code so that I could through the settings change the number of hits? local wallmaterials = { MATERIALS.STONE, MATERIALS.MOONROCK, MATERIALS.RUINS} for id,material in pairs(wallmaterials) do AddPrefabPostInit("wall_" .. material, function(inst) if not GLOBAL.TheWorld.ismastersim then return inst end if inst.components.workable then inst.components.workable:SetMaxWork(200)-- these lines sets all walls to 200 hammer hits inst.components.workable:SetWorkLeft(200) end return inst end) end  does your "Effectiveness" number have a multiplier or a big number? You can easily just put that variable instead of the 200 if its a big number, but if its a multiplier you could use the other part of the code that you removed instead. Link to comment https://forums.kleientertainment.com/forums/topic/72914-need-help-for-creating-mod-interacting-with-walls/#findComment-853679 Share on other sites More sharing options...
Tesumoto Posted December 28, 2016 Author Share Posted December 28, 2016 1 minute ago, Aquaterion said: does your "Effectiveness" number have a multiplier or a big number? You can easily just put that variable instead of the 200 if its a big number, but if its a multiplier you could use the other part of the code that you removed instead. This code will work for mod Wall Gates? Link to comment https://forums.kleientertainment.com/forums/topic/72914-need-help-for-creating-mod-interacting-with-walls/#findComment-853680 Share on other sites More sharing options...
Aquaterion Posted December 28, 2016 Share Posted December 28, 2016 Just now, Tezumoto said: This code will work for mod Wall Gates? without some modification no, as it is only modifying the 3 prefabs wall_stone, wall_moonrock and wall_ruins (btw MATERIALS.RUINS doesnt exist, so change it back to "ruins") Link to comment https://forums.kleientertainment.com/forums/topic/72914-need-help-for-creating-mod-interacting-with-walls/#findComment-853681 Share on other sites More sharing options...
Tesumoto Posted December 28, 2016 Author Share Posted December 28, 2016 1 minute ago, Aquaterion said: without some modification no, as it is only modifying the 3 prefabs wall_stone, wall_moonrock and wall_ruins (btw MATERIALS.RUINS doesnt exist, so change it back to "ruins") You can replace materials on prefabs? Link to comment https://forums.kleientertainment.com/forums/topic/72914-need-help-for-creating-mod-interacting-with-walls/#findComment-853682 Share on other sites More sharing options...
Tesumoto Posted December 28, 2016 Author Share Posted December 28, 2016 (edited) 7 minutes ago, Aquaterion said: without some modification no, as it is only modifying the 3 prefabs wall_stone, wall_moonrock and wall_ruins (btw MATERIALS.RUINS doesnt exist, so change it back to "ruins") local wallmaterials = { MATERIALS.STONE, MATERIALS.MOONROCK, "ruins"} for id,material in pairs(wallmaterials) do AddPrefabPostInit("wall_" .. material, function(inst) if not GLOBAL.TheWorld.ismastersim then return inst end if inst.components.workable then inst.components.workable:SetMaxWork(200)-- these lines sets all walls to 200 hammer hits inst.components.workable:SetWorkLeft(200) end return inst end) end So? I hope it will work for walls and walls gates. Edited December 28, 2016 by Tezumoto Link to comment https://forums.kleientertainment.com/forums/topic/72914-need-help-for-creating-mod-interacting-with-walls/#findComment-853683 Share on other sites More sharing options...
Aquaterion Posted December 28, 2016 Share Posted December 28, 2016 1 minute ago, Tezumoto said: local wallmaterials = { MATERIALS.STONE, MATERIALS.MOONROCK, "ruins"} for id,material in pairs(wallmaterials) do AddPrefabPostInit("wall_" .. material, function(inst) if not GLOBAL.TheWorld.ismastersim then return inst end if inst.components.workable then inst.components.workable:SetMaxWork(200)-- these lines sets all walls to 200 hammer hits inst.components.workable:SetWorkLeft(200) end return inst end) end So? yeah. Is your Effectiveness variable a Multiplier? like x1 to x5 for example? Link to comment https://forums.kleientertainment.com/forums/topic/72914-need-help-for-creating-mod-interacting-with-walls/#findComment-853685 Share on other sites More sharing options...
Tesumoto Posted December 28, 2016 Author Share Posted December 28, 2016 6 minutes ago, Aquaterion said: yeah. Is your Effectiveness variable a Multiplier? like x1 to x5 for example? Effectiveness? This in old code, yep multiplier Link to comment https://forums.kleientertainment.com/forums/topic/72914-need-help-for-creating-mod-interacting-with-walls/#findComment-853690 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