Back to Index Page generated: May 8, 2024, 6:16:03 AM

Expansion Traffic Lights

Content

Warnings

  1. No version in dependency reference to oolite.oxp.Thargoid.Neo-Docklights:null
  2. Conflict Expansions mismatch between OXP Manifest and Expansion Manager at character position 0068 (DIGIT ZERO vs LATIN SMALL LETTER N)

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description This OXP helps to override annoying problem of frozen docking queue. Emergency docking timer will be started immediately after request to docking clearance and after 15 min of waiting you will receive docking priority. In addition to text info this OXP provides visual helpers - string of colored flashers on approach lane between main station docking port and beacon. This OXP helps to override annoying problem of frozen docking queue. Emergency docking timer will be started immediately after request to docking clearance and after 15 min of waiting you will receive docking priority. In addition to text info this OXP provides visual helpers - string of colored flashers on approach lane between main station docking port and beacon.
Identifier oolite.oxp.stranger.TrafficLights oolite.oxp.stranger.TrafficLights
Title Traffic Lights Traffic Lights
Category Mechanics Mechanics
Author stranger stranger
Version 1.1.1 1.1.1
Tags docking, clearance, queue, station docking, clearance, queue, station
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
  • oolite.oxp.Thargoid.Neo-Docklights:0
  • oolite.oxp.Thargoid.Neo-Docklights:
  • Information URL http://aegidian.org/bb/viewtopic.php?f=4&t=19588 n/a
    Download URL https://wiki.alioth.net/img_auth.php/3/3c/TrafficLights.oxz n/a
    License CC-BY-NC-SA 3.0 CC-BY-NC-SA 3.0
    File Size n/a
    Upload date 1610873278

    Documentation

    Also read http://wiki.alioth.net/index.php/Traffic%20Lights

    ReadMe & License.txt

    Traffic Lights OXP by Stranger
    
    This OXP is released under the Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license.
    You are free to use and distribute this OXP on non-commercial basis. 
    Rebundling of this OXP within another distribution is permitted as long as it is unchanged.
    Any mods/derivatives of this OXP must be distributed under another names.
    The license information (either as this file or merged into a larger one) must be included in the OXP.
    
    --------------------------------------------------------------
    
    Instructions:
    
    Unzip the file, and then move the folder "Traffic Lights.oxp" to the AddOns directory of your Oolite installation. Then start the game up.
    
    This OXP helps to override annoying problem of frozen docking queue. Emergency docking timer will be started immediately after request to docking clearance (select station as target and press Shift-L) and after 15 min of waiting you will receive docking priority.
    You will also receive emergency docking priority in case of aft shield dropped below 0.1 max level (test for fuel depletion if Hard Way OXP is installed).
    Emergency docking clearance is performed on main station only and if you have no Fugitive status!
    In addition to text info this OXP provides visual helpers - string of colored flashers on approach lane between main station docking port and beacon.
    
    RED - docking is prohibited.
    YELLOW - docking is allowed, but there are ships in approach lane OR you have less then 30 seconds to dock.
    GREEN - docking is allowed and approach is clear.
    BLUE - player is not in docking queue.
    
    Dependencies:
    
    This OXP is incompatible with Neo-Dock Lights OXP by Thargoid.
    It is strongly recommended to avoid using other visual docking helper OXPs to prevent graphic clutter.
    Installing my Hard Way OXP is highly recommended, but not obligatory.
    
    Credits:
    
    Modified code from Neo-Dock Lights OXP by Thargoid was used for visualisation of docking status.
    I thank commander vasig for invaluable help in testing this OXP in state of development.
    I thank also commander cyxoway for multiple timer issue report in emergency_docking.js and improved method of timer management in traffic_lights.js.
    
    ______________________________________________________________
    
    Version history:
    
    29.01.2019 - Version 1.1.1	Converted to OZX.
    15.04.2018 - Version 1.1	Refining code issues.
    				manifest.plist added.
    08.09.2017 - Version 1.0	Blue flashers added to indicate player not in docking queue.
    				Improved method of timer management in traffic_lights.js.
    23.08.2017 - Version 0.9	Fixed multiple timer issue.
    				Aft shield level to permit emergency docking clearance lowered to 0.1 of max level.
    01.07.2017 - Version 0.8	Fixed situation with docking clearance timing out: flashers switches to yellow, not red.
    15.06.2017 - Version 0.7.	String of colored flashers is added as visual helpers to indicate docking status.
    				Changing name of OXP.
    11.06.2017 - Version 0.6.	Emergency docking clearance before timer goes zero is permitted if aft shield dropped below 0.25 of max level, not in Red condition.
    08.06.2017 - Version 0.5.	Emergency docking timer freezed if main station in battle regime (condition Red).
    				Kills emergency docking timer if player receives docking permission.
    08.06.2017 - Version 0.4.	Emergency docking clearance is unavailable on Fugitive legal status.
    				Emergency docking clearance before timer goes zero is permitted only in Red condition. 
    07.06.2017 - Version 0.3.	Fixed error causing running emergency timer on docking request other than main station.
    07.06.2017 - Version 0.2.	Fixed error causing penalty in case of emergency docking.
    06.06.2017 - Version 0.1.	Initial release.

    Equipment

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

    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/emergency_docking.js
    "use strict";
    this.name				= "Emergency Docking Clearance";
    this.author				= "Stranger";
    this.copyright			= "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
    this.description		= "Override docking delays";
    this.version			= "1.1";
    
    this.$waitingLimit = 15; // max 15 min
    
    this.shipWillLaunchFromStation = this.shipEnteredStationAegis = function()
    	{
    	if(system.isInterstellarSpace || !system.mainStation.isValid)
    		{ return; }
    	system.mainStation.requiresDockingClearance = true;
    	this.$waitingCounter = 0;
        this.$waitingTime = this.$waitingLimit;
    	}
        
    this.shipWillDockWithStation = this.shipWillEnterWitchspace = this.shipExitedStationAegis = function()
    	{
        this.shipDied();
        }
    
    this.$setClearance = function()
    	{
    	if(!system.mainStation || player.dockingClearanceStatus == "DOCKING_CLEARANCE_STATUS_GRANTED")
    		{
    		this.shipDied();
    		return; 
    		}
        this.$waitingCounter += 1;
        var message;
        if (this.$waitingCounter >= 60)
            {
            if (system.mainStation.alertCondition == 3)
                {
                message = "Emergency docking frozen";
                }
            else
                {
                this.$waitingTime -= 1;
                if (this.$waitingTime > 0 && player.ship.aftShield >= 0.1 * player.ship.maxAftShield)
                    {
                    message = "Emergency docking in " + this.$waitingTime + " min";
                    }
                else
                    {
                    system.mainStation.requiresDockingClearance = false;
                    message = "Emergency docking allowed";            
                    }
                }
            player.consoleMessage("\n\n\n\n\n\n\n\n\n\n Docking clearance status: " + message,5);
            this.$waitingCounter -= 60;
            }
    	}
    
    this.shipDied = function()
    	{
    	if(this.$dockTimer) 
    		{
    		this.$dockTimer.stop();
    		delete this.$dockTimer;
    		}
    	}
    
    this.playerRequestedDockingClearance = function(message)
        {
        if (player.ship.target != system.mainStation || player.bounty > 50 || system.mainStation.alertCondition == 3)
            { return; }
        if (player.ship.aftShield < 0.1 * player.ship.maxAftShield) // shields possibly shut down
            {
            system.mainStation.requiresDockingClearance = false;
            }
        else
            {
            if (!this.$dockTimer)
                {
                this.$dockTimer = new Timer(this, this.$setClearance, 0, 1);
                }
            }
        }
    Scripts/traffic_lights.js
    "use strict";
    this.name				= "Traffic Lights";
    this.author				= "Stranger";
    this.copyright			= "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
    this.description		= "Indicates docking clearance status";
    this.version			= "1.1";
    
    // this script is partially based on Neo-Dock Lights OXP by Thargoid
    
    this.startUp   = function ()
        {
    	this.$lightsStatus = "BLUE";
    	this.$lightsTimer = new Timer(this, this.$setLights, 0, 1);
    	this.$lightsTimer.stop();
        }
    
    this.shipWillLaunchFromStation = this.shipEnteredStationAegis = function()
    	{
    	if(system.isInterstellarSpace || !system.mainStation || !system.mainStation.isValid)
    		{ return; }
    	this.$lightsPosition = system.mainStation.position.add(system.mainStation.vectorForward.multiply(10000));
        this.$lights = system.addVisualEffect("dockLights_blue", this.$lightsPosition);	
        this.$lights.orientation = system.mainStation.orientation;
        this.$lightsTimer.start();
    	}
        
    this.shipWillDockWithStation = this.shipWillEnterWitchspace = this.shipExitedStationAegis = function()
    	{
        this.shipDied();
        }
    
    this.$setLights = function()
    	{
    	if(!system.mainStation) 
    		{
    		this.shipDied();
    		return; 
    		}
    
        function dockingShips(entity) {return entity.isShip && !entity.isPlayer && !entity.hasRole("buoy") && ((entity.position.distanceTo(system.mainStation.position) + entity.position.distanceTo(this.$lights.position)) < 10100)}
    	var incomingArray = system.filteredEntities(this, dockingShips, system.mainStation, 10000);
    
    	this.$lightsPosition = system.mainStation.position.add(system.mainStation.vectorForward.multiply(10000));
    	
        if(player.dockingClearanceStatus == "DOCKING_CLEARANCE_STATUS_GRANTED" || !system.mainStation.requiresDockingClearance)
            {
            this.$dockingStatus = "GREEN";
            }
        else
            {
            if(player.dockingClearanceStatus == "DOCKING_CLEARANCE_STATUS_TIMING_OUT")
                {
                this.$dockingStatus = "YELLOW";
                }
            else
                {
                if(player.dockingClearanceStatus == "DOCKING_CLEARANCE_STATUS_REQUESTED")
                    {
                    this.$dockingStatus = "RED";
                    }
                else
                    {
                    this.$dockingStatus = "BLUE";
                    }
                }
            }
    
        // condition RED
    	if(this.$dockingStatus == "RED" && this.$lightsStatus != "RED")
    		{ 
    		this.$removeLights();
    		this.$lights = system.addVisualEffect("dockLights_red", this.$lightsPosition);	
    		this.$lights.orientation = system.mainStation.orientation;
    		this.$lightsStatus = "RED";		
    		return;
    		}
    
        // condition YELLOW
    	if((this.$dockingStatus == "YELLOW" || (this.$dockingStatus == "GREEN" && incomingArray.length > 0)) && this.$lightsStatus != "YELLOW")
    		{ 
    		this.$removeLights();
    		this.$lights = system.addVisualEffect("dockLights_yellow", this.$lightsPosition);	
    		this.$lights.orientation = system.mainStation.orientation;
    		this.$lightsStatus = "YELLOW";		
    		return;
    		}
    		
        // condition GREEN
    	if(this.$dockingStatus == "GREEN" && incomingArray.length == 0 && this.$lightsStatus != "GREEN")
    		{ 
    		this.$removeLights();
    		this.$lights = system.addVisualEffect("dockLights_green", this.$lightsPosition);
    		this.$lights.orientation = system.mainStation.orientation;
    		this.$lightsStatus = "GREEN";
    		return;
    		}
    
        // condition BLUE
    	if(this.$dockingStatus == "BLUE" && this.$lightsStatus != "BLUE")
    		{ 
    		this.$removeLights();
    		this.$lights = system.addVisualEffect("dockLights_blue", this.$lightsPosition);	
    		this.$lights.orientation = system.mainStation.orientation;
    		this.$lightsStatus = "BLUE";		
    		return;
    		}
    
    	}
    
    this.shipDied = this.shipWillEnterWitchspace = this.shipExitedStationAegis = function()
    	{
    		this.$lightsTimer.stop();		
    		this.$removeLights();
    		this.$lightsStatus = "BLUE";
    	}	
    	
    this.$removeLights = function()
    	{
    	var count = system.allVisualEffects.length;
    	if(count === 0) { return; }
    	for (var i=count-1; i>=0; i--)
    		{
    		if(system.allVisualEffects[i].dataKey === "dockLights_green" || system.allVisualEffects[i].dataKey === "dockLights_yellow" || system.allVisualEffects[i].dataKey === "dockLights_red" || system.allVisualEffects[i].dataKey === "dockLights_blue")
    			{ system.allVisualEffects[i].remove(); }
    		}
    	}