Page 1 of 1

Removing pylon based equipments by code

Posted: Sat Feb 19, 2011 4:15 pm
by Okti
Is it possible to remove pylon based equipments by code?

Code: Select all

		player.ship.removeEquipment("EQ_GAL_DRIVE");
		var i = 0;
		while (i == 0)
		{
			if (player.ship.equipmentStatus("EQ_GAL_DRIVE_MINE") == "EQUIPMENT_OK")
			{
              player.ship.removeEquipment("EQ_GAL_DRIVE_MINE");
			}   
			else
			{
				i = 1;
				break;
			}	
		}
The first code works alright but not the ones for EQ_GAL_DRIVE_MINE.

Re: Removing pylon based equipments by code

Posted: Sat Feb 19, 2011 4:36 pm
by Kaks
I don't think equipmentStatus works on missiles & mines, since they can't be damaged.

You could still test for the presence of the equipment "EQ_GAL_DRIVE_MINE" inside player.ship.missiles,
but it's a lot simpler to just replace that lot (var i = 0; & that while loop) with

Code: Select all

while (player.ship.removeEquipment("EQ_GAL_DRIVE_MINE"));
to remove all the mines from the ship. (ship.removeEquipment returns false if it couldn't remove the specified equipment)

edit: and the only reason it couldn't remove the equipment is that it's not on board...

Re: Removing pylon based equipments by code

Posted: Sat Feb 19, 2011 4:42 pm
by Smivs
Hi Okti,
I don't know if this will work. It sort of checks if the equipment is not unavailable and removes it in this case. It's a double-negative...if it's not unavailable, it's available. seems a weird way to do it but I've seen something similar done elsewhere.

Code: Select all

if (player.ship.equipmentStatus("EQ_GAL_DRIVE_MINE") !== "EQUIPMENT_UNAVAILABLE")
				{
					player.ship.removeEquipment("EQ_GAL_DRIVE_MINE");
				}

Re: Removing pylon based equipments by code

Posted: Sat Feb 19, 2011 4:55 pm
by Okti
Hi Smivs,

Unfortunately it did not work.

But what Kaks oferred worked.


Thanks

Re: Removing pylon based equipments by code

Posted: Sat Feb 19, 2011 5:09 pm
by Smivs
OK, he knows about a zillion times more than I do.
Sorry for giving you the problem in the first place. :(

Re: Removing pylon based equipments by code

Posted: Sat Feb 19, 2011 5:16 pm
by Okti
No problem Smivs,

The only problem for the time being is if the commander is using a Vortex which can have swichtable missile bays. :D

Re: Removing pylon based equipments by code

Posted: Sat Feb 19, 2011 5:21 pm
by Smivs
Life is never simple :roll:

Re: Removing pylon based equipments by code

Posted: Sat Feb 19, 2011 6:26 pm
by Okti
I think I can check for the mission variables used in Vortex for the misile bays and change them as well. :mrgreen:

Re: Removing pylon based equipments by code

Posted: Sat Feb 19, 2011 6:29 pm
by Thargoid
If EQ_MULTIBAY is present, then the ship is a Vortex.

Then as you rightly say, you can pick the equipment out of the relevant missionVariables to remove them.

If you need any help with the scripting of the ship just let me know. I owe you one for the Manifest catch ;)

Re: Removing pylon based equipments by code

Posted: Sat Feb 19, 2011 6:38 pm
by Okti
No problem Thargoid,

I was only joking, because I use a hacked Vortex :D.

Price is lower, maxmissiles = 10, MaxCargo =100, and I may hack the code for inflight switching between missiles and cargo by activated event. :oops:

But it would be good to have one or two passanger Berths as well.

Re: Removing pylon based equipments by code

Posted: Sat Feb 19, 2011 6:46 pm
by Smivs
Okti wrote:

But it would be good to have one or two passanger Berths as well.
I could do you a couple of hard-to-remove pylon mounted ones if you like :lol:

Re: Removing pylon based equipments by code

Posted: Sat Feb 19, 2011 6:47 pm
by Okti
:D :D :D :D :D

Re: Removing pylon based equipments by code

Posted: Sat Feb 19, 2011 6:55 pm
by Okti
And I could add a timer watching if they are created again. But I do not personally like timers. :D