-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.lua
More file actions
46 lines (36 loc) · 1.32 KB
/
test.lua
File metadata and controls
46 lines (36 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
--[[=============================================--
-- test.lua
-- Sample script to demo the library with
-- CoroWrap usage.
--
-- Expected output of this script is:
-- Login Successful: B110DCFCEE5F14D0
-- SomeKey: NewValue
-- LiveOpsStore: LiveOpsStore1
-- PlayFab: {"Status": "Awesome"}
--
-- Author: Lyrthras
--=============================================]]--
local CoroWrap = require 'PlayFab/CoroWrap'
local PlayFabClientApi = CoroWrap(require 'PlayFab/PlayFabClientApi')
-- Always set your titleId first, before making any API calls
PlayFabClientApi.settings.titleId = "6195" -- 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
}
local res, err = PlayFabClientApi.LoginWithCustomID(loginRequest)
if err then
error("Login Failed: " .. err.errorMessage)
end
print("Login Successful: " .. res.PlayFabId)
-- After login, the full client API will fuction properly
res, err = PlayFabClientApi.GetTitleData({})
if err then
error("GetTitleData Failed: " .. err.errorMessage)
end
for key, value in pairs(res.Data) do
print(" "..key..":\t"..value)
end