Starbound

Starbound

Mech Compatibility Loader
FelmastProMcLane  [udvikler] 23. nov. 2024 kl. 21:57
Mech Arms Hooking
This discussion is about the method available for hooking mech arm scripts.

Base vs Specific
:Mech arms have usually 2 scripts, "base.lua" and "[any].lua", so there are 2 hook positions for these, not only that, but it has 2 arms, and the code for "[any].lua".

If only modifying the base is needed, the patch with "/mecharmsBase/-" can be used, any time the "base.lua" script is loaded, the scripts in this list are too.

Now for the harder ones, "[any].lua" can be "beamarm.lua", "gatling.lua", "anymodded.lua" and because there are 2 arms that must read data from these, hooking is more difficult.
  • Patch with "/mecharms/-" to add to the custom scripts.
  • Put your hooks into the lua file.
  • Check if leftArm or rightArm are loaded and available.
  • An example is included in the mod, check for "/vehicles/modularmech/armscripts/compat_base_armpower_dyn.lua"

For "damageSources" arms:
  • Hook into the player/deployment script: "/deploymentConfig/scripts/-"
  • Hook into MechPartManager class:
    MechPartManager.orig_mod_partConfig = MechPartManager.partConfig function MechPartManager:partConfig(partType, itemDescriptor) local res = self:orig_mod_partConfig (partType, itemDescriptor) --Your Code here if res then if res.damageSources then for _, sourceData in pairs(res.damageSources) do if sourceData.damage then local tier = world.threatLevel() sourceData.damage = sourceData.damage * tier end end end end --End of your code return res end
Sidst redigeret af FelmastProMcLane; 14. dec. 2024 kl. 21:18