Ejecting nonstandard cargo and the shipSpawned event-Solved

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
phkb
Commodore
Commodore
Posts: 2433
Joined: Tue Jan 21, 2014 10:37 pm
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...

Ejecting nonstandard cargo and the shipSpawned event-Solved

Post by phkb » Tue Apr 05, 2016 11:39 am

I've been playing around with a mission pack that utilitises the Black Box from cim's/spara's Rescue Stations. I've created my own custom shipdata entry for it, and can now happily spawn blackboxes to my hearts content. Here's the shipdata code for reference purposes:

Code: Select all

	"gcm-blackbox-template" = {
		is_template = "yes";
		ai_type = "nullAI.plist";
		energy_recharge_rate = 1;
		forward_weapon_type = "WEAPON_NONE";
		heat_insulation = 0.3;
		max_energy = 10;
		max_flight_pitch = 0.5;
		max_flight_roll = 0.5;
		max_flight_speed = 0;
		missiles = 0;
		model = "gcm_blackbox.dat";
		materials = {
			"gcm_blackbox.png" = {
				"diffuse_map" = "gcm_blackbox.png";
				"emission_map" = "gcm_blackbox_emission.png";
				"specular_map" = "gcm_blackbox_specular.png";
				"normal_map" = "gcm_blackbox_normal.png";
				"shininess" = "128";
			};
		};		
		name = "Black Box";
		scan_class = "CLASS_CARGO";
		thrust = 0;
		weapon_energy = "0";
		script_info = {
			no_sc_config = 1;
		};
		subentities = (
			{
				type = "flasher";
				color = { hue = 200; };
				frequency = 0.1;
				size = 7.5;
			}
		);		
	};
	"gcm-blackbox" = {
		like_ship = "gcm-blackbox-template";
		cargo_type = "CARGO_CARRIED";
		cargo_carried = "1 machinery";
		roles = "gcm_blackbox";
		unpiloted = "yes";
	};
I didn't realise that Oolite keeps a track of the data key of scooped objects, because I discovered if I scoop my black box, and then eject it again, the original model is respawned, not a standard cargo container. That's really cool!

But here's the thing: there is no "shipSpawned" event in this case. I've just spent the last two hours trying to work out why my code for detecting when the player ejects cargo (using the "shipSpawned" event) wasn't working, and the reason was, the event wasn't being called at all. This is in 1.82.

I took my code to 1.83, added the new "shipDumpedCargo" event and now I could see my blackbox being spawned. But still the "shipSpawned" event didn't fire.

So I think this is a bug, but I'd appreciate any pointers if I've messed something up somewhere.
Last edited by phkb on Wed Apr 06, 2016 2:26 am, edited 1 time in total.

User avatar
phkb
Commodore
Commodore
Posts: 2433
Joined: Tue Jan 21, 2014 10:37 pm
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...

Re: Ejecting non-standard cargo and the shipSpawned event

Post by phkb » Wed Apr 06, 2016 2:25 am

Nevermind, I think I worked this out after looking through the source. Scooped objects, and indeed all scooped objects in the hold, are still entities in the system. Therefore, when they are ejected they are not re-spawned, but just reappear. That's why the ship knew what type of object I'd scooped, and was able to eject the same item.

Sorry for the diversion. We will now return you to your normal programming.

Edit: Found out I should have been using the shipWasDumped event. Just for future reference.

Post Reply