GS2-Inventory Script Trigger Reference
Trigger
acquire
Item acquisition
Synchronous Execution Script
The script is executed synchronously before the item acquisition process.
Request
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| inventory | Inventory | Inventory |
| itemSets | ItemSet[] | List of Item Sets |
| acquireItemName | string | Name of Item Model acquired |
| userId | string | User ID |
| acquireCount | long | Quantity acquired |
| expiresAt | long | Expiration time Unix time, milliseconds |
Result
| Type | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|
| permit | bool | ✓ | Whether to allow item acquisition | ||
| overrideAcquireCount | int | 0 ~ 2147483645 | Actual amount obtained to be applied |
Implementation Example
-- Request
local namespace = args.namespace
local inventory = args.inventory
local itemSets = args.itemSets
local acquireItemName = args.acquireItemName
local userId = args.userId
local acquireCount = args.acquireCount
local expiresAt = args.expiresAt
-- Business logic:
local permit = true
local overrideAcquireCount = 0
-- Result
result = {
permit=permit,
overrideAcquireCount=overrideAcquireCount
}Asynchronous Execution Script
The script is executed asynchronously after the item acquisition process.
Request
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| oldInventory | Inventory | Inventory before update |
| oldItemSets | ItemSet[] | List of Item Sets before renewal |
| newInventory | Inventory | Inventory after update |
| newItemSets | ItemSet[] | List of updated Item Sets |
| acquireItemName | string | Name of Item Model acquired |
| userId | string | User ID |
| acquireCount | long | Quantity acquired |
| overflowValue | long | Amount of overflow |
| expiresAt | long | Expiration time Unix time, milliseconds |
Implementation Example
-- Request
local namespace = args.namespace
local oldInventory = args.oldInventory
local oldItemSets = args.oldItemSets
local newInventory = args.newInventory
local newItemSets = args.newItemSets
local acquireItemName = args.acquireItemName
local userId = args.userId
local acquireCount = args.acquireCount
local overflowValue = args.overflowValue
local expiresAt = args.expiresAt
-- Asynchronous scripts typically do not affect the API response.
-- Use for logging, analytics, external notifications, etc.
result = {
}overflowDone
the number of items hits the acquisition limit and notification of the quantity not obtained is completed
Synchronous Execution Script
The script is executed synchronously before the the number of items hits the acquisition limit and notification of the quantity not obtained is completed process.
Request
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| inventory | Inventory | Inventory |
| itemModel | ItemModel | Item Model |
| userId | string | User ID |
| overflowValue | long | Amount of overflow |
Implementation Example
-- Request
local namespace = args.namespace
local inventory = args.inventory
local itemModel = args.itemModel
local userId = args.userId
local overflowValue = args.overflowValue
-- Business logic:
-- Result
result = {
}consume
item consumption
Synchronous Execution Script
The script is executed synchronously before the item consumption process.
Request
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| inventory | Inventory | Inventory |
| itemSets | ItemSet[] | List of Item Sets |
| consumeItemName | string | Name of Item Model consumed |
| userId | string | User ID |
| consumeCount | long | Quantity consumed |
Result
| Type | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|
| permit | bool | ✓ | Whether to allow item consumption | ||
| overrideConsumeCount | int | 0 ~ 2147483645 | Actual consumption to be applied |
Implementation Example
-- Request
local namespace = args.namespace
local inventory = args.inventory
local itemSets = args.itemSets
local consumeItemName = args.consumeItemName
local userId = args.userId
local consumeCount = args.consumeCount
-- Business logic:
local permit = true
local overrideConsumeCount = 0
-- Result
result = {
permit=permit,
overrideConsumeCount=overrideConsumeCount
}Asynchronous Execution Script
The script is executed asynchronously after the item consumption process.
Request
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| oldInventory | Inventory | Inventory before consumption |
| oldItemSets | ItemSet[] | List of Item Sets before consumption |
| newInventory | Inventory | Inventory after consumption |
| newItemSets | ItemSet[] | List of Item Sets after consumption |
| consumeItemName | string | Name of Item Model consumed |
| userId | string | User ID |
| consumeCount | long | Quantity consumed |
Implementation Example
-- Request
local namespace = args.namespace
local oldInventory = args.oldInventory
local oldItemSets = args.oldItemSets
local newInventory = args.newInventory
local newItemSets = args.newItemSets
local consumeItemName = args.consumeItemName
local userId = args.userId
local consumeCount = args.consumeCount
-- Asynchronous scripts typically do not affect the API response.
-- Use for logging, analytics, external notifications, etc.
result = {
}simpleItemAcquire
Simple Item acquisition
Synchronous Execution Script
The script is executed synchronously before the simple item acquisition process.
Request
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| inventoryName | string | Simple Inventory Model Name The name of the simple inventory model that defines the item types for this inventory. Links the user’s simple inventory instance to its model definition. |
| simpleItems | SimpleItem[] | List of Simple Items |
| userId | string | User ID |
| acquireCounts | AcquireCount[] | List of acquisition quantities for Simple Items |
Result
| Type | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|
| permit | bool | ✓ | Whether to allow Simple Item acquisition | ||
| overrideAcquireCounts | AcquireCount[] | 0 ~ 100 items | List of acquisition quantities for Simple Items |
Implementation Example
-- Request
local namespace = args.namespace
local inventoryName = args.inventoryName
local simpleItems = args.simpleItems
local userId = args.userId
local acquireCounts = args.acquireCounts
-- Business logic:
local permit = true
local overrideAcquireCounts = {}
-- Result
result = {
permit=permit,
overrideAcquireCounts=overrideAcquireCounts
}Asynchronous Execution Script
The script is executed asynchronously after the simple item acquisition process.
Request
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| inventoryName | string | Simple Inventory Model Name The name of the simple inventory model that defines the item types for this inventory. Links the user’s simple inventory instance to its model definition. |
| oldSimpleItems | SimpleItem[] | List of Simple Items before update |
| newSimpleItems | SimpleItem[] | List of Simple Items after Update |
| userId | string | User ID |
| acquireCounts | AcquireCount[] | List of Simple Items |
Implementation Example
-- Request
local namespace = args.namespace
local inventoryName = args.inventoryName
local oldSimpleItems = args.oldSimpleItems
local newSimpleItems = args.newSimpleItems
local userId = args.userId
local acquireCounts = args.acquireCounts
-- Asynchronous scripts typically do not affect the API response.
-- Use for logging, analytics, external notifications, etc.
result = {
}simpleItemConsume
Simple Item consumption
Synchronous Execution Script
The script is executed synchronously before the simple item consumption process.
Request
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| inventoryName | string | Simple Inventory Model Name The name of the simple inventory model that defines the item types for this inventory. Links the user’s simple inventory instance to its model definition. |
| simpleItems | SimpleItem[] | List of Simple Item |
| userId | string | User ID |
| consumeCounts | ConsumeCount[] | List of consumption quantities of Simple Items |
Result
| Type | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|
| permit | bool | ✓ | Whether to allow Simple Item consumption | ||
| overrideConsumeCounts | ConsumeCount[] | 0 ~ 100 items | List of Simple Items |
Implementation Example
-- Request
local namespace = args.namespace
local inventoryName = args.inventoryName
local simpleItems = args.simpleItems
local userId = args.userId
local consumeCounts = args.consumeCounts
-- Business logic:
local permit = true
local overrideConsumeCounts = {}
-- Result
result = {
permit=permit,
overrideConsumeCounts=overrideConsumeCounts
}Asynchronous Execution Script
The script is executed asynchronously after the simple item consumption process.
Request
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| inventoryName | string | Simple Inventory Model Name The name of the simple inventory model that defines the item types for this inventory. Links the user’s simple inventory instance to its model definition. |
| oldSimpleItems | SimpleItem[] | List of Before update Simple Items |
| newSimpleItems | SimpleItem[] | List of After update Simple Items |
| userId | string | User ID |
| consumeCounts | ConsumeCount[] | List of consumption quantities of Simple Items |
Implementation Example
-- Request
local namespace = args.namespace
local inventoryName = args.inventoryName
local oldSimpleItems = args.oldSimpleItems
local newSimpleItems = args.newSimpleItems
local userId = args.userId
local consumeCounts = args.consumeCounts
-- Asynchronous scripts typically do not affect the API response.
-- Use for logging, analytics, external notifications, etc.
result = {
}bigItemAcquire
Big Item acquisition
Synchronous Execution Script
The script is executed synchronously before the big item acquisition process.
Request
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| inventoryName | string | Big Inventory Model Name The name of the big inventory model that defines the item types for this inventory. Links the user’s big inventory instance to its model definition. |
| itemName | string | Big Item Model Name The name of the big item model that defines the type of item stored in this record. Used to identify which item definition this big item possession corresponds to. |
| item | BigItem | Big Item |
| userId | string | User ID |
| acquireCount | string | Acquisition quantity for a Big Item Integer value strings up to 1024 digits |
Result
| Type | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|
| permit | bool | ✓ | Whether to allow Big Item acquisition | ||
| rate | float | 1.0 | 0 ~ 1000 | Acquisition quantity rate |
Implementation Example
-- Request
local namespace = args.namespace
local inventoryName = args.inventoryName
local itemName = args.itemName
local item = args.item
local userId = args.userId
local acquireCount = args.acquireCount
-- Business logic:
local permit = true
local rate = 0
-- Result
result = {
permit=permit,
rate=rate
}Asynchronous Execution Script
The script is executed asynchronously after the big item acquisition process.
Request
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| inventoryName | string | Big Inventory Model Name The name of the big inventory model that defines the item types for this inventory. Links the user’s big inventory instance to its model definition. |
| itemName | string | Big Item Model Name The name of the big item model that defines the type of item stored in this record. Used to identify which item definition this big item possession corresponds to. |
| oldItem | BigItem | Before update Big Item |
| newItem | BigItem | After update Big Item |
| userId | string | User ID |
| acquireCount | string | Acquisition quantity for a Big Item Integer value strings up to 1024 digits |
Implementation Example
-- Request
local namespace = args.namespace
local inventoryName = args.inventoryName
local itemName = args.itemName
local oldItem = args.oldItem
local newItem = args.newItem
local userId = args.userId
local acquireCount = args.acquireCount
-- Asynchronous scripts typically do not affect the API response.
-- Use for logging, analytics, external notifications, etc.
result = {
}bigItemConsume
big item consumption
Synchronous Execution Script
The script is executed synchronously before the big item consumption process.
Request
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| inventoryName | string | Big Inventory Model Name The name of the big inventory model that defines the item types for this inventory. Links the user’s big inventory instance to its model definition. |
| itemName | string | Big Item Model Name The name of the big item model that defines the type of item stored in this record. Used to identify which item definition this big item possession corresponds to. |
| item | BigItem | Big Item |
| userId | string | User ID |
| consumeCount | string | Consumption quantity of a Big Item Integer value strings up to 1024 digits |
Result
| Type | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|
| permit | bool | ✓ | Whether to allow Big Item consumption | ||
| rate | float | 1.0 | 0 ~ 1000 | Consume quantity rate |
Implementation Example
-- Request
local namespace = args.namespace
local inventoryName = args.inventoryName
local itemName = args.itemName
local item = args.item
local userId = args.userId
local consumeCount = args.consumeCount
-- Business logic:
local permit = true
local rate = 0
-- Result
result = {
permit=permit,
rate=rate
}Asynchronous Execution Script
The script is executed asynchronously after the big item consumption process.
Request
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| inventoryName | string | Big Inventory Model Name The name of the big inventory model that defines the item types for this inventory. Links the user’s big inventory instance to its model definition. |
| itemName | string | Big Item Model Name The name of the big item model that defines the type of item stored in this record. Used to identify which item definition this big item possession corresponds to. |
| oldItem | BigItem | Before update Big Item |
| newItem | BigItem | After update Big Item |
| userId | string | User ID |
| consumeCount | string | Consumption quantity of a Big Item Integer value strings up to 1024 digits |
Implementation Example
-- Request
local namespace = args.namespace
local inventoryName = args.inventoryName
local itemName = args.itemName
local oldItem = args.oldItem
local newItem = args.newItem
local userId = args.userId
local consumeCount = args.consumeCount
-- Asynchronous scripts typically do not affect the API response.
-- Use for logging, analytics, external notifications, etc.
result = {
}