Scripters cove

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

User avatar
Rorschachhamster
---- E L I T E ----
---- E L I T E ----
Posts: 274
Joined: Sun Aug 05, 2012 11:46 pm
Contact:

Re: Scripters cove

Post 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? :?:
User avatar
Amah
---- E L I T E ----
---- E L I T E ----
Posts: 486
Joined: Tue Aug 28, 2012 8:05 pm
Location: aboard the Laenina Crowne - Yasen-N class space freighter
Contact:

Re: Scripters cove

Post by Amah »

Hmmh, do you want a certain shiptype like only sidewinders?

escort_roles = (
{ role = "[sidewinder-escort]"; min = -2; max = 4; },
);
Amah
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2691
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Scripters cove

Post 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.
User avatar
Rorschachhamster
---- E L I T E ----
---- E L I T E ----
Posts: 274
Joined: Sun Aug 05, 2012 11:46 pm
Contact:

Re: Scripters cove

Post 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:
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Scripters cove

Post 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.
User avatar
Rorschachhamster
---- E L I T E ----
---- E L I T E ----
Posts: 274
Joined: Sun Aug 05, 2012 11:46 pm
Contact:

Re: Scripters cove

Post 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:
User avatar
Rorschachhamster
---- E L I T E ----
---- E L I T E ----
Posts: 274
Joined: Sun Aug 05, 2012 11:46 pm
Contact:

Re: Scripters cove

Post 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);
:?:
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Scripters cove

Post by phkb »

No, escorts are handled differently. You need something like:

Code: Select all

var returnValue = escortShip.offerToEscort(motherShip);
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Scripters cove

Post 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.
User avatar
Norby
---- E L I T E ----
---- E L I T E ----
Posts: 2577
Joined: Mon May 20, 2013 9:53 pm
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Contact:

Re: Scripters cove

Post 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. :(
Fritz
---- E L I T E ----
---- E L I T E ----
Posts: 591
Joined: Sun Jul 12, 2015 2:30 pm
Location: Bavaria, Germany
Contact:

Re: Scripters cove

Post 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).
"You wouldn't kill me just for a few credits, would you?" – "No, I'll do it just for the fun!"
User avatar
Norby
---- E L I T E ----
---- E L I T E ----
Posts: 2577
Joined: Mon May 20, 2013 9:53 pm
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Contact:

Re: Scripters cove

Post 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.
Fritz
---- E L I T E ----
---- E L I T E ----
Posts: 591
Joined: Sun Jul 12, 2015 2:30 pm
Location: Bavaria, Germany
Contact:

Re: Scripters cove

Post 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?
"You wouldn't kill me just for a few credits, would you?" – "No, I'll do it just for the fun!"
User avatar
Norby
---- E L I T E ----
---- E L I T E ----
Posts: 2577
Joined: Mon May 20, 2013 9:53 pm
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Contact:

Re: Scripters cove

Post 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.
Fritz
---- E L I T E ----
---- E L I T E ----
Posts: 591
Joined: Sun Jul 12, 2015 2:30 pm
Location: Bavaria, Germany
Contact:

Re: Scripters cove

Post 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?
"You wouldn't kill me just for a few credits, would you?" – "No, I'll do it just for the fun!"
Post Reply