Page 1 of 1

cargoCarried?

Posted: Mon Jul 14, 2008 2:25 pm
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).

Posted: Tue Jul 15, 2008 11:05 am
by Commander McLane
Hello? Anybody there?

Posted: Tue Jul 15, 2008 11:09 am
by DaddyHoggy
I'm here - but I can't answer your question...

Posted: Tue Jul 15, 2008 11:48 am
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.

Posted: Tue Jul 15, 2008 2:27 pm
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.

Posted: Tue Jul 15, 2008 2:42 pm
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.

Posted: Thu Jul 24, 2008 8:44 am
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.)

Posted: Thu Jul 24, 2008 10:29 am
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.

Posted: Fri Jul 25, 2008 6:14 am
by Commander McLane
Thanks, Eric! :D

Flying_Dutchman 1.1 is underway...