Back to Index Page generated: Sep 1, 2025, 4:12:03 AM

Expansion Turret Toggler

Content

Warnings

  1. Unknown key 'upload_date' at https://wiki.alioth.net/img_auth.php/1/10/TurretToggler_1.2.oxz!manifest.plist

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Toggle turrets on and off, this helps a lot with friendly fire. Toggle turrets on and off, this helps a lot with friendly fire.
Identifier oolite.oxp.Turret_Toggler oolite.oxp.Turret_Toggler
Title Turret Toggler Turret Toggler
Category Equipment Equipment
Author Thargoid, Solonar, Lone_Wolf Thargoid, Solonar, Lone_Wolf
Version 1.2 1.2
Tags Equipment, Weapons, Turrets Equipment, Weapons, Turrets
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL http://wiki.alioth.net/index.php/Turret_Toggler n/a
Download URL https://wiki.alioth.net/img_auth.php/1/10/TurretToggler_1.2.oxz n/a
License CC-BY-NC-SA 3.0 with clauses CC-BY-NC-SA 3.0 with clauses
File Size n/a
Upload date 1753399685

Documentation

Also read http://wiki.alioth.net/index.php/Turret%20Toggler

readme.txt

Turret Toggler modified by Solonar & Lone_Wolf

Instructions:

Turret Toggler equipment is available for F3 screen at TL 7 and above systems.
Once installed you will have a new primable equipment that allows to toggle the ship's turrets on and off.
It should work any ship that has turrets, except those ships that have their own way to toggle turrets (Vortex ? )




--------------------------------------------------------------

License:

This OXP is released under the Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license with the following clauses:

* Whilst you are free (and encouraged) to re-use any of the scripting, models or texturing in this OXP, the usage must be distinct from that within this OXP. Unique identifiers such as (but not limited to) unique shipdata.plist entity keys, mission variables, script names (this.name), equipment identity strings (EQ_), description list arrays and entity roles must not be re-used without prior agreement. Basically if it's unique or would identify or overwrite anything in the original OXP, then you may not re-use it (for obvious compatibility reasons).
* rebundling of this OXP within another distribution is permitted as long as it is unchanged. The following derivates however are permitted and except from the above:
	* the conversion of files between XML and openStep.
	* the merging of files with other files of the same type from other OXPs.
* The license information (either as this file or merged into a larger one) must be included in the OXP.
* Even though it is not compulsory, if you are re-using any sizable or recognisable piece of this OXP, please let me know :)


--------------------------------------------------------------
Changes in version 1.2
no longer removes all subentities, only turrets.
cleanup/restructuring of code, including renaming of scripts, variables and functions
device is now invulnerable
upon docking turrets HAVE to be restored to avoid getting unnecessary maintenance overhaul in F3 screen.
This means oxps that check for turrets while docked (feudal states does) , will see your ship as having turrets even though you have deactivated them.
Given that you can re-enable turrets at any time in-flight, i think this is correct behaviour.

Version history:

12-01-2012:  0.01 - Proof of concept and test release
12-02-2012:  0.02 - Added docking event handler scripts to correct maintenance offers for missing sub-entities.
12-04-2012:  1.0 - Final release, corrected some typos, works as advertised.
01-31-2013:  1.1 - Made the equipment removable through the ship outfitter.  Raised tech level and price to fit into the grand scheme of the Ooniverse.


--------------------------------------------------------------

Acknowledgements:

Thargoid for the original authoring of the turret toggle code found in the Vortex OXP
Solanar for creating the Turret Toggler oxp.

Equipment

Name Visible Cost [deci-credits] Tech-Level
Turret Toggler yes 20000 7+
Sell Turret Toggler yes 0 7+

Ships

This expansion declares no ships. This may be related to warnings.

Models

This expansion declares no models. This may be related to warnings.

Scripts

Path
Scripts/tt_equipment_events.js
"use strict";
this.name               = "TT Equipment Events";
this.author             = "Original code by Thargoid.  Modified code by Solonar, later modifications by Lone_Wolf";
this.copyright		= "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description	= "Equipment event handlers for Turret Toggler aka Universal Turret Switcher";
this.version		= "1.2";

