Scriptable Space Background Colour
Posted: Sat Dec 15, 2012 2:02 pm
I've posted this here rather than in my usual thread for random code hacks as I reckon this has more feasible uses than more than 8 galaxies or a Galactic Hyperdrive that allows you to travel in both directions by either pressing g to go forward or Shift-G to go backwards (although I would love to see these features in the game, but let's not start that argument again!).
By making the following changes to the source code, it would enable OXP writers to produce different coloured space backgrounds in different systems either by editing the planetinfo.plist file in the 'Config' directory or by Javascript. I'm using the source code for version 1.76.1 but this can also be done in the Trunk. Firstly, open up the Universe.m file in the 'src\Core' directory and go to line 632 and replace the following code: With the following code: Now go to about line 862 in the same file and find the following code: And replace the above code with the following: Now go down to about line 5092 and replace the following code: With the code below: Now go down to about line 9071 and insert the following code: Now compile the game and you're ready to test. You can now define space colours either by using planetinfo.plist file and using the following code: Which will now make space in the Lave system blue, or you could use a script command like
By making the following changes to the source code, it would enable OXP writers to produce different coloured space backgrounds in different systems either by editing the planetinfo.plist file in the 'Config' directory or by Javascript. I'm using the source code for version 1.76.1 but this can also be done in the Trunk. Firstly, open up the Universe.m file in the 'src\Core' directory and go to line 632 and replace the following code:
Code: Select all
[UNIVERSE setSkyColorRed:0.0f // back to black
green:0.0f
blue:0.0f
alpha:0.0f];
Code: Select all
NSDictionary *systeminfo = nil;
systeminfo = [self generateSystemData:system_seed];
skyClearColor[0] = [systeminfo oo_floatForKey:@"space_color_red" defaultValue:0.0];
skyClearColor[1] = [systeminfo oo_floatForKey:@"space_color_green" defaultValue:0.0];
skyClearColor[2] = [systeminfo oo_floatForKey:@"space_color_blue" defaultValue:0.0];
skyClearColor[3] = [systeminfo oo_floatForKey:@"space_color_alpha" defaultValue:0.0];
Code: Select all
[self setSkyColorRed:0.0f
green:0.0f
blue:0.0f
alpha:0.0f];
Code: Select all
skyClearColor[0] = [systeminfo oo_floatForKey:@"space_color_red" defaultValue:0.0];
skyClearColor[1] = [systeminfo oo_floatForKey:@"space_color_green" defaultValue:0.0];
skyClearColor[2] = [systeminfo oo_floatForKey:@"space_color_blue" defaultValue:0.0];
skyClearColor[3] = [systeminfo oo_floatForKey:@"space_color_alpha" defaultValue:0.0];
Code: Select all
skyClearColor[0] = 0.0;
skyClearColor[1] = 0.0;
skyClearColor[2] = 0.0;
skyClearColor[3] = 0.0;
Code: Select all
NSDictionary *systeminfo = nil;
systeminfo = [self generateSystemData:system_seed];
skyClearColor[0] = [systeminfo oo_floatForKey:@"space_color_red" defaultValue:0.0];
skyClearColor[1] = [systeminfo oo_floatForKey:@"space_color_green" defaultValue:0.0];
skyClearColor[2] = [systeminfo oo_floatForKey:@"space_color_blue" defaultValue:0.0];
skyClearColor[3] = [systeminfo oo_floatForKey:@"space_color_alpha" defaultValue:0.0];
Code: Select all
// Define space background color or set to black as default:
skyClearColor[0] = [systeminfo oo_floatForKey:@"space_color_red" defaultValue:0.0];
skyClearColor[1] = [systeminfo oo_floatForKey:@"space_color_green" defaultValue:0.0];
skyClearColor[2] = [systeminfo oo_floatForKey:@"space_color_blue" defaultValue:0.0];
skyClearColor[3] = [systeminfo oo_floatForKey:@"space_color_alpha" defaultValue:0.0];
Code: Select all
"0 7" =
{
space_color_blue = 0.2;
};
System.infoForSystem(galaxyNumber, player.ship.targetSystem).space_color_red = 0.2;
to make the next system you jump into red! The above code also ensures that even when launching from the station the colour is what you have defined it to be, and even if you go into the planet's atmosphere (which turns the background colour blue) and come back up again, it will revert to the colour defined in the planetinfo.plist file or by Javascript.