cargoCarried?

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

Moderators: winston, another_commander

Post Reply
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

cargoCarried?

Post by Commander McLane »

Can we already query the amount of cargo carried by the player in JS (or anywhere else, for that matter)? So that we use the player.dumpCargo only if there is actually something in the hold?

This has been a request, I am just not sure whether it has already been implemented (and there is nothing in the wiki).
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

Hello? Anybody there?
User avatar
DaddyHoggy
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 8515
Joined: Tue Dec 05, 2006 9:43 pm
Location: Newbury, UK
Contact:

Post by DaddyHoggy »

I'm here - but I can't answer your question...
Selezen wrote:
Apparently I was having a DaddyHoggy moment.
Oolite Life is now revealed here
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

Post by another_commander »

I believe dumpCargo checks for actual cargo presence before dumping anything, so you should be OK to use it. As for a method for querying cargo quantity, I am not sure there is anything at the moment.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

I think nothing has changed till now. The status on the wiki is still correct. As A_C writes: dumpCargo only dumps cargo when the player or NPC has cargo on board.

dumpCargo can be used from within the AI or from JS. In the later case it returns the entity of the dumped cargo (or null when there was no cargo). The entity is probably a cargo pod and a script still will not be able to see what is inside it.

this.cargo = player.dumpCargo()

or

if(player.dumpCargo()) {........}

The later if statement will try to dump the cargo and is only true when there was cargo dumped.
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 »

Hmm, yes. Adding Ship methods:
  • cargoSpaceUsed
  • availableCargoSpace
  • passengerCount
  • passengerCapacity (Currently always 0 for NPCs)
Also renaming maxCargo to cargoCapacity.
Eric Walch wrote:
The entity is probably a cargo pod and a script still will not be able to see what is inside it.
Yep, just a ship like any other. Currently.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

Ahruman wrote:
Hmm, yes. Adding Ship methods:
  • cargoSpaceUsed
  • availableCargoSpace
  • passengerCount
  • passengerCapacity (Currently always 0 for NPCs)
Also renaming maxCargo to cargoCapacity.
Thanks!

Just for clarification: I want to query whether there actually is cargo, because I want to unvoluntarily dump player-cargo together with printing out a screen message. As it is now the screen message will also be given out if there is actually no cargo dumped, which is kind of unsatisfying.

And it's already there in Flying_Dutchman.oxp. (The next version for 1.72 will have the query for cargoSpaceUsed included.)
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Commander McLane wrote:
As it is now the screen message will also be given out if there is actually no cargo dumped, which is kind of unsatisfying.
Not completely. When you use:

Code: Select all

if(player.dumpCargo()) {your message....} 
It tries to dump cargo and your message will only be shown if the cargo was actually dumped. player.dumpCargo() returns true or false, depending if it has dumped something.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

Thanks, Eric! :D

Flying_Dutchman 1.1 is underway...
Post Reply