Skip to content

Game Client Usage

Require the Plugin

--Require the Coronium Ace plugin
local ace = require("plugin.ace")

Configure Ace

--Configure Coronium Ace
ace.config({
  api_key = "<ace-client-api-key>",
  game_key = "<ace-game-api-key>"
})

You can find the game_key listed on the Game module "game card" for your game (click here for details).

The api_key can be found in your account "Settings" by clicking on your username found in the upper right of the web based admin.

Set Game Handler

The following shows all available event types. Not all event types are required. See the Events section for detailed information on each event type.

local function GameHandler(event)

  local etype = event.type

  --==========================================================================
  --== Game Init (Server: ace.hook.GameInit)
  --==========================================================================  
  if etype == ace.GAMEINIT then
    print("gameinit")
  --==========================================================================
  --== Game Ready
  --========================================================================== 
  elseif etype == ace.GAMEREADY then
    print("gameready")
  --==========================================================================
  --== Game State (Server: ace.gameSync)
  --========================================================================== 
  elseif etype == ace.GAMESTATE then
    print("gamestate")
  --==========================================================================
  --== Game Timeout
  --========================================================================== 
  elseif etype == ace.GAMETIMEOUT then
    print("gametimeout")
  --==========================================================================
  --== Game Over (Server: ace.gameOver)
  --========================================================================== 
  elseif etype == ace.GAMEOVER then
    print("gameover")
  --==========================================================================
  --== Game Close (Server: ace.gameClose)
  --========================================================================== 
  elseif etype == ace.GAMECLOSE then
    print("gameclose")
  --==========================================================================
  --== Player State
  --========================================================================== 
  elseif etype == ace.PLAYERSTATE then
    print("playerstate")
  --==========================================================================
  --== Player Left
  --========================================================================== 
  elseif etype == ace.PLAYERLEFT then
    print("playerleft")
  --==========================================================================
  --== Player Matchup Timeout
  --========================================================================== 
  elseif etype == ace.MATCHTIMEOUT then
    print("matchtimeout")
  --==========================================================================
  --== Move Timer Start
  --========================================================================== 
  elseif etype == ace.MOVESTART then
    print("movestart", event.tick)
  --==========================================================================
  --== Move Timer Updated
  --========================================================================== 
  elseif etype == ace.MOVETICK then
    print("movetick", event.tick)
  --==========================================================================
  --== Move Timer Expired
  --========================================================================== 
  elseif etype == ace.MOVETIMEOUT then
    print("movetimeout", event.tick)
  --==========================================================================
  --== Message (Server: ace.message)
  --========================================================================== 
  elseif etype == ace.MESSAGE then
    print("message")
  --==========================================================================
  --== Connected
  --==========================================================================  
  elseif etype == ace.CONNECT then
    print("connected")
  --==========================================================================
  --== Disconnected
  --========================================================================== 
  elseif etype == ace.DISCONNECT then
    print("disconnect", event.reason)
  --==========================================================================
  --== Error
  --========================================================================== 
  elseif etype == ace.ERROR then
    print("error", event.reason)
  end
end

ace.addEventListener(ace.EVENT, GameHandler)

Connect To Server

ace.connect()