PNetwork's forceRequiredAddonTutorial"Why tons of datablocks when you can just use other add-ons?"
Contents:
1-
Criteria to force2-
Why force addons?3-
Function Usage
1: Criteria to forceSo you want to use the forceRequiredAddOn function, eh? Well, make sure the add-on you wanna use the function with matches this criteria:
1: Has atleast one .cs file
Lol, that was easy, right?
Why force addons?Why use the forceRequiredAddon function, you say?
You get two advantages.
1: You can be lazy and not have to do all the work.
2: People who DL your add-on get benefit so they have to load less datablocks.
Function UsageStep 1:First you'll have to memorize all the .cs files inside the add-on you are trying to use the function with. But whatever, you can write them down on a piece of paper.
Step 2: Go back to the script from YOUR addon.
Step 3: First type this. We're using SciFiBuild particle as an example.
And we will use %fa as our variable that will help us in various parts.
%fa = ForceRequiredAddOn("particle_sciFiBuild"); //Force that.
This is our starting line which basically says,
Oh hey theres a
faTMAN who wants science fiction particles to be required!
But this is basically a piece of crap so far. It does nothing to make sure this is enabled , really.
We have to add more code, like this.
(Sci fi build has more than one emitter but just say it only have RedSheildL Particle. If you were to have an addon like this though, you would copy+paste the statement [Thing.uiName = "";]
and edit "Thing" to the datablock name which is found inside the code of the other addon.
%error = ForceRequiredAddOn("particle_sciFiBuild");
if(%fa == $Error::AddOn_Disabled)
{
RedSheildLParticle.uiName = "";
}
Ok. Here's the final element that does the real business.
if(%fa == $Error::AddOn_NotFound)
{
error("ERROR: [ Your addon name here] - required add-on particle_sciFiBuild "); // Oops i don't have that addon
}
else // Otherwise, if i do have the addon
{
exec("./Particle_SciFiBuild.cs");
}
Let's look closely at the exec() line.
There's something to understand.
If you open the server.cs of the addon you want to force, and
A: You see only exec() lines. No other code.
B: You see exec and other code.
C: You see only other code, no exec() at all.
For A users:
Don't modify the exec() line above in the code statement at all.
(Particle_SciFiBuild.cs is obvious to change though)
For B users:
Modify the exec() line above in the code statement to say
exec("./server.cs");
This way the server.cs is run and the exec function in the server.cs file executes sub-scripts like Particle_SciFiBuild and then also executes server.cs's own code.
For C users:
Same thing as above. Change it to ./server.cs
You're done! You can also use this to run remote scripts.