IAP Badger

A simple, unified, IAP library for Corona SDK


Type function
Library iap_badger.*
Return value
Keywords inventory, set, value
See also iap_badger.addToInventory() iap_badger.saveInventory()


This function specifies the value of an item in the inventory. It's main purpose is to allow an app to piggyback IAP Badger's save and restore functionality, permitting an app to store variables alongside IAP Badger's inventory. Changes won't be written permanently to the device until the saveInventory() function is called.

Warning: this function should not be used to change the value of inventory items already handled by IAP Badger, or an error may be thrown.


iap_badger.setInventoryValue( itemName, value )
itemName (required)

String. The name of the item in the inventory whose value will be changed. This must correspond to an entry in the inventoryItems table in the product catalogue passed to iap_badger.init().

itemCount (required)

A value to give the item. This can be any of the standard Corona data types, including tables.


Saving additional quantities alongside IAP Badger's inventory information.

--Include the plugin
local iap = require 'plugin.iap_badger'

--Create the product catalogue
local catalogue = {

    --Information about the product on the app stores
    products = {    

    --Information about how to handle the inventory item
    inventoryItems = {
        --The following inventory item will be handled by IAP Badger
        hat = { productType="consumable" },

--This table contains all of the options we need to specify in this example program.
local iapOptions = {
    --The catalogue generated above
    --The filename in which to save the inventory

--Initialise IAP badger

--Add an item to the inventory


--Save the app's high score information alongside the inventory.
iap.setInventoryValue("hiscore", 10000)
iap.setInventoryValue("hiscore_playername", "Jim")

--Save the inventory

--Next time the inventory is loaded, the high score information as specified above will be available.

This website uses cookies. Click here to see our privacy policy. Created using the Responsive Grid System.