Photon Lua (Corona) Client API

Module loadbalancing.Actor

Summarizes a "player" within a room, identified (in that room) by ID (or "actorNr").

To implement custom logic customize default Actor instance with initActor function passed to LoadBalancingClient.new.

Functions

instance:getRoom () Actor's room: the room initialized by client for create room operation or room client connected to.
instance:raiseEvent (eventCode, data, options) Raises game custom event.
instance:setName (name) Sets actor name.
instance:onPropertiesChange (changedCustomProps, byClient) Called on every actor properties update: properties set by client, poperties update from server.
instance:getCustomProperty (name) Returns custom property by name.
instance:getCustomPropertyOrElse (name, defaultValue) Returns custom property by name or default value.
instance:setCustomProperty (name, value, forward) Sets custom property.
instance:setCustomProperties (properties, forward) Sets custom properties.
instance:isSuspended () Returns true if actor is in suspended state.


Functions

instance:getRoom ()
Actor's room: the room initialized by client for create room operation or room client connected to.

Returns:

    loadbalancing.Room Actor's room.
instance:raiseEvent (eventCode, data, options)
Raises game custom event.

Parameters:

  • eventCode byte Identifies this type of event (and the content). Your game's event codes can start with 0.
  • data optional table Custom data you want to send along (use nil, if none).
  • options optional table Additional options:

    interestGroup: (byte) The ID of the interest group this event goes to (exclusively).

    cache: (constants.EventCaching) Events can be cached (merged and removed) for players joining later on. Default is EventCaching.DoNotCache

    receivers: (constants.ReceiverGroup) Defines to which group of players the event is passed on. Default is ReceiverGroup.Others

    targetActors: (int array) Defines the target players who should receive the event (use only for small target groups).

    sendReliable: (boolean) Default is true. Guarantees event delivery (event repeated if it's lost). Set to false if the event is replaced by a newer rapidly.

    channelId: (byte) Default is 0. The "channel" to which this event should belong. Per channel, the sequence is kept in order.

instance:setName (name)
Sets actor name.

Parameters:

instance:onPropertiesChange (changedCustomProps, byClient)
Called on every actor properties update: properties set by client, poperties update from server. Override to update custom actor state.

Parameters:

  • changedCustomProps table Key-value map of changed properties.
  • byClient boolean true if properties set by client.
instance:getCustomProperty (name)
Returns custom property by name.

Parameters:

  • name string Name of the property.

Returns:

    Property or nil if property not found.
instance:getCustomPropertyOrElse (name, defaultValue)
Returns custom property by name or default value.

Parameters:

  • name string Name of the property.
  • defaultValue Default property value.

Returns:

    Property or default value if property not found.
instance:setCustomProperty (name, value, forward)
Sets custom property.

Parameters:

  • name string Name of the property.
  • value Property value. Pass nil to remove property.
  • forward boolean Forward to web hook.
instance:setCustomProperties (properties, forward)
Sets custom properties.

Parameters:

  • properties table Table of properties to set.
  • forward boolean Forward to web hook.
instance:isSuspended ()
Returns true if actor is in suspended state.

Returns:

    boolean Actor suspend state.
generated by LDoc 1.3