I am trying to get product price from App store and display it in the app as text. This is how I am doing
local function loadedCallback(e)
for i=1, #e.products do
table.insert(localizedPrices, i, tostring(e.products[i].price));
end
end
store.loadProducts(productID, loadedCallback);
This code is in a separate file names iap.lua. while localizedPrices is an array. Now I try to get price from another lua file like this. iap.localizedPrices[item No.]. When tested in sandbox environment it gives error and treats localizedPrices as nil. So app crashes. Please help me about this and guide me where I am wrong ?
I will be thankful.
I notice that you are passing a variable called productID to the loadProducts function. If productID is a string with the product name, then it won’t work, since loadProducts is supposed to get a table with the strings of the products. If you have just one product, you could try store.loadProducts( {productID}, loadedCallback) instead.
Andrew [import]uid: 109711 topic_id: 37606 reply_id: 145829[/import]
I notice that you are passing a variable called productID to the loadProducts function. If productID is a string with the product name, then it won’t work, since loadProducts is supposed to get a table with the strings of the products. If you have just one product, you could try store.loadProducts( {productID}, loadedCallback) instead.
Andrew [import]uid: 109711 topic_id: 37606 reply_id: 145829[/import]
Erg, thanks for getting back to me, Rob. I had actually posted my own topic on the issue I was having before the above question in this thread, and then it turned out I made a horrifically embarrassing mistake in my own code… so I quickly deleted it :rolleyes:
In any case, everything is working as expected for me now.
Erg, thanks for getting back to me, Rob. I had actually posted my own topic on the issue I was having before the above question in this thread, and then it turned out I made a horrifically embarrassing mistake in my own code… so I quickly deleted it :rolleyes:
In any case, everything is working as expected for me now.