diff --git a/src/spaceObjects/spaceship.cpp b/src/spaceObjects/spaceship.cpp index b6382cc202..83ef76f2d7 100644 --- a/src/spaceObjects/spaceship.cpp +++ b/src/spaceObjects/spaceship.cpp @@ -102,6 +102,12 @@ REGISTER_SCRIPT_SUBCLASS_NO_CREATE(SpaceShip, ShipTemplateBasedObject) /// Returns the size of the tube /// Example: local size = ship:getTubeSize(0) REGISTER_SCRIPT_CLASS_FUNCTION(SpaceShip, getTubeSize); + // Returns the time for a tube load + // Example: load_time = ship:getTubeLoadTime(0) + REGISTER_SCRIPT_CLASS_FUNCTION(SpaceShip, getTubeLoadTime); + // Sets the load time for a tube + // Example ship:setTubeLoadTime(0, 15) + REGISTER_SCRIPT_CLASS_FUNCTION(SpaceShip, setTubeLoadTime); /// Set the icon to be used for this ship on the radar. /// For example, ship:setRadarTrace("RadarBlip.png") will show a dot instead of an arrow for this ship. /// Note: Icon is only shown after scanning, before the ship is scanned it is always shown as an arrow. @@ -1272,6 +1278,22 @@ EMissileSizes SpaceShip::getTubeSize(int index) return weapon_tube[index].getSize(); } +float SpaceShip::getTubeLoadTime(int index) +{ + if (index < 0 || index >= max_weapon_tubes) { + return 0; + } + return weapon_tube[index].getLoadTimeConfig(); +} + +void SpaceShip::setTubeLoadTime(int index, float time) +{ + if (index < 0 || index >= max_weapon_tubes) { + return; + } + weapon_tube[index].setLoadTimeConfig(time); +} + void SpaceShip::addBroadcast(int threshold, string message) { if ((threshold < 0) || (threshold > 2)) //if an invalid threshold is defined, alert and default to ally only diff --git a/src/spaceObjects/spaceship.h b/src/spaceObjects/spaceship.h index f9dc03cc58..dbe04cb2cd 100644 --- a/src/spaceObjects/spaceship.h +++ b/src/spaceObjects/spaceship.h @@ -436,6 +436,8 @@ class SpaceShip : public ShipTemplateBasedObject void setWeaponTubeSize(int index, EMissileSizes size); void setTubeSize(int index, EMissileSizes size); EMissileSizes getTubeSize(int index); + void setTubeLoadTime(int index, float time); + float getTubeLoadTime(int index); void setRadarTrace(string trace) { radar_trace = trace; }