# Game Management

Before using game management API, create a gane management object is required, as below:

local Game = class.Game.new()

The specific function name and description are as follows:

Serial number Function name Description
1 doGameEnd(...) End the game
2 getDefString(...) Acquire default character string
3 setScriptVar(...) Set the script's attribute for custom
4 getScriptVar(...) Receive script attribute for custom
5 sendScriptVars2Client(...) Upload the script's attribute
6 addRenderGlobalEffect(...) New global effect
7 removeRenderGlobalEffect(...) Clear global effect
8 setRenderGlobalEffectPos(...) Set the location of global effect
9 setRenderGlobalEffectScale(...) Set global zoom effect
10 msgBox(...) Set pop-up notice

# doGameEnd

  • Parameters and types:nil
  • Return value and types:
  • The main role of this method: End the game
  • The specific use cases are as follows:
--每当玩家做动画表情,就会游戏结束
--当玩家做动画表情时执行此函数
local function Player_PlayAction(event)
	--结束游戏
    Game:doGameEnd(nil)
end
--注册一个动画表情监听器,事件发生时执行上面的函数
ScriptSupportEvent:registerEvent([=[Player.PlayAction]=],Player_PlayAction)

# getDefString

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Acquire default character string
  • The specific use cases are as follows:
--获取id为1的默认字符串,参数1为默认字符串id(不建议使用此接口)
local result,str=Game:getDefString(1)
--在聊天框显示
Chat:sendSystemMsg("id为1的默认字符串内容为:"..str)

# setScriptVar

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set the script's attribute for custom
  • The specific use cases are as follows:
local result = Game:setScriptVar(index, val)

# getScriptVar

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Receive script attribute for custom
  • The specific use cases are as follows:
local result = Game:getScriptVar(index)

# sendScriptVars2Client

  • Parameters and types:nil
  • Return value and types:
  • The main role of this method: Upload the script's attribute
  • The specific use cases are as follows:
local result = Game:sendScriptVars2Client()

# addRenderGlobalEffect

  • Parameters and types:
  • Return value and types:
  • The main role of this method: New global effect
  • The specific use cases are as follows:
--在游戏添加一个迷雾特效,目前参数只支持一个"particles/Fog.ent"
local result,effectid=Game:addRenderGlobalEffect("particles/Fog.ent")
--在聊天框显示
Chat:sendSystemMsg("添加了一个迷雾效果!id为"..effectid)

# removeRenderGlobalEffect

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Clear global effect
  • The specific use cases are as follows:
--移除id为1的地图特效,参数1为要移除的特效id
Game:removeRenderGlobalEffect(1)
--在聊天框显示
Chat:sendSystemMsg("移除了id为1的地图特效")

# setRenderGlobalEffectPos

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set the location of global effect
  • The specific use cases are as follows:
--把id为1的地图特效移动至(10,10)高度7
--第一个参数为特效id
--后三个参数为移动至坐标
Game:setRenderGlobalEffectPos(1,10,7,10)
--在聊天框显示
Chat:sendSystemMsg("把id为1的特效移动到了坐标(0,0)高度7的位置")

# setRenderGlobalEffectScale

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set global zoom effect
  • The specific use cases are as follows:
--把id为1的地图特效放大两倍
--第一个参数为需要缩放的特效id
--后三个参数分别为特效在x、y、z方向上的缩放倍数
Game:setRenderGlobalEffectScale(1,2,2,2)
--在聊天框显示
Chat:sendSystemMsg("把id为1的特效放大了2倍")

# msgBox

  • Parameters and types:
    • msg:string the text to display
  • Return value and types:
  • The main role of this method: Set pop-up notice
  • The specific use cases are as follows:
--每当玩家做动画表情,显示一个弹窗
--当玩家做动画表情时执行此函数
local function Player_PlayAction(event)
	--显示一个游戏弹窗,参数为弹窗显示内容
    Game:msgBox("这是一个弹窗!")
end
--注册一个动画表情监听器,事件发生时执行上面的函数
ScriptSupportEvent:registerEvent([=[Player.PlayAction]=],Player_PlayAction)
Last Update: 6/11/2020, 9:30:46 PM