General discussion for players of Oolite.
Moderators: winston , another_commander
Okti
---- 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
Post
by Okti » Sat Feb 19, 2011 4:15 pm
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.
Kaks
Quite Grand Sub-Admiral
Posts: 3009 Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke
Post
by Kaks » Sat Feb 19, 2011 4:36 pm
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.
Smivs
Retired Assassin
Posts: 8408 Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:
Post
by Smivs » Sat Feb 19, 2011 4:42 pm
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");
}
Okti
---- 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
Post
by Okti » Sat Feb 19, 2011 4:55 pm
Hi Smivs,
Unfortunately it did not work.
But what Kaks oferred worked.
Thanks
Smivs
Retired Assassin
Posts: 8408 Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:
Post
by Smivs » Sat Feb 19, 2011 5:09 pm
OK, he knows about a zillion times more than I do.
Sorry for giving you the problem in the first place.
Okti
---- 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
Post
by Okti » Sat Feb 19, 2011 5:16 pm
No problem Smivs,
The only problem for the time being is if the commander is using a Vortex which can have swichtable missile bays.
Smivs
Retired Assassin
Posts: 8408 Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:
Post
by Smivs » Sat Feb 19, 2011 5:21 pm
Life is never simple
Okti
---- 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
Post
by Okti » Sat Feb 19, 2011 6:26 pm
I think I can check for the mission variables used in Vortex for the misile bays and change them as well.
Thargoid
Thargoid
Posts: 5528 Joined: Thu Jun 12, 2008 6:55 pm
Post
by Thargoid » Sat Feb 19, 2011 6:29 pm
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
Okti
---- 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
Post
by Okti » Sat Feb 19, 2011 6:38 pm
No problem Thargoid,
I was only joking, because I use a hacked Vortex
.
Price is lower, maxmissiles = 10, MaxCargo =100, and I may hack the code for inflight switching between missiles and cargo by activated event.
But it would be good to have one or two passanger Berths as well.
Smivs
Retired Assassin
Posts: 8408 Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:
Post
by Smivs » Sat Feb 19, 2011 6:46 pm
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
Okti
---- 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
Post
by Okti » Sat Feb 19, 2011 6:47 pm
Okti
---- 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
Post
by Okti » Sat Feb 19, 2011 6:55 pm
And I could add a timer watching if they are created again. But I do not personally like timers.