Way to add ship build w/equipment in MD script?
Moderators: Scripting / Modding Moderators, Moderators for English X Forum
-
- Posts: 665
- Joined: Wed, 6. Nov 02, 20:31
Way to add ship build w/equipment in MD script?
Is it possible to get a shipyard to build a ship with a standard equipment preset (using resources, etc) via MD script? There's a node <add_build_to_construct_ship> but its loadout parameter only takes IDs that are defined in the ship macro, which isn't used for the normal faction ships. There are actions to manipulate the ship after creation but that seems to fabricate out of thin air which is not what I want in this case.
-
- Posts: 813
- Joined: Fri, 11. Nov 05, 23:18
Re: Way to add ship build w/equipment in MD script?
Pretty sure you could use the create commands to make a ship in non-visible space then reference the created ship as the buildobject to make a clone for actual costs:
Alternatively, just build the ship with the minimum loadout then use 'add_build_to_modify_ship' to change the equipment.
Code: Select all
<create_ship name="$cloneme" ... />
<add_build_to_construct_ship object="$shipyard" buildobject="$cloneme" />
<destroy_object name="$cloneme" explosion="false" />
-
- Posts: 665
- Joined: Wed, 6. Nov 02, 20:31
Re: Way to add ship build w/equipment in MD script?
add_build_to_modify_ship wants the same loadout ID so that won't work, but creating a ship in dead space, using the other loadout path and then duplicating it as a build might. I'll try it.
-
- Posts: 665
- Joined: Wed, 6. Nov 02, 20:31
Re: Way to add ship build w/equipment in MD script?
So, what "buildobject" actually does in <add_build_to_construct_ship> is it results in that object being reconstructed in place. It only "rebuilds" the hull, not the equipment, so it doesn't result in the resource usage I'm looking for.
Using <add_build_to_modify_ship> sort of works. It consumes the resources for the missing items on the ship, but only actually applies consumables and drones. Fortunately, once the build is done, at that point using <apply_loadout> will force the equipment onto the ship, so the end result is an equipped ship that used the proper resources to build. (finally)
Figuring out the number of consumables to build is its own task, though, since the loadout only exposes a ware list to script, not a count. Drones and deployables are constant space so just pick a number in the range but missile capacity depends on launchers, so it's a pain. Hopefully when they get to mod support they'll improve the options here.
Using <add_build_to_modify_ship> sort of works. It consumes the resources for the missing items on the ship, but only actually applies consumables and drones. Fortunately, once the build is done, at that point using <apply_loadout> will force the equipment onto the ship, so the end result is an equipped ship that used the proper resources to build. (finally)
Figuring out the number of consumables to build is its own task, though, since the loadout only exposes a ware list to script, not a count. Drones and deployables are constant space so just pick a number in the range but missile capacity depends on launchers, so it's a pain. Hopefully when they get to mod support they'll improve the options here.