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

Expansion Reverse Y Control

Content

Warnings

  1. No version in dependency reference to oolite.oxp.Norby.ReverseControl:null
  2. Conflict Expansions mismatch between OXP Manifest and Expansion Manager at character position 0065 (DIGIT ZERO vs LATIN SMALL LETTER N)
  3. Unknown key 'upload_date' at https://wiki.alioth.net/img_auth.php/d/df/ReverseYControl_1.5.oxz!manifest.plist

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Your ship's up-down and roll controls will be equal in all views, but use the opposite vertical directions as ReverseControl. Your ship's up-down and roll controls will be equal in all views, but use the opposite vertical directions as ReverseControl.
Identifier oolite.oxp.Norby.ReverseYControl oolite.oxp.Norby.ReverseYControl
Title Reverse Y Control Reverse Y Control
Category Mechanics Mechanics
Author Norby Norby
Version 1.5 1.5
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
  • oolite.oxp.Norby.ReverseControl:0
  • oolite.oxp.Norby.ReverseControl:
  • Information URL http://wiki.alioth.net/index.php/ReverseControl n/a
    Download URL https://wiki.alioth.net/img_auth.php/d/df/ReverseYControl_1.5.oxz n/a
    License CC-BY-NC-SA 4.0 CC-BY-NC-SA 4.0
    File Size n/a
    Upload date 1610873488

    Documentation

    Also read http://wiki.alioth.net/index.php/Reverse%20Y%20Control

    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/reverseycontrol.js
    "use strict";
    this.name        = "reverseycontrol";
    this.author      = "Norby";
    this.copyright   = "2014 Norbert Nagy";
    this.licence     = "CC BY-NC-SA 3.0";
    this.description = "Reverse up-down control in the aft view.";
    
    //customizable properties
    this.$ReverseControlOn = true; //can turn off without uninstall
    
    //internal properties, should not touch
    this.$ReverseControlFCB = null; //FrameCallBack
    this.$ReverseControlPrevOri = null; //previous orientation
    
    //world script events
    this.startUp = function() {
    }
    
    this.shipLaunchedFromStation = this.shipExitedWitchspace = function( station ) {
    	this.viewDirectionChanged(player.ship.viewDirection);
    }
    
    this.shipWillDockWithStation = function(station) {
    	this.$Stop();
    }
    
    this.viewDirectionChanged = function( view ) {
    	switch ( view ) {
    		case "VIEW_AFT":
    		case "VIEW_FORWARD":
    		case "VIEW_PORT":
    		case "VIEW_STARBOARD":
    			var ps = player.ship;
    			if( ps && ps.isValid ) this.$ReverseControlPrevOri = ps.orientation;
    			if( this.$ReverseControlOn && !isValidFrameCallback( this.$ReverseControlFCB ) )
    				this.$ReverseControlFCB = addFrameCallback( this.$ReverseControl_FCB.bind(this) );
    			break;
    		default:
    			this.$Stop();
    	}
    }
    
    //ReverseControl methods
    this.$ReverseControl_FCB = function( delta ) { //FrameCallBack
    	var ps = player.ship;
    	var r = worldScripts["reversecontrol"];
    	if( ps && ps.isValid && !ps.docked && this.$ReverseControlOn && ps.AI != "dockingAI.plist" ) {
    		var prevori = this.$ReverseControlPrevOri;
    		if( prevori ) switch ( ps.viewDirection ) {
    			case "VIEW_FORWARD":
    				//reverse up-down
    				//var a = ps.heading.angleTo( prevori.vectorUp() ) - Math.PI / 2; //buggy with sniperlock
    				var a = ps.pitch * delta;
    				var c = prevori.vectorRight();
    				ps.orientation = ps.orientation.rotate( c, 2 * a );
    				break;
    			case "VIEW_AFT":
    				//reverse roll
    				//var a = ps.orientation.vectorRight().angleTo( prevori.vectorUp() ) - Math.PI / 2; //buggy with sniperlock
    				var a = ps.roll * delta;
    				var c = prevori.vectorForward();
    				ps.orientation = ps.orientation.rotate( c, 2 * a );
    				break;
    			case "VIEW_PORT":
    				//pitch -> -roll
    				var a = ps.pitch * delta;
    				var c = prevori.vectorForward();
    				ps.orientation = ps.orientation.rotate( c, 2 * a );
    				//roll -> -pitch
    				var a = ps.roll * delta;
    				var c = prevori.vectorRight();
    				ps.orientation = ps.orientation.rotate( c, 2 * a );
    				break;
    			case "VIEW_STARBOARD":
    				//pitch -> roll
    				var a = ps.pitch * delta;
    				var c = prevori.vectorForward();
    				ps.orientation = ps.orientation.rotate( c, -2 * a );
    				//roll -> pitch
    				var a = ps.roll * delta;
    				var c = prevori.vectorRight();
    				ps.orientation = ps.orientation.rotate( c, -2 * a );
    				break;
    			default:
    				this.$Stop();
    		}
    		this.$ReverseControlPrevOri = ps.orientation;
    	} else {
    		this.$ReverseControlPrevOri = null;
    	}
    }
    
    this.$Stop = function() {
    	this.$ReverseControlPrevOri = null;
    	if( isValidFrameCallback( this.$ReverseControlFCB ) )
    		removeFrameCallback( this.$ReverseControlFCB );
    }