Join us at the Oolite Anniversary Party -- London, 7th July 2024, 1pm
More details in this thread.

Scripters cove

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

Moderators: winston, another_commander

User avatar
Capt. Murphy
Commodore
Commodore
Posts: 1127
Joined: Fri Feb 25, 2011 8:46 am
Location: UK South Coast.

Re: Scripters cove

Post by Capt. Murphy »

Thanks Svengali.
[EliteWiki] Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Re: Scripters cove

Post by Thargoid »

Can flashers be turned on and off by script (the equivalent of the AI commands switchLightsOn and switchLightsOff)? I had a memory that it got introduced at one point, but I can't find it anywhere. Or have we still got to bounce off an AI to do it?
User avatar
Okti
---- E L I T E ----
---- E L I T E ----
Posts: 700
Joined: Sun Sep 26, 2010 1:51 pm
Location: A GH shop, near witchpoint to Oresrati in Galaxy 8

Re: Scripters cove

Post by Okti »

Thargoid wrote:
Can flashers be turned on and off by script (the equivalent of the AI commands switchLightsOn and switchLightsOff)? I had a memory that it got introduced at one point, but I can't find it anywhere. Or have we still got to bounce off an AI to do it?
I don't think so, we had to use an AI State triggered by JS at XephatlsSword to achieve that effect.
My OXP's
And Latest Mission Coyote's Run
User avatar
Capt. Murphy
Commodore
Commodore
Posts: 1127
Joined: Fri Feb 25, 2011 8:46 am
Location: UK South Coast.

Re: Scripters cove

Post by Capt. Murphy »

http://wiki.alioth.net/index.php/Oolite ... ghtsActive

is read/write - you don't need to go via the AI.

this.ship.lightsActive = true or this.ship.lightsActive = false
[EliteWiki] Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
User avatar
Okti
---- E L I T E ----
---- E L I T E ----
Posts: 700
Joined: Sun Sep 26, 2010 1:51 pm
Location: A GH shop, near witchpoint to Oresrati in Galaxy 8

Re: Scripters cove

Post by Okti »

Capt. Murphy wrote:
http://wiki.alioth.net/index.php/Oolite ... ghtsActive

is read/write - you don't need to go via the AI.

this.ship.lightsActive = true or this.ship.lightsActive = false
An update to XS is required :D

Thanks for this information.
My OXP's
And Latest Mission Coyote's Run
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Re: Scripters cove

Post by Thargoid »

Capt. Murphy wrote:
http://wiki.alioth.net/index.php/Oolite ... ghtsActive

is read/write - you don't need to go via the AI.

this.ship.lightsActive = true or this.ship.lightsActive = false
Thanks too - I thought I could recall such a command but couldn't find it for looking...
User avatar
Gimbal Locke
---- E L I T E ----
---- E L I T E ----
Posts: 293
Joined: Sun Jan 08, 2012 11:32 pm
Location: Brussels
Contact:

Re: Scripters cove

Post by Gimbal Locke »

Is it possible to have an item for sale at a specific planet?

I looked at http://wiki.alioth.net/index.php/Equipment.plist, where I found:

