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
Type Description
namespace Namespace Namespace
lotteryModel LotteryModel Lottery Model name
drawnPrizes DrawnPrize[] List of Drawn Prizes
boxItems BoxItems Box state including prizes and their remaining/initial quantities
Result
Type Required Default Value Limits Description
permit bool
Whether to allow lottery
overrideDrawnPrizes DrawnPrize[] 0 ~ 1000 items List of Drawn Prizes to override the result
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

Process of dynamically selecting the Prize Table

Synchronous Execution Script

The script is executed synchronously before the process of dynamically selecting the prize table.

Request
Type Description
namespace Namespace Namespace
lotteryModel LotteryModel Lottery Model for dynamically selecting Prize Table
userId string User ID
count int Number of draws
Result
Type Required Default Value Limits Description
prizeTableNames string[]
1 ~ 1000 items List 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
}