Scripters cove

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

Moderators: winston, another_commander

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 »

Pleb wrote:
Quick question, I'm trying to use the new allowOfferShip function to make a ship only available if a mission variable is set to a specific value and the player is in an anarchy system. Is this even possible? :?
Yes.

Set the condition_script in shipyard.plist to be the name of a script file. Then, in that script file:

Code: Select all

this.allowOfferShip = function(shipKey) {
  return (missionVariables.myShipIsAvailable == "yes" && system.info.government == 0);
}
If the script file is managing multiple ships with different conditions, you'd actually have to check the value of shipKey, of course.

That should prevent the ship from appearing in other circumstances, though of course there's no guarantee it'll show up at all, depending on chance and tech level settings in shipyard.plist.
User avatar
Pleb
---- E L I T E ----
---- E L I T E ----
Posts: 908
Joined: Sun Apr 29, 2012 2:23 pm
Location: United Kingdom

Re: Scripters cove

Post by Pleb »

Thanks cim, that worked a treat! couldn't find any other use of the new condition scripts anywhere else or in any of the newest OXP releases so figured I might be the first to try it out. :mrgreen:
Desktop PC: CPU: Intel i7-4790K Quad Core 4.4GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1080Ti RAM: 32GB DDR3

Laptop PC: CPU: Intel i5-10300H Quad Core 4.5GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1650 RAM: 32GB DDR4
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2409
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: Scripters cove

Post by Wildeblood »

What's the correct syntax for defining a timer, when I need to pass parameters to the function the timer is calling? I need this timer:

this.$tradingTimer = new Timer(this, this.$performTrading, 15, 9);

to call this.$performTrading(param, param)
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 »

Wildeblood wrote:
What's the correct syntax for defining a timer, when I need to pass parameters to the function the timer is calling? I need this timer:

this.$tradingTimer = new Timer(this, this.$performTrading, 15, 9);

to call this.$performTrading(param, param)
This should work. I used similar syntax in Troomp.
this.$tradingTimer = new Timer(this, function(){this.$performTrading(param, param)}, 15, 9)
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Scripters cove

Post by Thargoid »

I don't think you can directly - the parameters have to be routed via variables or a similar method. Or at least that was what was recommended to me a while back when I had the same question.

Spara's method may be an alternative.
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 »

Pleb wrote:
Thanks cim, that worked a treat! couldn't find any other use of the new condition scripts anywhere else or in any of the newest OXP releases so figured I might be the first to try it out. :mrgreen:
There are some equipment condition scripts in the core game (replacing the TL99 hack for the Naval Energy Unit and the other restricted item). I'm not aware of any released for shipdata or shipyard.
Wildeblood wrote:
What's the correct syntax for defining a timer, when I need to pass parameters to the function the timer is calling?
Untested, but try

Code: Select all

new Timer(this, this.$performTrading.bind(this, param, param), 15, 9);
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 »

I don't get it. I want equipment to be available only if you have ASC and Passenger Berth. What's wrong with this?

Code: Select all

"requires_equipment" = 
	(
		"EQ_ADVANCED_COMPASS",
		"EQ_PASSENGER_BERTH"
	);
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Scripters cove

Post by Smivs »

That looks OK to me. What is going wrong/not working?
Commander Smivs, the friendliest Gourd this side of Riedquat.
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 »

Smivs wrote:
That looks OK to me. What is going wrong/not working?
I'm being vague again, sorry. Equipment is not offered, althought I meet the requirements. For some reason I can only get single item requires_equipment clauses to work. Like this:

Code: Select all

"requires_equipment" = "EQ_ADVANCED_COMPASS";
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Scripters cove

Post by Smivs »

According to the wiki it should accept an array of strings. :? Have you tried "requires_any_equipment"?
Commander Smivs, the friendliest Gourd this side of Riedquat.
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 »

Smivs wrote:
According to the wiki it should accept an array of strings. :? Have you tried "requires_any_equipment"?
Yes. That one seems allow the equipment, if anything of "requires_any_equipment" is present. It seems that either I'm doing something terribly wrong or there is a bug in here.
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Scripters cove

Post by Smivs »

Ah, so "requires_any_equipment" worked, yes?
Commander Smivs, the friendliest Gourd this side of Riedquat.
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 »

Smivs wrote:
Ah, so "requires_any_equipment" worked, yes?
It works alright, but it's not what I want. I want to allow the equipment only if both requirements are met. Requires_any_equipment allow's the equipment if either requirement is met.

EDIT: Actually, with this:

Code: Select all

"requires_any_equipment" = 
	(
		"EQ_ADVANCED_COMPASS",
		"EQ_PASSENGER_BERTH"
	);
* If I have ASC and no Passenger Berth, equipment IS offered
* If I have Passenger Berth and no ASC, equipment IS not offered

There must be something wrong. Or I'm losing it :? .
Last edited by spara on Sat Jan 26, 2013 8:55 pm, edited 1 time in total.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Scripters cove

Post by Thargoid »

Can you post the entire equipment.plist file, or at least the full section relating to that equipment item? What you've posted is OK, so it'd be worth double-checking that there's not something adrift elsewhere in the set-up.

For reference, below is the code for the planetary landing capability (from Planetfall) which similarly requires two bits of kit before it becomes available and seems to be working.

Code: Select all

(
	(
	8, 
	50000, 
	"Planetary Landing Capability", 
	"EQ_PLANETFALL", 
	"Modifications to the ships control thrusters, auto-pilot systems, heat shielding and landing gear to enable landing on planetary bodies and moons. Requires docking computers and heat shielding to already be installed.", 
		{
		"available_to_all" = yes;
		"requires_equipment" = 
			(
			"EQ_DOCK_COMP",
			"EQ_HEAT_SHIELD"
			); 
		script_info = { thargoidRepairBotChance = 0; };
		}
	)
)
[/color]
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 »

Here we go. I'm going crazy with this. All help is appreciated.

Code: Select all

(
	(
		0, 600, "In-System Taxi Licence",
		"EQ_IN_SYSTEM_TAXI_LICENCE",
		"Join Taxi Galactica's in-system taxi drivers division. Deliver customers from one station to another in-system. Buy this and you'll receive local delivery offers right to you Comms while cruising. When you get an offer, you have one minute to decide to take it or not. If you want to take it, just prime this small gadget and activate it.",
		{
			"available_to_all" = yes;
			"requires_equipment" = 
			(
				"EQ_ADVANCED_COMPASS",
				"EQ_PASSENGER_BERTH"
			);
			"portable_between_ships" = yes;
			"script" = "taxi_equipment.js";
			"damage_probability" = 0.0;
			"condition_script" = "taxi_equipment.js";
		}
	),
	(
		1, 100, "Remove In-System Taxi Licence",
		"EQ_WEAPON_IN_SYSTEM_TAXI_LICENCE_REMOVAL",
		"Stop receiving in-system delivery offers.",
		{
			"available_to_all" = true;
			"requires_equipment" = "EQ_IN_SYSTEM_TAXI_LICENCE";
			"condition_script" = "taxi_equipment.js";
		}
	)  
)
and

Code: Select all

this.allowAwardEquipment = function(eqKey, ship, context) {
	if (player.ship.dockedStation.hasRole("taxi_station"))
		return true;
	else return false;
}
Post Reply