Code: Select all

 conditions = (
       "systemGovernment_number morethan 3"
Is there a list somewhere on which variables (such as systemGovernment_number) I can test against (I suppose there is a variable such as systemName or systemID)?
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Scripters cove

Post by Commander McLane »

Gimbal Locke wrote:
Is it possible to have an item for sale at a specific planet?

I looked at http://wiki.alioth.net/index.php/Equipment.plist, where I found:

Code: Select all

 conditions = (
       "systemGovernment_number morethan 3"
Is there a list somewhere on which variables (such as systemGovernment_number) I can test against (I suppose there is a variable such as systemName or systemID)?
Yes, and yes. You can test against all variables that were part of the legacy scripting system. They're listed on the [wiki]Methods[/wiki]-page (Querying states). The one you're looking for is planet_number, probably together with galaxy_number.
User avatar
Gimbal Locke
---- E L I T E ----
---- E L I T E ----
Posts: 293
Joined: Sun Jan 08, 2012 11:32 pm
Location: Brussels
Contact:

Re: Scripters cove

Post by Gimbal Locke »

Thanks, Commander McLane!
Commander McLane wrote:
You can test against all variables that were part of the legacy scripting system.
Is there also a non-legacy way to achieve the same?
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Scripters cove

Post by Commander McLane »

Gimbal Locke wrote:
Thanks, Commander McLane!
Commander McLane wrote:
You can test against all variables that were part of the legacy scripting system.
Is there also a non-legacy way to achieve the same?
Nope, not within a plist. And the markets are not exposed to JS.

And now imagine that in Oolite 1.65 the things on the Methods-page were everything we had for scripting! What couldn't be done with these pitifully few commands and variables, simply couldn't be done.
User avatar
Capt. Murphy
Commodore
Commodore
Posts: 1127
Joined: Fri Feb 25, 2011 8:46 am
Location: UK South Coast.

Re: Scripters cove

Post by Capt. Murphy »

Gimbal Locke wrote:
Thanks, Commander McLane!
Commander McLane wrote:
You can test against all variables that were part of the legacy scripting system.
Is there also a non-legacy way to achieve the same?
I think you can do the same in JS...with a bit of trickery.

You need the equipment item to "requires_equipment" = "EQ_GIMBAL_DUMMY"; or similar.

"EQ_GIMBAL_DUMMY" has a required tech lvl of 99 and is "visible" = no; in it's equipment info.

In a worldScript you store the galaxyNumbers and system.ID's in an array, and on docking interrogate the array to see if the current station should have the equipment item and if so award the player "EQ_GIMBAL_DUMMY". On launching you remove from the player "EQ_GIMBAL_DUMMY".

This does have some advantages, not least that you could change the array in response to game events and store it as a missionVariable in JSON format. E.g. a new invention might initially only be available at one tech level 15 planet, but could spread to other systems.
[EliteWiki] Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Scripters cove

Post by cim »

Capt. Murphy wrote:
I think you can do the same in JS...with a bit of trickery.
You can also do the same with a mission variable, which is probably a little simpler:

Code: Select all

    "conditions" = ("mission_thisequipmentisavailable equal 1");
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2411
Joined: Mon May 31, 2010 11:11 pm

Re: Scripters cove

Post by Switeck »

Thargoid wrote:
Capt. Murphy wrote:
http://wiki.alioth.net/index.php/Oolite ... ghtsActive

is read/write - you don't need to go via the AI.

this.ship.lightsActive = true or this.ship.lightsActive = false
Thanks too - I thought I could recall such a command but couldn't find it for looking...
It's also possible to turn lights on/off via AI.plist scripts...which could also be triggered by .js scripts.

With "clever use" of scripting, a piece of equipment could start off unavailable (TL99) and slowly become available down to some high-ish tech level, (like TL12) representing a fast spread of the technology.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: Scripters cove

Post by Eric Walch »

Capt. Murphy wrote:
I think you can do the same in JS...with a bit of trickery.

You need the equipment item to "requires_equipment" = "EQ_GIMBAL_DUMMY"; or similar.

"EQ_GIMBAL_DUMMY" has a required tech lvl of 99 and is "visible" = no; in it's equipment info.
Sounds a bit complex to me. The easier variant would be to give the equipment itself a lvl of 99 and only set it to the current lvl on docking at a station where needed. Than set it back to 99 on launching.

And when you only want it for a specific station, you can put it all in the ship-script of the station itself during the dock/undock handlers of the station:

Code: Select all

this.otherShipDocked = function (ship)
{
	if (ship.isPlayer) missionVariables.EQ_MY_EQUIPMENT = 3;
}

this.stationLaunchedShip = function (ship)
{
	if (ship.isPlayer) delete missionVariables.EQ_MY_EQUIPMENT;
}
User avatar
Gimbal Locke
---- E L I T E ----
---- E L I T E ----
Posts: 293
Joined: Sun Jan 08, 2012 11:32 pm
Location: Brussels
Contact:

Re: Scripters cove

Post by Gimbal Locke »

Thanks folks, this is most helpful. I'll play around a bit with the different approaches proposed by Commander McLane, Capt. Murphy, cim & Eric.

The confusing thing for new OXP scripters (well, for me anyway) is to know what to do in plist and what to do in Javascript (both formats are new to me), but the above discussion has been clarifying a lot.
Post Reply