Removing pylon based equipments by code

General discussion for players of Oolite.

Moderators: winston, another_commander

Post Reply
User avatar
Okti
---- E L I T E ----
---- E L I T E ----
Posts: 700
Joined: Sun Sep 26, 2010 1:51 pm
Location: A GH shop, near witchpoint to Oresrati in Galaxy 8

Removing pylon based equipments by code

Post 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.
My OXP's
And Latest Mission Coyote's Run
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Re: Removing pylon based equipments by code

Post 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...
Last edited by Kaks on Sat Feb 19, 2011 4:50 pm, edited 1 time in total.
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Removing pylon based equipments by code

Post 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");
				}
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Okti
---- E L I T E ----
---- E L I T E ----
Posts: 700
Joined: Sun Sep 26, 2010 1:51 pm
Location: A GH shop, near witchpoint to Oresrati in Galaxy 8

Re: Removing pylon based equipments by code

Post by Okti »

Hi Smivs,

Unfortunately it did not work.

But what Kaks oferred worked.


Thanks
My OXP's
And Latest Mission Coyote's Run
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Removing pylon based equipments by code

Post by Smivs »

OK, he knows about a zillion times more than I do.
Sorry for giving you the problem in the first place. :(
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Okti
---- E L I T E ----
---- E L I T E ----
Posts: 700
Joined: Sun Sep 26, 2010 1:51 pm
Location: A GH shop, near witchpoint to Oresrati in Galaxy 8

Re: Removing pylon based equipments by code

Post 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
My OXP's
And Latest Mission Coyote's Run
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Removing pylon based equipments by code

Post by Smivs »

Life is never simple :roll:
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Okti
---- E L I T E ----
---- E L I T E ----
Posts: 700
Joined: Sun Sep 26, 2010 1:51 pm
Location: A GH shop, near witchpoint to Oresrati in Galaxy 8

Re: Removing pylon based equipments by code

Post by Okti »

I think I can check for the mission variables used in Vortex for the misile bays and change them as well. :mrgreen:
My OXP's
And Latest Mission Coyote's Run
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Removing pylon based equipments by code

Post 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 ;)
User avatar
Okti
---- E L I T E ----
---- E L I T E ----
Posts: 700
Joined: Sun Sep 26, 2010 1:51 pm
Location: A GH shop, near witchpoint to Oresrati in Galaxy 8

Re: Removing pylon based equipments by code

Post 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.
My OXP's
And Latest Mission Coyote's Run
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Removing pylon based equipments by code

Post 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:
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Okti
---- E L I T E ----
---- E L I T E ----
Posts: 700
Joined: Sun Sep 26, 2010 1:51 pm
Location: A GH shop, near witchpoint to Oresrati in Galaxy 8

Re: Removing pylon based equipments by code

Post by Okti »

:D :D :D :D :D
My OXP's
And Latest Mission Coyote's Run
User avatar
Okti
---- E L I T E ----
---- E L I T E ----
Posts: 700
Joined: Sun Sep 26, 2010 1:51 pm
Location: A GH shop, near witchpoint to Oresrati in Galaxy 8

Re: Removing pylon based equipments by code

Post by Okti »

And I could add a timer watching if they are created again. But I do not personally like timers. :D
My OXP's
And Latest Mission Coyote's Run
Post Reply