How to get the contents of the ship inventory and cargo space

Started by loudent, April 16, 2015, 11:45:56 PM

loudent

I've looked through the API for the ships and there's a way to see if it has a specific item and there's a way to see what the ship has equipped, but I'm interested in the contents of both the cargo and the inventory of the ship.

Any way to do that?

ai_enabled

"ship.HasCargoAmount" look for the cargo at player's ship cargo and (if docked) at player's station cargo storage.
"ship.HasItemOfType" is do the same, but for items + it checks equipment also.
If you need some new functions - we could add them with the next patch.

loudent

I realize my original post was unclear. I'm aware of the two functions you mentioned.

What I'm looking for is something like ship.GetCargo(ship_id) which returns all the contents of the cargo in a list (id, count). Same thing with the ship storage space ship.GetStorage(ship_id) which also returns a list of items in a ships storage space.

ai_enabled

I see. So you need the functions to get the items list/cargo list of the specific container (which can be ship items/cargo/equipment, station storage items/cargo, station shop container and flying in the space crate container).
Sounds useful. Will be available with the next patch, it's planned on Monday.
Regards!

jeeplaw

Awesome, so I think where he's going with that request is to include some kind of ship scanner? That way you can scan merchants for illegal trade activity and hunt them down and get bounties? I like it! ;)