Back to Index Page generated: Jun 13, 2026, 7:54:50 PM

Expansion Headlights

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Tune the light level with this primable equipment on the dark side of objects like you have powerful headlights. Tune the light level with this primable equipment on the dark side of objects like you have powerful headlights.
Identifier oolite.oxp.Norby.Headlights oolite.oxp.Norby.Headlights
Title Headlights Headlights
Category Ambience Ambience
Author Norby Norby
Version 1.2 1.2
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Dependent Expansions
  • oolite.oxp.Norby.Ambiences_recommended_by_Norby:1.6
  • Information URL http://wiki.alioth.net/index.php/Headlights n/a
    Download URL https://wiki.alioth.net/img_auth.php/3/39/Headlights.1.2.oxz n/a
    License CC BY-NC-SA 4 CC BY-NC-SA 4
    File Size n/a
    Upload date 1610873272

    Relationships Diagram

    Documentation

    Also read http://wiki.alioth.net/index.php/Headlights

    Headlights_readme.txt

    Headlights
    
    If you buy, prime (Shift+N) and activate (n) this equipment then you raise the level of the ambient light around you. Another activate set it back to the previous level as you turn on/off your headlights.
    
    Using the mode (b) key you can change the function of the activate key between the following modes:
    * switch between default and high level (on/off),
    * decrease default level,
    * increase default level,
    * save the current level as high level (min. value: 2) and reset the default level to 1.
    
    Useful with dark monitors combined with integrated graphics without gamma settings.
    
    After you set your lights dock and save your game, this will be stored in your savegame. If you remove the equipment to reduce the length of your primable list, your setting will be remain. But if you keep it then you can use it to find ships: if you turn on an off repeatedly then highlight objects over the stars.
    
    Can override very dark ambient_level settings in OXZs like Realistic Stars.
    
    If your Oolite is older than 1.81 then you can edit the default setting in the Config/planetinfo.plist, for example set to 0.5 if you want darker than the default but not so dark than in Realistic Stars which is 0.1.
    
    For more information see the regarding discussuion:
    http://aegidian.org/bb/viewtopic.php?f=2&t=4494&start=4215#p230222
    
    
    Instructions:
    
    Do not unzip the .oxz file, just move into the AddOns folder of your Oolite installation.
    
    License:
    
    This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike License version 4.0.
    If you are re-using any piece of this OXP, please let me know by sending an e-mail to norbylite@gmail.com.
    
    Changelog:
     2016.01.01. v1.2  New mode key functions.
     2015.05.10. v1.1  Fixed a bug after load game reported by Day.
     2014.12.04. v1.0  First release.
    

    Equipment

    Name Visible Cost [deci-credits] Tech-Level
    Headlights yes 100 1+
    Remove Headlights yes 0 1+

    Ships

    This expansion declares no ships.

    Models

    This expansion declares no models.

    Scripts

    Path
    Scripts/headlights.js
    "use strict";
    this.name	= "headlights";
    this.author	= "Norby";
    this.copyright	= "2014 Norby";
    this.description= "Tune the light level on the dark side of objects";
    this.licence	= "CC BY-NC-SA 4.0";
    
    //internal properties, should not touch
    this.$Level = 1; //darker than the default but not "too" dark as 0.1 in Realistic Stars
    this.$Level2 = 4; //highlight objects over star-filled background
    this.$Mode = 1; //current mode
    
    //equipment events
    this.activated = function() { //increase ambient level
            var w = worldScripts["headlights"];
            switch(w.$Mode) {
                    case 1: //switch between default and high level
                    if( system.ambientLevel == w.$Level2 )
                            system.ambientLevel = w.$Level;
                    else system.ambientLevel = w.$Level2;
                    player.consoleMessage("Headlights set to "
                            +Math.round(system.ambientLevel*100)/100, 3);
                    break;
                    case 2: //decrease ambientLevel
                    w.$eq(false, w);
                    break;
                    case 3: //increase ambientLevel
                    w.$eq(true, w);
                    break;
                    case 4: //save as high level
                    w.$Level2 = w.$hi();
                    player.consoleMessage("Headlights high level set to "+w.$Level2
                            +", default level set back to 1", 3);
                    system.ambientLevel = w.$Level = 1; //reset default to 1
                    w.$Mode = 1; //back to the switching mode
                    break;
                    default: //for sure
                    w.$Mode = 1;
                    break;
            }
    }
    
    this.mode = function() { //decrease ambient level
            var w = worldScripts["headlights"];
            w.$Mode++;
            if( w.$Mode > 4 ) w.$Mode = 1;
            switch(w.$Mode) {
                    case 1: //switch between default and high level
                    player.consoleMessage("Headlights mode: switch between default and high level", 3);
                    break;
                    case 2: //decrease ambientLevel
                    player.consoleMessage("Headlights mode: decrease level", 3);
                    break;
                    case 3: //increase ambientLevel
                    player.consoleMessage("Headlights mode: increase level", 3);
                    break;
                    case 4: //save as high level
                    player.consoleMessage("Headlights mode: save "+w.$hi()+" as high level", 3);
                    break;
                    default: //for sure
                    w.$Mode = 1;
                    break;
            }
    }
    
    //worldscript events
    this.startUp = function() {
            var l = missionVariables.$HeadlightsLevel;
            if( l ) {
                    this.$Level = l;
                    if( system.ambientLevel ) system.ambientLevel = l;
            }
            l = missionVariables.$HeadlightsLevel2;
            if( l ) this.$Level2 = l;
    }
    
    this.playerBoughtEquipment = function(equipmentKey) {
    	if( equipmentKey == "EQ_Headlights_REMOVE" ) {
    		var eq = equipmentKey.substr( 0, equipmentKey.length-7 );//the real eq
    		player.ship.removeEquipment( eq ); //remove it
    		player.ship.removeEquipment( equipmentKey ); //remove the "bought" remove eq
    	}
    }
    
    this.playerWillSaveGame = function(message) {
            missionVariables.$HeadlightsLevel = this.$Level;
            missionVariables.$HeadlightsLevel2 = this.$Level2;
    }
    
    this.shipWillExitWitchspace = function() {
    	system.ambientLevel = this.$Level; //force in every system
    }
    
    //headlights functions
    this.$eq = function(up, w) { //decrease ambient level
    	if( !system.ambientLevel ) {
    		player.consoleMessage("You need Oolite 1.81 to use this equipment"
    			+" but you can change ambient_level by hand in Config/planetinfo.plist", 10);
    		return;
    	}
    	var step = 0.05;
    	if( w.$Level > 1.5 || up && w.$Level == 1.5 ) step = 0.5;
    	if( w.$Level < 0.05 ) w.$Level = 0;
    	if( up ) {
    		w.$Level += step;
    		if( w.$Level > 10 ) w.$Level = 0.01;
    	} else {
    		w.$Level -= step;
    		if( w.$Level < 0 ) w.$Level = 10;
    	}
    	if(w.$Level == 0) w.$Level = 0.01;
    	w.$Level = Math.round(w.$Level*100)/100;
    	system.ambientLevel = w.$Level;
    	player.consoleMessage("Headlights set to "+w.$Level, 3);
    }
    
    this.$hi = function() { //high ambient level
            var hi = Math.round(system.ambientLevel*100)/100;
            if( hi < 2 ) hi = 2; //min. 2
            return hi;
    }