PlayFab Lua SDK for LuaDist command-line, Defold, and more
This is a community supported SDK.
For new and existing users, you can use the current version as it is. The team at Microsoft would no longer be providing official support for those using this SDK. You can continue to get community support and updates at PlayFab forums.
We are currently looking for reliable community partners to provide long-term support for this SDK. If you are interested to take ownership and provide future maintenance, let us know.
What you have to do:
We're excited to hear from you. Thank you for your support and happy coding.
The PlayFab LuaSdk includes the files needed to make PlayFab HTTPS API calls within a Lua Project.
Current supported platforms:
To connect to the PlayFab service, your machine must be running TLS v1.2 or better.
local json = require("PlayFab.json")
local PlayFabClientApi = require("PlayFab.PlayFabClientApi")
-- Always set your titleId first, before making any API calls
PlayFabClientApi.settings.titleId = nil -- TODO: Set this to your string titleId you created on PlayFab Game Manager website
-- After the above setup is complete, you can make a Login API call
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 )
Alternately, from the console, you can run the playfab API tests by runing the following console command from windows (Lua.exe must be in your path environment variable):
lua PlayFabTesting/TestPlayFabConsole.lua
local PlayFabClientApi = require("PlayFab.PlayFabClientApi")
local IPlayFabHttps = require("PlayFab.IPlayFabHttps")
local PlayFabHttps_Defold = require("PlayFab.PlayFabHttps_Defold")
IPlayFabHttps.SetHttp(PlayFabHttps_Defold) -- The auto import magic doens't work if you set the name, so you have to set the reference
PlayFabClientApi.settings.titleId = "6195"
function init(self)
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)
end
-- After login, the full client API will fuction properly
-- PlayFabClientApi.GetTitleData( etc etc etc )
-- Try linking more api calls to buttons!
For a complete list of available APIs, check out the online documentation.
We love to hear from our developer community! Do you have ideas on how we can make our products and services better?
Our Developer Success Team can assist with answering any questions as well as process any feedback you have about PlayFab services.
Forums, Support and Knowledge Base
Apache License -- Version 2.0, August 2016 http://www.apache.org/licenses/ Full details available within the LICENSE file.