Scripting API issue missing a function?

Started by ninekorn, July 19, 2017, 01:29:35 AM

ninekorn

Hey AI-Enable. If youre still working could I know how to access items from "itemsInCargo = items.GetItemsAndCargo(shop_container_id)". This gives me an array of objects. but nowhere i can find in the scripts how to go get the difference shop sections like "boosters" "devices" "hulls" etc. When I write a for loop to try and get them i get [object object] and when i do a double for loop to iterate through itemsInCargo[g] I get nothing. again. thats probably my lack of knowledge of javascript but still theres no explanation for that in the Scripting API unless I just didnt find it. You see Im creating this market Terminal where players will be able to access every shops in each system the moment they access that terminal. Right now I can select systems then stations then I get the "main" station container i guess then I thought I would get the different sections of the shops with that GetItemsAndCargo function. But it just returns "object object" all the time. Once I get those items I will incorporate buy/sell for the player to buy items from the other side of the galaxy. Im not there yet.

something like:

"itemsInCargo = items.GetItemsAndCargo(shop_container_id)".

for (i = 0; i < itemsInCargo.length; i++)
{
       console.Print(itemsInCargo[i]+ " " + " SHOPCONTAINERID");
}
then i dont know what?


ai_enabled

There are no actual sections in the shop container - it simply contains items list. The sections are working as a simple filter on the client-side only - it knows all the items in the shop container but displays only those which belong to a selected section.
GetItemsAndCargo returns array of objects. Each object contains following fields:
int item_id
int quantity
string xml_id

Beware that cargo items are not usual items - they don't have ID's (always zero) - only xml_id and quantity. But that also helps to determine if item is cargo - just check if item_id == 0.

ninekorn

thank you. in the end i was the one that had gone to sleep. had a big day yesterday. Ill try that out today.