Tutorial for Photon Cloud

I am looking for a tutorial for a game like pong using Photon Cloud. The two simple and advanced files provided are neat but they lack comments for me to understand exactly what is going on. A tutorial like pong with four objects on the screen is not overly complex and not to simple and I think it would help a lot of people like myself who have never developed any multiplayer games etc.

Thanks

David G

For now the samples are all we have for LUA. In the end the flow is simple

  • connect

  • join room

  • raise events (reliable or unreliable), put data you want to send around

Our samples show this and the code should be self explaining.

Chris

For now the samples are all we have for LUA. In the end the flow is simple

  • connect

  • join room

  • raise events (reliable or unreliable), put data you want to send around

Our samples show this and the code should be self explaining.

Chris

How can I get all players info (either in lobby or in a room) when I first connect to a lobby?

Thanks

When joined to room, detailed info on all actors in the room available from actors list: client:myRoomActors():

for actorNr, actor in pairs(client:myRoomActors()) do print(actor.name, actor.actorNr, actor:getCustomProperty("prop1"), actor:getCustomProperty("prop2") ) end

While client is connected to master server, general statistics for lobbies available: peers connected count and games count.

Use client:requestLobbyStats() to query stats and implement client:onLobbyStats() to handle response:

function client:onLobbyStats(errorCode, errorMsg, lobbies) if lobbies then for \_, l in pairs(lobbies) do print(l.lobbyName, l.lobbyType, l.peerCount, l.gameCount) end end end

See also Photon Cloud lua api doc http://doc.exitgames.com/photon-cloud/api/lua/doc/

Thanks for your help.  I thought actor was a table object, but it is a class object so

print(json.decode(actor) didn’t work for my simple test.

I couldn’t open this link.  Is there anything wrong?

http://doc.exitgames.com/photon-cloud/api/lua/doc/

“The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.”

How can I get all players info (either in lobby or in a room) when I first connect to a lobby?

Thanks

When joined to room, detailed info on all actors in the room available from actors list: client:myRoomActors():

for actorNr, actor in pairs(client:myRoomActors()) do print(actor.name, actor.actorNr, actor:getCustomProperty("prop1"), actor:getCustomProperty("prop2") ) end

While client is connected to master server, general statistics for lobbies available: peers connected count and games count.

Use client:requestLobbyStats() to query stats and implement client:onLobbyStats() to handle response:

function client:onLobbyStats(errorCode, errorMsg, lobbies) if lobbies then for \_, l in pairs(lobbies) do print(l.lobbyName, l.lobbyType, l.peerCount, l.gameCount) end end end

See also Photon Cloud lua api doc http://doc.exitgames.com/photon-cloud/api/lua/doc/

Thanks for your help.  I thought actor was a table object, but it is a class object so

print(json.decode(actor) didn’t work for my simple test.

I couldn’t open this link.  Is there anything wrong?

http://doc.exitgames.com/photon-cloud/api/lua/doc/

“The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.”

I really think this module is lacking a tutorial. I’ve read through the example code, but it’s bloated with code specific to the “games” in the example. Perhaps I’m lacking the initial knowledge I require to begin working with Photon. 

For me, I’d love a tutorial that showed you step by step what’s needed.

Saying this:

  • connect

  • join room

  • raise events (reliable or unreliable), put data you want to send around

Is like saying:

dqSGYmk.jpg

(sorry for the language )

It would be great if someone could compile a pong tutorial or something similar.

Thanks!

We are working hard to enhance the samples - see below for some code snippets you asked for:

Basic operations are covered here: http://doc-api.exitgames.com/lua/samples/corona-plugin/photon_corona_plugin_sample.zip

  1. create loadbalancing client: 

    local photon = require “plugin.photon” local LoadBalancingClient = photon.loadbalancing.LoadBalancingClient local client = LoadBalancingClient.new(appInfo.MasterAddress, appInfo.AppId, appInfo.AppVersion) 

  2. override methods to handle events, responses and state change:

    function client:onStateChange(state) if state == LoadBalancingClient.State.JoinedLobby then – join or create room here self:joinRandomRoom() – self:joinRoom(“helloworld”) – self:createRoom(“helloworld”) end end function client:onEvent(code, content, actorNr) if code == EVENT_CODE then – handle event, e.g. sync with other client end end

  3. connect to server and run game loop with ‘service’ calls:

    client:connect() function client:timer(event) self:service() – game logic end timer.performWithDelay( 100, client, 0)

  4. send events to other clients somewhere inside game logic or handler:

    local data = {x = 1, y = “bla”} self:raiseEvent(EVENT_CODE, data) – reliable by default – self:raiseEvent(EVENT_CODE, data, {sendReliable = false }) – unreliable

I really think this module is lacking a tutorial. I’ve read through the example code, but it’s bloated with code specific to the “games” in the example. Perhaps I’m lacking the initial knowledge I require to begin working with Photon. 

For me, I’d love a tutorial that showed you step by step what’s needed.

Saying this:

  • connect

  • join room

  • raise events (reliable or unreliable), put data you want to send around

Is like saying:

dqSGYmk.jpg

(sorry for the language )

It would be great if someone could compile a pong tutorial or something similar.

Thanks!

We are working hard to enhance the samples - see below for some code snippets you asked for:

Basic operations are covered here: http://doc-api.exitgames.com/lua/samples/corona-plugin/photon_corona_plugin_sample.zip

  1. create loadbalancing client: 

    local photon = require “plugin.photon” local LoadBalancingClient = photon.loadbalancing.LoadBalancingClient local client = LoadBalancingClient.new(appInfo.MasterAddress, appInfo.AppId, appInfo.AppVersion) 

  2. override methods to handle events, responses and state change:

    function client:onStateChange(state) if state == LoadBalancingClient.State.JoinedLobby then – join or create room here self:joinRandomRoom() – self:joinRoom(“helloworld”) – self:createRoom(“helloworld”) end end function client:onEvent(code, content, actorNr) if code == EVENT_CODE then – handle event, e.g. sync with other client end end

  3. connect to server and run game loop with ‘service’ calls:

    client:connect() function client:timer(event) self:service() – game logic end timer.performWithDelay( 100, client, 0)

  4. send events to other clients somewhere inside game logic or handler:

    local data = {x = 1, y = “bla”} self:raiseEvent(EVENT_CODE, data) – reliable by default – self:raiseEvent(EVENT_CODE, data, {sendReliable = false }) – unreliable