Jump to content

Unique parts, is it even possible?


Recommended Posts

Hello. Been spending the last few days developing a mod that use Naquadah technology ( Stargate ) to increase the efficiency of liquid fuel engines. In order to keep the addon from being OP though I need to limit the number of Naquadah generators you can have on each vessel to one, or at least make sure no more than one generator will function at the same time.

My Naquadah generators are mostly the stock Fuel Cells modified to convert my own custom resource Naquadah into refined Naquadah used in conjunction with Liquid Fuel and Oxidizer within the engine to provide thrust. Thing is, the generators produce as much refined Naquadah as the engine consume, but I want to limit the number of engines able to operate to 1 ( by limiting the amount of refined naquadah that can be produced )

Is something like this even possible? Could anyone point me in the right direction for how to approach this if so? Would be much appreciated.

Link to comment
Share on other sites

Singleton pattern will not work, that method would result in one generator working across all loaded vessels within physics range.

Rather, in your "Generator Start" method, add code to turn off all other generators on the vessel so that only the generator last told to start by the player runs.


//inside your Generator Start code
foreach(Part p in this.vessel.Parts) //cycle through all parts on the vessel
{
if(p != this.part) //only stop the generator if it is not the generator currently being started
{
foreach(NaquadahPartModule nPM in p.Modules.OfType<NaquadahPartModule>()) //find the Naquadah generator part module
{
//insert code to stop the generator here
}
}
}

Hope that helps,

D.

Link to comment
Share on other sites

  • 2 weeks later...
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...