Permalink
4661d44 Dec 6, 2016
@pgilmorepf @mroberti
117 lines (100 sloc) 5.6 KB

Corona builds for LuaSdk

The Corona plugin files are available for free on the Corona marketplace. (PlayFab subscription fees still apply when relevant)

Client Plugin Instructions:

  • Add the following to your build.settings:
plugins = {
  ["plugin.playfab.client"] = { publisherId = "com.playfab" }
}
  • Here is a main.lua script for your Corona game project which will log in to PlayFab, and print the result to the console
local pfClient = require("plugin.playfab.client")
local PlayFabClientApi = pfClient.PlayFabClientApi
PlayFabClientApi.settings.titleId = "<your-title-id>"

local loginRequest = {
    -- https://api.playfab.com/Documentation/Client/method/LoginWithCustomID
    CustomId = "TestCustomId",
    CreateAccount = true
}
PlayFabClientApi.LoginWithCustomID(loginRequest, function(result) print("Login Successful: " .. result.PlayFabId) end, function(error) print("Login Failed: " .. error.errorMessage) end)

-- After login, the full client API will fuction properly
-- PlayFabClientApi.GetTitleData( etc etc etc )
-- Try linking more api calls to buttons and game events!
  • All API methods follow the same signature: PlayFabClientApi.<ApiName>(request, function(result) end, function(error) end)
  • You can see a list of all available client APIs methods

Server Plugin Instructions:

  • Add the following to your build.settings:
plugins = {
  ["plugin.playfab.server"] = { publisherId = "com.playfab" }
}
  • Here is a main.lua script for your Corona game-server project which will log in to PlayFab, and print the result to the console
local pfServer = require("plugin.playfab.server")
local json = pfServer.json
local PlayFabServerApi = pfServer.PlayFabServerApi
PlayFabServerApi.settings.titleId = "<your-title-id>"
PlayFabServerApi.settings.devSecretKey = "<your-secret-key>"

local dataRequest = {} -- https://api.playfab.com/Documentation/Server/method/GetTitleData
PlayFabServerApi.GetTitleData(dataRequest, function(result) print("GetTitleData Successful: " .. json.encode(result.Data)) end, function(error) print("GetTitleData Failed: " .. error.errorMessage) end)

-- Many server APIs act on a PlayFabId, which is the ID that represents each player
-- Transmit this data from your client to your server
  • All API methods follow the same signature: PlayFabServerApi.<ApiName>(request, function(result) end, function(error) end)
  • You can see a list of all available server APIs methods

Combo Plugin Instructions:

  • Add the following to your build.settings:
plugins = {
  ["plugin.playfab.combo"] = { publisherId = "com.playfab" }
}
  • Here is a main.lua script for your Corona game project which will log in to PlayFab via the client, and get the titleId as a server, and print the results to the console
local pfCombo = require("plugin.playfab.combo")
local json = pfCombo.json
local PlayFabClientApi = pfCombo.PlayFabClientApi
local PlayFabServerApi = pfCombo.PlayFabServerApi
PlayFabClientApi.settings.titleId = "<your-title-id>"
PlayFabServerApi.settings.devSecretKey = "<your-secret-key>"

local loginRequest = {
    -- https://api.playfab.com/Documentation/Client/method/LoginWithCustomID
    CustomId = "TestCustomId",
    CreateAccount = true
}
PlayFabClientApi.LoginWithCustomID(loginRequest, function(result) print("Login Successful: " .. result.PlayFabId) end, function(error) print("Login Failed: " .. error.errorMessage) end)

local dataRequest = {} -- https://api.playfab.com/Documentation/Server/method/GetTitleData
PlayFabServerApi.GetTitleData(dataRequest, function(result) print("GetTitleData Successful: " .. json.encode(result.Data)) end, function(error) print("GetTitleData Failed: " .. error.errorMessage) end)


-- After login, the full client API will fuction properly
-- PlayFabClientApi.GetTitleData( etc etc etc )
-- Try linking more api calls to buttons and game events!