# 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:
--Whenever the player makes an animated expression,the game will end
--This function is executed when the player makes an animated expression
local function Player_PlayAction(event)
	--End Game
Game:doGameEnd(nil)
end
--Register an animated expression listener,execute the above function when the event occurs
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:
--Get the default string with id 1 and parameter 1 is the default string id (this interface is not recommended)
local result,str=Game:getDefString(1)
--Show in chat box
Chat:sendSystemMsg("The default string content with id 1 is:"..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:
--Add a fog effect to the game,currently the parameter only supports one "particles/Fog.ent"
local result,effectid=Game:addRenderGlobalEffect("particles/Fog.ent")
--Show in chat box
Chat:sendSystemMsg("Add a fog effect! id is "..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:
--Remove the map special effect with id 1,parameter 1 is the special effect id to be removed
Game:removeRenderGlobalEffect(1)
--Show in chat box
Chat:sendSystemMsg("Remove the map effect with 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:
--Move the map effect with id 1 to (10,10) height 7
--The first parameter is the special effect id
--The last three parameters are moving to coordinates
Game:setRenderGlobalEffectPos(1,10,7,10)
--Show in chat box
Chat:sendSystemMsg("Move the special effect with id 1 to the position with coordinates(0,0) height 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:
--double the map effect with id 1
--The first parameter is the special effect id that needs to be scaled
--The last three parameters are the magnification of the special effects in the x,y,and z directions
Game:setRenderGlobalEffectScale(1,2,2,2)
--Show in chat box
Chat:sendSystemMsg("Amplify the special effect with id 1 by 2 times")

# 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:
--Whenever the player makes an animated expression,a pop-up window is displayed
--This function is executed when the player makes an animated expression
local function Player_PlayAction(event)
	--Display a game pop-up window,the parameter is the pop-up window display content
Game:msgBox("This is a popup!")
end
--Register an animated expression listener,execute the above function when the event occurs
ScriptSupportEvent:registerEvent([=[Player.PlayAction]=],Player_PlayAction)
Last Update: 6/11/2020, 9:30:46 PM