Bridge Commander Central

BC Forums => BC Scripting => Topic started by: Mustang on March 20, 2007, 10:55:42 AM

Title: Scripting Mutators
Post by: Mustang on March 20, 2007, 10:55:42 AM
Okay, I need help with Mutators. I can make a mutator appear on the menu, but how do I get it to work (I know I click on it)? How do I make it so that my ship pack will not work without it turned on? Been wondering.

Thanks for any help.
Title: Re: Scripting Mutators
Post by: MLeo on March 20, 2007, 11:59:57 AM
Well, the mutatordef is a rather abstract thing. It has nothing to do with it's GUI counterpart.

For what reason would you like to know if you have clicked on it?


As for your second question, it's easy.
Similar as with OverrideDefs, you can add a dict={} to ship plugins (in fact, you already do that).
Now, you can add a "modes": [ <Your mutator list> ] to that.

So if your mutator is in variable "mode", then you put mode there.

Now, of course you would prefer to have the mutator defined elsewere (in fact, you must, unless you want a lot of duplicate mutators :P).
So, you have your file in autoload (say, MustangShipMutator.py)
Then you put in each ship file the following:
import Custom.Autoload.MustangShipMutator

But writing Custom.Autoload.MustangShipMutator.mode each time is a bit of a hassle.
So you put in this line instead of the import:
from Custom.Autoload.MustangShipMutator import mode

Now you can do {..... , "modes": [mode], ....}
This assumes that your autoload file is called MustangShipMutator.py, and the mutator within is called "mode" (as variable, not the real mutator name).
Title: Re: Scripting Mutators
Post by: Mustang on March 20, 2007, 01:42:11 PM
Ummm... could you possibly speak a little more.... n00bish? I'm still pretty new to scripting. I just got to the point this past weekend where I can script ship plugins from scratch.

If you could possibly write it step-by-step in your post? If not that's fine, I'm sure I'll figure it out somehow, sometime.

Thanks though.
Title: Re: Scripting Mutators
Post by: MLeo on March 20, 2007, 02:10:59 PM
Ok, you have your mutator in an autoload file, right?
Let's call it MustangMutator.py (just as example).
So it's path is scripts/Custom/Autoload/MustangMutator.py

The mutator contained inside is defined as:
mode = Foundation.MutatorDef("Mustangs Mutator")

Now, in your ship plugin you have your shipdef line:

Foundation.ShipDef.MustangsShip = Foundation.FedShipDef(abrev, name, dict ={'iconName': *snip*})

The FedShipDef is just another example.

Now, append at the end (before the }):
, "modes": [mode]

So you get:
Foundation.ShipDef.MustangsShip = Foundation.FedShipDef(abrev, name, dict ={'iconName': *snip*, "modes": [Custom.Autoload.MustangMutator.mode]})

BUT!
How does your ship plugin file know about "Custom.Autoload.MustangMutator.mode"?
You need to import it.

Since mode is the variable you defined earlier, we just need to import the file.

At the top of the file add (you can put it anywhere before it's first usuage, but it's easier to group them, so put it under Foundation):
import Custom.Autoload.MustangMutator


You may notice that it's rather long to write:
Custom.Autoload.MustangMutator.mode

So we can import just the "mode" variable defined in Custom.Autoload.MustangMutator with this:

from Custom.Autoload.MustangMutator import mode

Now you can write this for your shipdef line:
Foundation.ShipDef.MustangsShip = Foundation.FedShipDef(abrev, name, dict ={'iconName': *snip*, "modes": [mode]})


I hope that helps.
Title: Re: Scripting Mutators
Post by: Mustang on March 20, 2007, 02:26:00 PM
It won't work. GOD I hate the BSOD.  :evil:
Title: Re: Scripting Mutators
Post by: El on March 20, 2007, 02:34:22 PM
Not being funny, but you didn't actually type *snip* in the shipdef did you?
Title: Re: Scripting Mutators
Post by: Mustang on March 20, 2007, 03:16:39 PM
No, and besides, what is *snip* supposed to be?
Title: Re: Scripting Mutators
Post by: MLeo on March 20, 2007, 03:28:28 PM
*snip* is what is usually refered to something that has been omitted.

Now, please get me a console report.
Using the console is the least any scripter should know. ;)
Or, maybe you should just post the 2 scripts (the Autoload file and the Ship plugin).
Title: Re: Scripting Mutators
Post by: Mustang on March 20, 2007, 03:46:26 PM
There ya go. I'll get right on it, expect it in a while.
Title: Re: Scripting Mutators
Post by: MLeo on March 20, 2007, 04:28:39 PM
Be sure to put that in a new post, since I don't get notifications for updated posts.
Title: Re: Scripting Mutators
Post by: Dasher42 on April 25, 2007, 02:43:36 PM
I've got a friendly question.  Why do you need to use a mutator for a ship pack?  You either use the ships or you don't.  "Extra Ships and Mods" is the default mutator for things like this.  I realize I set a bad example by putting the Sol system under a mutator, but they have been sorely overused and abused for things that just add to existing menus, rather than alter existing components or add gameplay-changing features which was the intended purpose.

Pardon my designer's grousing.  This is just to say that I think you're getting into needless complexity for what you're doing. :)
Title: Re: Scripting Mutators
Post by: MLeo on April 25, 2007, 05:50:01 PM
It's what I call: "I don't know what I'm doing, so I'm copying..." based working.

I see it at school a lot, and I even started that way with scripting. Lol, my first uniform mutator pack was heavily based on Occas' Romulan crew, so heavily, that the character files had pRomBrex and such in them.
Title: Re: Scripting Mutators
Post by: ACES_HIGH on May 01, 2007, 11:25:20 PM
seems to me that all character mods have that prefix in the code, thats a prime example
Title: Re: Scripting Mutators
Post by: MLeo on May 02, 2007, 04:59:05 AM
seems to me that all character mods have that prefix in the code, thats a prime example
That would then be my fault. :P
Title: Re: Scripting Mutators
Post by: Mustang on July 30, 2007, 10:53:44 AM
I've got a friendly question.  Why do you need to use a mutator for a ship pack?  You either use the ships or you don't.  "Extra Ships and Mods" is the default mutator for things like this.  I realize I set a bad example by putting the Sol system under a mutator, but they have been sorely overused and abused for things that just add to existing menus, rather than alter existing components or add gameplay-changing features which was the intended purpose.

Pardon my designer's grousing.  This is just to say that I think you're getting into needless complexity for what you're doing. :)

I don't need to, I just want to learn. If I have building blocks on something simple, like putting a mutator in a ship pack, then I'll be able to put a mutator into just about anything. Mutators work the same way all the way around... right?