GS2-Exchange Script Trigger Reference

Reference of event triggers that call extended scripts

Trigger

exchange

Exchange

Synchronous Execution Script

The script is executed synchronously before the exchange process.

Request
TypeDescription
namespaceNamespaceNamespace
rateModelRateModelExchange Rate Model
userIdstringUser ID performing the exchange
countintExchanging volume
configConfig[]Configuration values applied to transaction variables
Result
TypeRequiredDefaultValue LimitsDescription
permitbool
Whether to allow exchange
rateModestring
“float”Rate mode
ratefloat1.00 ~ 1000Acquisition quantity rate
logRateLogRateLogarithmic acquisition correction
Implementation Example
-- Request
local namespace = args.namespace
local rateModel = args.rateModel
local userId = args.userId
local count = args.count
local config = args.config

-- Business logic:
local permit = true
local rateMode = ""
local rate = 0
local logRate = nil

-- Result
result = {
  permit=permit,
  rateMode=rateMode,
  rate=rate,
  logRate=logRate
}

Asynchronous Execution Script

The script is executed asynchronously after the exchange process.

Request
TypeDescription
namespaceNamespaceNamespace
rateModelRateModelExchange Rate Model
userIdstringUser ID performing the exchange
countintExchanging volume
configConfig[]Configuration values applied to transaction variables
Implementation Example
-- Request
local namespace = args.namespace
local rateModel = args.rateModel
local userId = args.userId
local count = args.count
local config = args.config

-- Asynchronous scripts typically do not affect the API response.
-- Use for logging, analytics, external notifications, etc.

result = {
}

incrementalExchange

Exchange

Synchronous Execution Script

The script is executed synchronously before the exchange process.

Request
TypeDescription
namespaceNamespaceNamespace
rateModelIncrementalRateModelExchange rate model
userIdstringUser ID performing the exchange
countintExchanging volume
configConfig[]Set values to be applied to transaction variables
Result
TypeRequiredDefaultValue LimitsDescription
permitbool
Whether to allow exchange
Implementation Example
-- Request
local namespace = args.namespace
local rateModel = args.rateModel
local userId = args.userId
local count = args.count
local config = args.config

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}

Asynchronous Execution Script

The script is executed asynchronously after the exchange process.

Request
TypeDescription
namespaceNamespaceNamespace
rateModelIncrementalRateModelExchange rate model
userIdstringUser ID performing the exchange
countintExchanging volume
configConfig[]Set values to be applied to transaction variables
Implementation Example
-- Request
local namespace = args.namespace
local rateModel = args.rateModel
local userId = args.userId
local count = args.count
local config = args.config

-- Asynchronous scripts typically do not affect the API response.
-- Use for logging, analytics, external notifications, etc.

result = {
}

calculateCost

Cost calculation script for Incremental Cost Exchange Rate

Synchronous Execution Script

The script is executed synchronously before the cost calculation script for incremental cost exchange rate process.

Request
TypeDescription
namespaceNamespaceNamespace
incrementalRateModelIncrementalRateModelIncremental Cost Exchange Rate Model
userIdstringUser ID
currentExchangeCountintCurrent number of exchange counts
quantityintExchange Quantity
Result
TypeRequiredDefaultValue LimitsDescription
costModestring
“num”Cost calculation method
costlong0 ~ 9223372036854775805Cost
logCostLogCostCost calculation result using logarithm
Implementation Example
-- Request
local namespace = args.namespace
local incrementalRateModel = args.incrementalRateModel
local userId = args.userId
local currentExchangeCount = args.currentExchangeCount
local quantity = args.quantity

-- Business logic:
local costMode = ""
local cost = 0
local logCost = nil

-- Result
result = {
  costMode=costMode,
  cost=cost,
  logCost=logCost
}

acquireAwait

Exchange Await

Synchronous Execution Script

The script is executed synchronously before the exchange await process.

Request
TypeDescription
namespaceNamespaceNamespace
rateModelRateModelExchange Rate Model
awaitModelAwaitExchange Await
Result
TypeRequiredDefaultValue LimitsDescription
permitbool
Whether to allow awaiting exchange
Implementation Example
-- Request
local namespace = args.namespace
local rateModel = args.rateModel
local awaitModel = args.awaitModel

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}

Asynchronous Execution Script

The script is executed asynchronously after the exchange await process.

Request
TypeDescription
namespaceNamespaceNamespace
rateModelRateModelExchange Rate Model
awaitModelAwaitExchange Await
Implementation Example
-- Request
local namespace = args.namespace
local rateModel = args.rateModel
local awaitModel = args.awaitModel

-- Asynchronous scripts typically do not affect the API response.
-- Use for logging, analytics, external notifications, etc.

result = {
}