GS2-Lottery Script Trigger Reference

Reference for event triggers that call extended scripts

Trigger

lottery

Lottery

Synchronous Execution Script

The script is executed synchronously before the lottery process.

Request
TypeDescription
namespaceNamespaceNamespace
lotteryModelLotteryModelLottery Model name
drawnPrizesDrawnPrize[]List of Drawn Prizes
boxItemsBoxItemsList of items taken out of the box
Result
TypeRequiredDefaultValue LimitsDescription
permitbool
Whether to allow lottery
overrideDrawnPrizesDrawnPrize[]0 ~ 1000 itemsList of Drawn Prizes
Implementation Example
-- Request
local namespace = args.namespace
local lotteryModel = args.lotteryModel
local drawnPrizes = args.drawnPrizes
local boxItems = args.boxItems

-- Business logic:
local permit = true
local overrideDrawnPrizes = {}

-- Result
result = {
  permit=permit,
  overrideDrawnPrizes=overrideDrawnPrizes
}

choicePrizeTable

A script that dynamically changes the Prize Table

Synchronous Execution Script

The script is executed synchronously before the a script that dynamically changes the prize table process.

Request
TypeDescription
namespaceNamespaceNamespace
lotteryModelLotteryModelLottery Model for dynamically selecting Prize Table
userIdstringUser ID
countintNumber of draws
Result
TypeRequiredDefaultValue LimitsDescription
prizeTableNamesstring[]
1 ~ 1000 itemsList of Prize Table names to be used for the lottery
If there are 10 response values but fewer than 10 draws, they will be used in order starting from the first one.
If there are 10 draws and fewer than 10 Prize Tables are responded to, the responded Prize Tables will be used in order, and the remaining draws will be conducted using the last Prize Table responded to.
For example, if three Prize Tables are responded to, the first draw will use the first Prize Table, the second draw will use the second Prize Table, and the third draw and subsequent draws will use the third Prize Table.
Implementation Example
-- Request
local namespace = args.namespace
local lotteryModel = args.lotteryModel
local userId = args.userId
local count = args.count

-- Business logic:
local prizeTableNames = {}

-- Result
result = {
  prizeTableNames=prizeTableNames
}