Page 18 of 29

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Posted: Thu Nov 05, 2020 5:03 am
by Reval
OK, I've kinda worked out how the allowOfferShip method might be used, and produced the following condition script (which, sadly, is having no effect at Lave whatsoever):

Code: Select all

	"use strict";

	this.allowOfferShip = function(shipKey) {
		if ((shipKey=="gecko-player") || (shipKey=="krait-player") || (shipKey=="sidewinder-player") || (shipKey=="adder-player")) {
			if (system.economy <= 6) {
				return true; 
			} else {
				return false;
			}
		}
		return true;
	}
I've also placed the line "condition_script = fe_conditions.js" in the new shipyard.plist entries, a single example of which I post here:

Code: Select all

	"gecko-player" =
	{
		chance = 0.5;
		"optional_equipment" =
		(
            "EQ_ECM",
			"EQ_FUEL_SCOOPS",
			"EQ_PASSENGER_BERTH",
			"EQ_ESCAPE_POD",
			"EQ_ENERGY_BOMB",
			"EQ_ENERGY_UNIT",
			"EQ_DOCK_COMP",
			"EQ_WEAPON_PULSE_LASER",
			"EQ_WEAPON_BEAM_LASER",
			"EQ_WEAPON_MINING_LASER",
			"EQ_FUEL_INJECTION",
			"EQ_SCANNER_SHOW_MISSILE_TARGET",
			"EQ_MULTI_TARGET",
			"EQ_GAL_DRIVE",
			"EQ_ADVANCED_COMPASS",
			"EQ_SHIELD_BOOSTER",
			"EQ_HEAT_SHIELD"
		);
		price = 40000;
		"standard_equipment" =
		{
			extras = "";
			"forward_weapon_type" = "EQ_WEAPON_PULSE_LASER";
		};
		techlevel = 4;
		"weapon_facings" = 1;
		"condition_script" = "fe_conditions.js";
	};
Despite it simply not working as advertized (even on a completely clean install), the latest.log is throwing no errors that might guide me. No errors relating to these OXPs, that is.

Suggestions/corrections welcomed :)

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Posted: Thu Nov 05, 2020 6:49 am
by montana05
Reval wrote: Thu Nov 05, 2020 5:03 am
Suggestions/corrections welcomed :)
Your script will prevent the ship to be sold above TechLevel 6 but it will not force a sale in the other systems. While equipment.plist offers automatically in all systems of the defined Techlevel and above shipyard.plist aka shipyard of a station is using a selection of valid ships, TechLevel and chance are 2 of the factors used.

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Posted: Thu Nov 05, 2020 7:06 am
by Reval
Oh, I see :( So is there not a simple solution?

Edit: I guess one could include start-scenarios for the five new ships, but I was hoping to avoid that further complication. (Kinda spoils the fun of dumping the old Cobby for 50,000 creds, though, dontcha think? ;) )

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Posted: Thu Nov 05, 2020 7:17 am
by montana05
Reval wrote: Thu Nov 05, 2020 7:06 am
Oh, I see :( So is there not a simple solution?
You can use addShipToShipyard to force a sale:

system.mainStation.addShipToShipyard
(
{
short_description: "Cobra Mark I: With fuel injectors and galactic hyperdrive.",
shipdata_key:"cobramk1-player",
price:120000,
personality:Math.floor(Math.random() * 32768),
extras:["EQ_FUEL_INJECTION","EQ_GAL_DRIVE"]
}
);

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Posted: Thu Nov 05, 2020 7:19 am
by Reval
Woo hoo, well, I wasn't aware of that little wheeze (must look at the wiki again) :)

Cheers again, montana.

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Posted: Thu Nov 05, 2020 7:24 am
by montana05
Reval wrote: Thu Nov 05, 2020 7:19 am
Woo hoo, well, I wasn't aware of that little wheeze (must look at the wiki again) :)

Cheers again, montana.
Welcome, you can find the method at "Oolite JavaScript Reference: Station", its pretty new, added V1.89. I didn't think about it first and I never tried so no experience there. :wink:

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Posted: Thu Nov 05, 2020 7:25 am
by Reval
Cool. And that script goes... where? And do I reference it somewhere in shipdata or shipyard?

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Posted: Thu Nov 05, 2020 7:30 am
by montana05
Reval wrote: Thu Nov 05, 2020 7:25 am
Cool. And that script goes... where? And do I reference it somewhere in shipdata or shipyard?
Neither, you will need a separate script. I guess the easiest approach would be to start with player.shipWillExitWitchspace = function()

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Posted: Thu Nov 05, 2020 7:59 am
by another_commander
@Reval: Just checking, I hope you start the game with shift held down when you make changes inside your scripts or plists. Doing so requests a complete cache wipe and rebuild and is the way to get any changes you make in. Otherwise, the game's cache is referenced and that will normally not contain your changes.

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Posted: Thu Nov 05, 2020 8:13 am
by Reval
Oh yes, always. It's become a reflex ;)

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Posted: Thu Nov 05, 2020 12:53 pm
by dybal
montana05 wrote: Thu Nov 05, 2020 7:30 am
Reval wrote: Thu Nov 05, 2020 7:25 am
Cool. And that script goes... where? And do I reference it somewhere in shipdata or shipyard?
Neither, you will need a separate script. I guess the easiest approach would be to start with player.shipWillExitWitchspace = function()
Create a script, include its name in Config/world-scripts.plist , create the wroldScript event handlers in the script.

Event handlers you should create and put your the call to insert the ship in the shipyard in:

startUpComplete
shipExitedWitchspace

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Posted: Thu Nov 05, 2020 1:01 pm
by Reval
OK. Thanks for the clarification. :) I'll get onto that after some ZZZZZZZZs ;)

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Posted: Thu Nov 05, 2020 1:21 pm
by dybal
Things you should be aware:

- there might be other stations with shipyards in the system beside the main station (if the player is running the OXPs that create them)
- not all stations in the system stations list have shipyards
- it might be worthwhile to roll the dice before inserting the ship(s) in the stations' shipyards, just to make the game a bit unpredictable. You might want to use system.scrambledPseudoRandomNumber() for that, it makes things consistent between sucessive loads of a game savefiles.

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Posted: Thu Nov 05, 2020 1:28 pm
by Reval
Well I'm testing atm on a completely clean install. Same result as on the one OXP'd up to the hilt.

Dice roll sounds good, but I _need_ at least the Gecko and Adder at Lave.

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Posted: Thu Nov 05, 2020 1:39 pm
by montana05
Agreed, some OXP's do add (a lot) more stations that will not be covered by the forced sale I suggested. Rolling the dice is very useful, I am doing it for some equipment to prevent it to show up at every station. However, for ships chance is rolling the dice for you already.