Page 41 of 117

Re: Scripters cove

Posted: Sat Mar 17, 2012 4:44 am
by Capt. Murphy
Thanks Svengali.

Re: Scripters cove

Posted: Wed Mar 21, 2012 8:51 pm
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?

Re: Scripters cove

Posted: Wed Mar 21, 2012 9:23 pm
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.

Re: Scripters cove

Posted: Wed Mar 21, 2012 9:32 pm
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

Re: Scripters cove

Posted: Wed Mar 21, 2012 9:37 pm
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.

Re: Scripters cove

Posted: Wed Mar 21, 2012 9:45 pm
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...

Re: Scripters cove

Posted: Wed Mar 21, 2012 9:51 pm
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)?

Re: Scripters cove

Posted: Wed Mar 21, 2012 9:55 pm
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.

Re: Scripters cove

Posted: Wed Mar 21, 2012 10:10 pm
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?

Re: Scripters cove

Posted: Wed Mar 21, 2012 11:19 pm
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.

Re: Scripters cove

Posted: Thu Mar 22, 2012 5:39 am
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.

Re: Scripters cove

Posted: Thu Mar 22, 2012 7:53 am
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");

Re: Scripters cove

Posted: Thu Mar 22, 2012 8:05 am
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.

Re: Scripters cove

Posted: Thu Mar 22, 2012 8:58 am
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;
}

Re: Scripters cove

Posted: Thu Mar 22, 2012 1:16 pm
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.