Jump to content

module > part not counting in rocket part limit for upgraded buildings


Recommended Posts

ok so heavy modded game, alot of parts we add just for decor to make our rockets look nice, but then get kicked in the head because the part count is higher than VAB/launchpad allow until you upgrade further, but cant upgrade yet o.O so a simple module, if on a part, that part isnt counted in the limit

MODULE

{

name = ModuleExcludePartLimit

}

or such :)

i tried looking through some of ksp code, but can't find where to hook into the part counting, so maybe theres better modders :)

Link to comment
Share on other sites

The simplest way would be to dynamically increase the part limit instead. Just glancing at it, I'd say actually preventing the part from being included in the count would exceed the effort : reward ratio for your mod

[KSPAddon(KSPAddon.Startup.MainMenu, true)]
public class ExtendPartLimitCount : GameVariables
{
private void Awake() // important that this be in Awake
{
// just a little future-proofing
if (Instance.GetType() != typeof (GameVariables))
{
Debug.LogError(string.Format("{0} cannot run; conflicting GameVariables instance of type {1}",
GetType().Name, Instance.GetType().FullName));
Destroy(this);
return;
}

Instance = this;
DontDestroyOnLoad(this);
}

public override int GetPartCountLimit(float editorNormLevel)
{
var baseLimit = base.GetPartCountLimit(editorNormLevel);

if (!HighLogic.LoadedSceneIsEditor) return baseLimit;

return baseLimit + EditorLogic.fetch.ship.parts
.Count(p => p.GetComponent<ExtendPartCountLimitModule>() != null);
}
}

public class ExtendPartCountLimitModule : PartModule
{
}

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...