I’ve been working on a new version of the Steamworks extension. The new version fixes some issues with the generated code which would result in crashes, specifically with Steamworks API functions where the C++ API expects arguments such as an array of objects/structs and a length of the array. Example:
bool GetItemsWithPrices( SteamItemDef_t *pArrayItemDefs, uint64 *pPrices, uint32 unArrayLength );
bool GetResultItems( SteamInventoryResult_t resultHandle, SteamItemDetails_t *pOutItemsArray, uint32 *punOutItemsArraySize );
In the case of GetItemsWithPrices
the unArrayLength
argument specifies the length of the pArrayItemDefs
and pPrices
arrays. You get unArrayLength
from a call to GetNumItemsWithPrices
.
In the case of GetResultItems
the punOutItemsArraySize
argument specifies the length of the pPrices
array. You get the punOutItemsArraySize
from a call to GetResultItems
with pPrices
set to NULL.
The API definition used when generating the extension and the Lua bindings doesn’t provide a way to distinguish between the two different ways of getting the array length which means that the Lua API has to change for some functions. The Lua API was:
local ok, count, items = steamworks.inventory_get_result_items(handle)
local ok, items , prices = steamworks.inventory_get_items_with_prices(count)
But has been changed to:
local ok, count, items = steamworks.inventory_get_result_items(handle, items, count)
local ok, items , prices = steamworks.inventory_get_items_with_prices(items, prices, count)
In the case of steamworks.inventory_get_result_items
you need to make two calls, one to get the number of items and one to get the items:
-- first call without arguments will return the number of items
local ok, count = steamworks.inventory_get_result_items(handle)
-- second call with length as an argument will get the items
local ok, count, items = steamworks.inventory_get_result_items(handle, nil, count)
I have made a pre-release containing this breaking change and would appreciate help in testing the new version (ping @Pkeod and @dapetcu21).