Page 84 of 118

Re: Scripters cove

Posted: Mon Oct 05, 2015 6:32 am
by Rorschachhamster
Is there an easy way to change the escort_ship from the shipdata.plist, or assign the role of a certain escort, in the this.shipSpawned function? :?:

Re: Scripters cove

Posted: Mon Oct 05, 2015 8:47 am
by Amah
Hmmh, do you want a certain shiptype like only sidewinders?

escort_roles = (
{ role = "[sidewinder-escort]"; min = -2; max = 4; },
);

Re: Scripters cove

Posted: Mon Oct 05, 2015 9:10 am
by spara
If you want to do something about the escorts after the ship has been spawned, you need to remove the possible spawned escorts and replace them with new ones.

Re: Scripters cove

Posted: Mon Oct 05, 2015 10:43 am
by Rorschachhamster
Amah wrote:
Hmmh, do you want a certain shiptype like only sidewinders?

escort_roles = (
{ role = "[sidewinder-escort]"; min = -2; max = 4; },
);
No, that's not it, I wanted to do that in script, not in the .plist, because of reasons... :D
spara wrote:
If you want to do something about the escorts after the ship has been spawned, you need to remove the possible spawned escorts and replace them with new ones.

Thanks, that gave me an idea: Maybe I should get rid of the escorts in the shipdata.plist and add them in the script that spawns the ship, instead of the script that fires when the ship is spawned... :mrgreen: Maybe... :roll:

Re: Scripters cove

Posted: Tue Oct 06, 2015 12:34 am
by phkb
I do a lot of this escort adding type stuff in Station Dock Control. The biggest issue I faced was how to add escorts to launching ships. I had to set timers to wait until the mothership had really launched before adding escorts to it.

Re: Scripters cove

Posted: Tue Oct 06, 2015 12:29 pm
by Rorschachhamster
phkb wrote:
I do a lot of this escort adding type stuff in Station Dock Control. The biggest issue I faced was how to add escorts to launching ships. I had to set timers to wait until the mothership had really launched before adding escorts to it.
Thanks, I took a look at your code, and I know now what to do... I think... :lol:

Re: Scripters cove

Posted: Fri Oct 09, 2015 8:05 pm
by Rorschachhamster
No, I don't.

So, the escortGroup of a ship is a ship group, isn't it? Shouldn#t I be able to add a ship to it via addShip?

Code: Select all

motherShip.escortGroup.addShip(otherShip);
:?:

Re: Scripters cove

Posted: Tue Oct 13, 2015 12:05 am
by phkb
No, escorts are handled differently. You need something like:

Code: Select all

var returnValue = escortShip.offerToEscort(motherShip);

Re: Scripters cove

Posted: Fri Oct 16, 2015 10:41 am
by phkb
If I have an equipment key, is there any way I can find out if it's available for purchase at the current docked station? Without going to the F3 screen and eyeballing it, I mean.

Re: Scripters cove

Posted: Fri Oct 16, 2015 2:35 pm
by Norby
phkb wrote:
If I have an equipment key, is there any way I can find out if it's available for purchase at the current docked station? Without going to the F3 screen and eyeballing it, I mean.
There is no general way, but if it is in your OXP then you can set a variable in a worldScript within a condition script when allowAwardEquipment return true. In the case of others you can only roughly mimic the decision by comparing the techlevel, checking if it is already installed, copy the functions from condition scripts of all OXPs and update at every change of the original, etc. :(

Re: Scripters cove

Posted: Sat Oct 24, 2015 9:38 pm
by Fritz
If there are two (or more) OXPs containing a "shipSpawned" function, let's say, one for naming the ship and one for adjusting other properties (weapons, equipment, textures), is there any way to control which of the functions is called first? Is the calling sequence determined by the installation order of the OXPs or by something else, or is it completely random?

I want to create an OXP defining "company freighters" having different textures and other properties. I also want these ships to have special names based on company-specific naming schemes. So far, so good, but what about the OXP "Random Ship Names"? Luckily its "shipSpawned" function actually checks if the ship already has a name, but that would only be useful if my "shipSpawned" function is called first. In the other case, my OXP would have to rename a ship that already has been given a name. This would work of course, but it wouldn't be very elegant from a programmers perspective (and the name would be 'wasted', i.e. deleted from the name lists of Random Ship Names).

Re: Scripters cove

Posted: Sat Oct 24, 2015 10:28 pm
by Norby
Fritz wrote:
is there any way to control which of the functions is called first?
Unfortunately is not, only the manually installed OXPs comes later than managed OXZs. The order between packages in the same folder is determined by the filesystem, in Windows this is the order of installation but random under Linux.

Re: Scripters cove

Posted: Sat Oct 24, 2015 10:55 pm
by Fritz
Thank you! I'll try to program it so that it should work in either case.

Probably it's impossible to make every OXP work (and test it) with very other OXP, but is there a simple and recommended method to check if a certain OXP is installed?

Re: Scripters cove

Posted: Sun Oct 25, 2015 12:07 am
by Norby
Fritz wrote:
a simple and recommended method to check if a certain OXP is installed?
Only those which contain a worldscript:

Code: Select all

if( worldScripts["name"] )
Where "name" is not the filename of the .js but the content of this.name within the script. Unfortunately many OXPs are made without any script, mainly ships.

Re: Scripters cove

Posted: Sun Oct 25, 2015 12:39 am
by Fritz
True... my own player-ship OXP doesn't have a script. Is it "officially" recommended to supply a dummy script containing nothing else than this.name or would this create unnecessary overhead?