Jump to content

Kerbol Renamer - does exactly what it says on the tin!


tntristan12

Recommended Posts

This is a very, very simple mod. It contains only a .dll, so just unzip it right into your GameData folder and load up the game. The Sun will now be called Kerbol, and long time forum users like me will have their beloved fan-nickname made official. If you don't like the name "Kerbol" and want to call it something else, the source code is below!

Download here!


using System;
using System.Linq;
using UnityEngine;

[KSPAddon(KSPAddon.Startup.EveryScene, false)]
public class KerbolRenamer : MonoBehaviour {
void Start() {
var bodies = GameObject.FindObjectsOfType(typeof(CelestialBody)).Cast<CelestialBody>();
var kerbol = bodies.Single(cb => cb.name == "Sun");
kerbol.gameObject.name = "Kerbol";
kerbol.bodyName = "Kerbol";
kerbol.use_The_InName = false;
}
}

This is a "do whatever you want" license. This code took less than an hour to write, and doesn't contain anything groundbreaking. If you want to use it in your own plugin knock yourself out. If you want to give me credit for the plugin, make sure you credit scgtrp as well because he helped me write it. If you want to tell everyone you wrote it, I mean... That's not cool, but I'm not gonna stop you.

Keep in mind, this is my first mod so it was more of an experiment than anything. I've got bigger better things coming down the pipeline (hopefully). I hope you enjoy it!

Link to comment
Share on other sites

This is a very, very simple mod. It contains only a .dll, so just unzip it right into your GameData folder and load up the game. The Sun will now be called Kerbol, and long time forum users like me will have their beloved fan-nickname made official. If you don't like the name "Kerbol" and want to call it something else, the source code is below!

Download here!


using System;
using System.Linq;
using UnityEngine;

[KSPAddon(KSPAddon.Startup.EveryScene, false)]
public class KerbolRenamer : MonoBehaviour {
void Start() {
var bodies = GameObject.FindObjectsOfType(typeof(CelestialBody)).Cast<CelestialBody>();
var kerbol = bodies.Single(cb => cb.name == "Sun");
kerbol.gameObject.name = "Kerbol";
kerbol.bodyName = "Kerbol";
kerbol.use_The_InName = false;
}
}

This is a "do whatever you want" license. This code took less than an hour to write, and doesn't contain anything groundbreaking. If you want to use it in your own plugin knock yourself out. If you want to give me credit for the plugin, make sure you credit scgtrp as well because he helped me write it. If you want to tell everyone you wrote it, I mean... That's not cool, but I'm not gonna stop you.

Keep in mind, this is my first mod so it was more of an experiment than anything. I've got bigger better things coming down the pipeline (hopefully). I hope you enjoy it!

If this could be used to rename planets too...This is just the thing RSS guys would welcome for more immersion :D

Link to comment
Share on other sites

So this is the mod you were secretive about? Interesting.

Not at all. I gave up on that mod after it became clear that it was way above my current skill level. :P

Can this rename other planets? I want to call bop Kraken
If this could be used to rename planets too...This is just the thing RSS guys would welcome for more immersion :D

Sure can. Just replace "Sun" with "Bop" and then "Kerbol" with "Kraken." All this mod does is look through all CBodies at start up, finds the one with the name you want to change, then updates it. Like this:


using System;
using System.Linq;
using UnityEngine;

[KSPAddon(KSPAddon.Startup.EveryScene, false)]
public class KerbolRenamer : MonoBehaviour {
void Start() {
var bodies = GameObject.FindObjectsOfType(typeof(CelestialBody)).Cast<CelestialBody>();

var kerbol = bodies.Single(cb => cb.name == "Sun");
kerbol.gameObject.name = "Kerbol";
kerbol.bodyName = "Kerbol";
kerbol.use_The_InName = false;

var wantToChange = bodies.Single(cb => cb.name == "Kerbin/Mun/Bop/Gilly/Eve/etc...");
wantToChange.gameObject.name = "Name You Want";
wantToChange.bodyName = "Name You Want";
wantToChange.use_The_InName = false; //generally false, but you can make it true if you want it to say "the Name You Want" instead of just "Name You Want"
}
}

Edited by tntristan12
Link to comment
Share on other sites

I've run it on my fully modded save without issue so far. That said, I don't have every plugin installed and even then I can only say I haven't run into any issues *yet*. Let me know if it bugs out for you though! :)

Link to comment
Share on other sites

No I haven't touched sciencedefs. My understanding of how the stock game code works is very limited, since I need to use a decompiler to understand some of the processes going on and Squad has a pretty nifty little obfuscator making things very hard to read. I don't know if my patch is going to severely break science or not, but feel free to test it out and let me know what it does!

You could always do a quick "replace all" in sciencedefs.cfg to turn every instance of Sun into Kerbol... But I don't know if that's going to fix anything that's broken. More testing is needed on my end.

Edited by tntristan12
Link to comment
Share on other sites

Well, that looks like it'd be a fine addition to RSS. Would give planets their proper names, though obviously the names would have to be exposed to configs.

Link to comment
Share on other sites

This would go great with RSS. The sciencedefs I don't think should be too hard to change...

RSS has this functionality. It's disabled by default because as Blizzy pointed out, renaming planets can interfere with other mods. It shouldn't be that way IMO because there should be some means of searching out planets other than their player visible names. In fact I think maybe there is and we've just overlooked it.... would like to explore that fuether but my PC is really acting up lately :(

Link to comment
Share on other sites

RSS does actually support doing this; that's all the (commented out) bodyName = whatever lines in the cfg. They're commented out because, yeah, science, but also because for example EVE relies on bodies retaining their names and CB name matching scaledspace transform name.

There's also the question of PQS name.

On the whole I've held off digging too deeply because so much is actually tied to the CB's name (other mods, sure, but also I fear some internal stuff).

However, very little depends on the Sun itself (and by the time this mod fires, anything referencing it will have a pointer, not a string, referring to it anyway), so this usage should be ok, other than science obviously.

Link to comment
Share on other sites

RSS does actually support doing this; that's all the (commented out) bodyName = whatever lines in the cfg. They're commented out because, yeah, science, but also because for example EVE relies on bodies retaining their names and CB name matching scaledspace transform name.

There's also the question of PQS name.

On the whole I've held off digging too deeply because so much is actually tied to the CB's name (other mods, sure, but also I fear some internal stuff).

However, very little depends on the Sun itself (and by the time this mod fires, anything referencing it will have a pointer, not a string, referring to it anyway), so this usage should be ok, other than science obviously.

Perhaps. Is there really any science to be had around the sun though? I guess there's the typical EVA/Crew report. I wonder if there's a way to fix the science aspect. NathanKell, you'd be able to say better than I since you've got so much more modding experience.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...