Forums » Suggestions
Make identifying ship makes via Lua great again!
As far as I know, there is not a good way to determine what kind of ship another player's named capital ship is. We have the following relevant lua functions:
GetActiveShipName() -> string name (this will be the custom name)
GetActiveShipID() -> int itemid (used for looking up item information)
GetPrimaryShipNameOfPlayer(int charid) -> string name (this will also be the custom name)
GetPrimaryShipIDOfPlayer(int charid) -> int objectid (used for targeting, not looking up item information)
Of those, the only one that returns anything that can be used to determine what kind of capship a named vessel is is GetActiveShipID(), and that's only available for your own ship. Can't use it on other people's. The only way I can find to identify other people's ships is to use GetPrimaryShipIDOfPlayer() to get the objectid, then point the radar at them, and then get the information out of GetTargetInfo(). But this requires changing your target. That shouldn't be necessary. You don't have to actually target a ship to look up how far away it is, how much health it has, who it belongs to, what it's named, or anything like that, so it doesn't make sense that you'd have to target to determine which kind of capship it is either.
So, I propose a pair of new GetPrimaryShip* functions:
GetPrimaryShipMakeOfPlayer(int charid) -> string name (actual name of the ship type, not custom name)
GetPrimaryShipItemIDOfPlayer(int charid) -> int itemid
Like the existing GetPrimaryShip* functions, these would default to the player's ship if a charid is not provided, and they would be restricted to ships in the player's current sector.
GetActiveShipName() -> string name (this will be the custom name)
GetActiveShipID() -> int itemid (used for looking up item information)
GetPrimaryShipNameOfPlayer(int charid) -> string name (this will also be the custom name)
GetPrimaryShipIDOfPlayer(int charid) -> int objectid (used for targeting, not looking up item information)
Of those, the only one that returns anything that can be used to determine what kind of capship a named vessel is is GetActiveShipID(), and that's only available for your own ship. Can't use it on other people's. The only way I can find to identify other people's ships is to use GetPrimaryShipIDOfPlayer() to get the objectid, then point the radar at them, and then get the information out of GetTargetInfo(). But this requires changing your target. That shouldn't be necessary. You don't have to actually target a ship to look up how far away it is, how much health it has, who it belongs to, what it's named, or anything like that, so it doesn't make sense that you'd have to target to determine which kind of capship it is either.
So, I propose a pair of new GetPrimaryShip* functions:
GetPrimaryShipMakeOfPlayer(int charid) -> string name (actual name of the ship type, not custom name)
GetPrimaryShipItemIDOfPlayer(int charid) -> int itemid
Like the existing GetPrimaryShip* functions, these would default to the player's ship if a charid is not provided, and they would be restricted to ships in the player's current sector.
+1
+1; didn't the honk plugin say that the trident honk was provided for just any ship that didn't match existing ship names? Now that the Golly is around, doees it honk like a trident because of this?
Yep. And I'd rather leave it like that than have Honk temporarily change your target every time somebody honks at you.
@Pizzasgood
The GetPrimaryShipNameOfPlayer(int charid) function does do what you want. The tricky part is that the behavior is different for yourself (where it does return the custom ship name) versus another player (where it returns the name of the ship class, e.g. Goliath). The sensor log uses GetPrimaryShipNameOfPlayer(charid) to populate the ship column, so you can see how it works there.
Granted, this only works for the pilot of the capship (whether the pilot is manning a turret or not does not matter). GetPrimaryShipNameOfPlayer(charid) returns nil for passengers.
You'll still have to go through a few hoops using GetActiveShipID() to get the info for your own ship.
The GetPrimaryShipNameOfPlayer(int charid) function does do what you want. The tricky part is that the behavior is different for yourself (where it does return the custom ship name) versus another player (where it returns the name of the ship class, e.g. Goliath). The sensor log uses GetPrimaryShipNameOfPlayer(charid) to populate the ship column, so you can see how it works there.
Granted, this only works for the pilot of the capship (whether the pilot is manning a turret or not does not matter). GetPrimaryShipNameOfPlayer(charid) returns nil for passengers.
You'll still have to go through a few hoops using GetActiveShipID() to get the info for your own ship.
Oh! Thanks, I can work with that.