Forums » Suggestions
Request for Lua Api functions
Can we get some sort of permanent stock number for each item and have Lua look-up functions available ?
ie. Name to stocknumber
Stocknumber to name
It would make it a lot easier to write trade related plugins when you dont have to constantly compare and store string data. (I find it difficult to believe such a number does not already exist).
I would also like a mission accept function if it doesnt already exist.
Thanks
ie. Name to stocknumber
Stocknumber to name
It would make it a lot easier to write trade related plugins when you dont have to constantly compare and store string data. (I find it difficult to believe such a number does not already exist).
I would also like a mission accept function if it doesnt already exist.
Thanks
I'm not sure if this is exactly what you're looking for but there are already ids for items that merchants sell.
As for mission accept, I think I saw a function in the existing API documentation that would do this, and I know someone else was asking about it at one point, but I'm not sure of the state of this functionality.
As for mission accept, I think I saw a function in the existing API documentation that would do this, and I know someone else was asking about it at one point, but I'm not sure of the state of this functionality.
The item ID numbers change from merchant to inventory to ship. We need a constant one. I could create a set but I suspect the number already exists and they just need to give us access to it.
Plenty of ways to get mission info but no accept function that I have seen in the documentation. If it does exist I would be grateful if you could post it.
Plenty of ways to get mission info but no accept function that I have seen in the documentation. If it does exist I would be grateful if you could post it.
Well, it only makes sense that the itemids would change from merchant to player. Since each different stack of an item needs to be unique. The existing functions provide some measure of a way to track these varying ids back to the original information, but since this isn't an area of expertise for me, I can't really comment on the best way to go about it.
As for the mission thing, it looks like the functions you want are:
RequestMissionDetails(idx)
SendMissionQuestionResponse(1)
I haven't taken the time to figure out how to make them work together.
As for the mission thing, it looks like the functions you want are:
RequestMissionDetails(idx)
SendMissionQuestionResponse(1)
I haven't taken the time to figure out how to make them work together.
I think what PaK's asking for is a kind of type ID. One reason each stack gets a different itemID is due to the need to keep it unique. (it's probably a PK for the drop item table in the DB) However, whether you pick up a 3 stacks of Medium Power Cells or buy them or carry 50 to a station, they're always Medium Power Cells. A consistent type ID would keep from having to compare strings all the time.
There already is a permanent stock number for every commodity/addon/ship, but it can be confusing because on racecar the permanent stock number and the one where each stack gets its own number are both referred to as itemid. The functions beginning with GetInventoryItem deal with the stack number (typically 5 digits or less). What you want is the InvManager related functions that deal with the permanent stock number (8 to 10 digits).
For example, the permanent stock number of the hogII is 2809086257, Storm Extender is 3639133428, and Heliocene Ore is 1901609210.
You can see that the 4 ship presets stored in the config.ini use the permanent stock number to identify ships and addons.
I make pretty heavy use of the permanent stock number in ShipLoadoutsManager if you need some examples of how to deal with the permanent stock number.
For example, the permanent stock number of the hogII is 2809086257, Storm Extender is 3639133428, and Heliocene Ore is 1901609210.
You can see that the 4 ship presets stored in the config.ini use the permanent stock number to identify ships and addons.
I make pretty heavy use of the permanent stock number in ShipLoadoutsManager if you need some examples of how to deal with the permanent stock number.
Thanks guys - I will give them a try and see if they do the job
Been meaning to take a long look at the InventoryManager. Sounds like some nice reading to do.
I looked thru the functions and cant find one to get an itemID from the item name string which is the one I need most. Without it I would have to either randomly grab items and do string compares or make and maintain a rather large list of everything in VO. (which would stink)
So the request for stock name to stock number still stands unless someone is kind enough to share an alternative means.
So the request for stock name to stock number still stands unless someone is kind enough to share an alternative means.
You shouldn't need a function to get the permanent stock number given an item name, and using such a function would be a bad practice because of items that are different but share a common text string for the name. "Mining Beam" comes to mind, as there is both a small and large port variety. The copy of TA I have gets confused about that item because it uses the name string as a table key for saving its data when it really should be using the permanent stock number as the table key.
If you need to get the permanent stock number of all the items sold by the current station, use:
for n=1 to GetNumStationMerch() do stock_number = GetStationMerchInfo(n).itemid end
Or if you need to convert the stack number (e.g. an item in inventory) to the permanent stock number use:
stock_number = GetInventoryItemType(stack_number)
With that said, the InvManager.InventoryItemToType(name) will convert an item name to permanent stock number, but the name is not the one seen in-game. It seems to be a unique name the devs have given every item that does not include spaces. The 3 items I listed in my previous post use the names warthogMkII, StormRadarExtender, & OreHeliocene (all case-sensitive). You really shouldn't need to use this function, except perhaps if you wanted to use those names as keys to a table or something.
If you need to get the permanent stock number of all the items sold by the current station, use:
for n=1 to GetNumStationMerch() do stock_number = GetStationMerchInfo(n).itemid end
Or if you need to convert the stack number (e.g. an item in inventory) to the permanent stock number use:
stock_number = GetInventoryItemType(stack_number)
With that said, the InvManager.InventoryItemToType(name) will convert an item name to permanent stock number, but the name is not the one seen in-game. It seems to be a unique name the devs have given every item that does not include spaces. The 3 items I listed in my previous post use the names warthogMkII, StormRadarExtender, & OreHeliocene (all case-sensitive). You really shouldn't need to use this function, except perhaps if you wanted to use those names as keys to a table or something.
The problem Is I need to convert the items listed in the mission objectives to item numbers and they are only listed by name.
Hmm... sounds like you are trying to write a plug-in I've already written. Just needs a bit more polish and I'll be able to release. Possibly this weekend.
Well could you post how you matched up the parts from the mission objectives to actual inventory items - sounds like you already solved my problem....
local stationid = GetStationLocation()
local sta_items = GetStationCargoList(stationid)
for _,itemid in ipairs(sta_items) do
local item_name = GetInventoryItemName(itemid)
if needed_items[item_name] then
etc
where needed_items is a table with item names as keys created using info from the mission objectives
local sta_items = GetStationCargoList(stationid)
for _,itemid in ipairs(sta_items) do
local item_name = GetInventoryItemName(itemid)
if needed_items[item_name] then
etc
where needed_items is a table with item names as keys created using info from the mission objectives