this.activated = function()
  {	
    if ( worldScripts["Turret Toggler"]._tt_turret_status == "active" )
      {
        player.consoleMessage("Ship's turrets are now deactivated.",6);
        worldScripts["Turret Toggler"]._tt_turret_status = "inactive";
      }
    else
      {
        player.consoleMessage("Ship's turrets are now activated.",6);
        worldScripts["Turret Toggler"]._tt_turret_status = "active";
      };
    worldScripts["Turret Toggler"]._tt_toggle_turret_status(worldScripts["Turret Toggler"]._tt_turret_status );
  };
Scripts/tt_worldscript_events.js
"use strict";
this.name               = "TT WorldScript Events";
this.author             = "Original code by Thargoid.  Modified code by Solonar, later modifications by Lone_Wolf";
this.copyright		= "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description	= "worlsscript event handlers for Turret Toggler aka Universal Turret Switcher";
this.version		= "1.2";


this.startUp = function()
  {
    if ( worldScripts["Turret Toggler"].startUp ) { worldScripts["Turret Toggler"].startUp(); };
  };


this.shipLaunchedFromStation = function(station)
  {
    if ( worldScripts["Turret Toggler"]._tt_turret_status == "inactive" )
      {
        // remove turrets if they are de-activated (having been restored on docking to avoid overhaul offer)
	worldScripts["Turret Toggler"]._tt_toggle_turret_status("inactive"); 
      };
  };

this.shipWillDockWithStation = function(station)
  {
    if ( worldScripts["Turret Toggler"]._tt_turret_status == "inactive" )
      {
        // if the turrets are not on the ship on docking, a maintenance overhaul is offered to restore them!
        player.ship.restoreSubEntities(); 
      };
  };
	
this.playerBoughtEquipment = function(equipmentKey)
  {     
    switch ( equipmentKey )
      {
        case "EQ_UNI_TURRET":
          worldScripts["Turret Toggler"]._tt_turret_status = "active";
          missionVariables.uni_turret = "active";
          break;
        case "EQ_UNI_TURRET_REMOVAL":
          if ( worldScripts["Turret Toggler"]._tt_turret_status == "inactive" ) { player.ship.restoreSubEntities(); };
          player.ship.removeEquipment("EQ_UNI_TURRET");
          player.ship.removeEquipment("EQ_UNI_TURRET_REMOVAL");
          player.credits += 1500;
          delete missionVariables.uni_turret;
          break;
        default:
          break;
      };
  };

this.playerWillSaveGame = function()
  {
    if ( missionVariables.uni_turret ) { missionVariables.uni_turret = worldScripts["Turret Toggler"]._tt_turret_status; };
  };
Scripts/turret_toggler.js
"use strict";
this.name               = "Turret Toggler";
this.author             = "Original code by Thargoid.  Modified code by Solonar, later modifications by Lone_Wolf";
this.copyright		= "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description	= "Main script for the Turret Toggler aka Universal Turret Switcher";
this.version		= "1.2";


this._tt_turret_status = "active"

this.startUp = function()
  {
    if ( missionVariables.uni_turret ) { this._tt_turret_status = missionVariables.uni_turret };
    delete this.startUp;
  };


this._tt_toggle_turret_status = function(set)
  {
    // set = string, "active" or "inactive"
    switch (set)
      {
        case "active":
          player.ship.restoreSubEntities();
          // refresh ship target , this should make sure turrets get current target
          var current_target = player.ship.target
          player.ship.target = null;
          player.ship.target = current_target;
          break;
        case "inactive":
          var subCounter = 0;
          for ( subCounter = player.ship.subEntities.length - 1;subCounter>=0;subCounter-- )
            { 
              if ( player.ship.subEntities[subCounter].isTurret ) { player.ship.subEntities[subCounter].remove(); };
            };
          break;
        default:
          break;
      };
  };