AMS ammo counter

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

Post Reply
User avatar
Cmdr Wyvern
---- E L I T E ----
---- E L I T E ----
Posts: 1649
Joined: Tue Apr 11, 2006 1:47 am
Location: Somewhere in the great starry void

AMS ammo counter

Post by Cmdr Wyvern »

I want to set up a dart ammo tally for AMS; for when you go to the manifest screen(F5-F5), you can read a message like "AMS dart ammo available: <darts in magazine>". I recon it would be useful to quickly tell how much ammo is remaining in the AMS, and since it doesn't use missile stores like other ammo...

I know the AMS uses a mission variable, amCount, to keep track of it's ammo, and it would be swell to read the amCount variable for the manifest message.
The thing is, I'm completely at a loss on how to make that happen. Some assistance, please :?:
Running Oolite buttery smooth & rock stable w/ tons of eyecandy oxps on:
ASUS Prime X370-A
Ryzen 5 1500X
16GB DDR4 3200MHZ
128GB NVMe M.2 SSD (Boot drive)
1TB Hybrid HDD (For software and games)
EVGA GTX-1070 SC
1080P Samsung large screen monitor
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

The mission javascript element is your friend here, specifically mission.setInstructionsKey()

That said I must admit I'm highly dubious about using the manifest screen for such things, simply because very very quickly it seems to fill up once you get a few OXPs in the game and becomes indecipherable and messy. That's why I've avoided using it for just this kind of consideration, and use a pop-up message on launch instead.
User avatar
Cmdr Wyvern
---- E L I T E ----
---- E L I T E ----
Posts: 1649
Joined: Tue Apr 11, 2006 1:47 am
Location: Somewhere in the great starry void

Post by Cmdr Wyvern »

Thargoid wrote:
The mission javascript element is your friend here, specifically mission.setInstructionsKey()
Sorry bud, that's not a lot of help. I'm hopelessly ignorant on how to make this go. I tried studying the code from mission oxps, and got lost in the code and even more confused.
Thargoid wrote:
That said I must admit I'm highly dubious about using the manifest screen for such things, simply because very very quickly it seems to fill up once you get a few OXPs in the game and becomes indecipherable and messy. That's why I've avoided using it for just this kind of consideration, and use a pop-up message on launch instead.
Noted. I don't have a lot of mission oxps installed myself, just UPS and RH at the moment. I tend to uninstall one-shot missions once I play them through.
But what the hell, I thought it would be a handy widget to have. Normally AMS only displays a hud message when you launch or it shoots off a dart.

For anyone who gives a flip, here's the code I'm tinkering with.

Code: Select all

this.startUp = this.shipLaunchedFromStation = this.shipExitedWitchspace = this.shipDockedWithStation = function() { // Displays dart ammo count on the manifest screen. No ammo display if AMS N/A.
	if(player.ship.hasEquipment("EQ_AMS") && missionVariables.amCount > 0) {
		mission.setInstructionsKey("ams_ammo_status" + (this.amCount));
	}
	else if(player.ship.hasEquipment("EQ_AMS") && missionVariables.amCount < 1) {
		mission.setInstructionsKey("ams_ammo_status_empty");
	}
}
Running Oolite buttery smooth & rock stable w/ tons of eyecandy oxps on:
ASUS Prime X370-A
Ryzen 5 1500X
16GB DDR4 3200MHZ
128GB NVMe M.2 SSD (Boot drive)
1TB Hybrid HDD (For software and games)
EVGA GTX-1070 SC
1080P Samsung large screen monitor
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

Cmdr Wyvern wrote:
Sorry bud, that's not a lot of help. I'm hopelessly ignorant on how to make this go. I tried studying the code from mission oxps, and got lost in the code and even more confused.
The good news is, mission screens will be far simpler in 1.74.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

@Wyvern - looks in the right kind of lines.

Grab my Planetfall taxi add-on and have a look in there, that uses the manifest screen to show where the destination is, and the script's reasonably small.

Not much time at the moment (off on hols on Monday, so manic sorting out etc) but if this goes on until next weekend I'll look at it for you).
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

Post by Kaks »

Wyvern, it looks ok, but what have you got inside missiontext.plist?

As Ahruman said, the whole mission stuff is going to be simpler to handle in 1.74.

In this specific case, in 1.74 you will also be able to just do

mission.setInstructions("AMS dart ammo available: " + (this.amCount));

without adding all the various instructions key definitions inside missiontext.plist.
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
Cmdr Wyvern
---- E L I T E ----
---- E L I T E ----
Posts: 1649
Joined: Tue Apr 11, 2006 1:47 am
Location: Somewhere in the great starry void

Post by Cmdr Wyvern »

Thargoid wrote:
@Wyvern - looks in the right kind of lines.

Grab my Planetfall taxi add-on and have a look in there, that uses the manifest screen to show where the destination is, and the script's reasonably small.

Not much time at the moment (off on hols on Monday, so manic sorting out etc) but if this goes on until next weekend I'll look at it for you).
Thank, Thargy. This puts me on the right track, methinks. :)
Running Oolite buttery smooth & rock stable w/ tons of eyecandy oxps on:
ASUS Prime X370-A
Ryzen 5 1500X
16GB DDR4 3200MHZ
128GB NVMe M.2 SSD (Boot drive)
1TB Hybrid HDD (For software and games)
EVGA GTX-1070 SC
1080P Samsung large screen monitor
Post Reply