Skip to content

Filtering packets with the Lua API

Aleksi edited this page Aug 23, 2020 · 2 revisions

Sala has support for simple Lua filters. When looking at a list of captured packets, go to View -> Apply filter and type in your filter script. The script should receive a Packet as a variadic argument and return a boolean indicating whether the packet passes the filter. Packet has the following members:

Packet.Type

The packet's packet type (for example, 0x83 or 0x15). See Packet types for a list of packet types.

Packet:HasSubpacket(subpacket_type uint8)

Returns true if Packet is a 0x83 packet containing a subpacket with type subpacket_type. See Packet types for a list of subpacket types (under ID_DATA).

Packet:ReferencesInstance(peer_id uint32, id uint32, ref_type_filter ?RefTypeFilter = (any))

Return true if Packet contains a reference to the instance given by peer_id and id. If ref_type_filter is provided, only the specified reference types are accepted. Otherwise all reference types are accepted.

The different reference type filters may be obtained by indexing the global variable InstRefType with the following indices:

  • Deletion
  • Creation
  • SetProperty
  • Event
  • Ack
  • InValue
  • AsParent
  • TopReplicated
  • PhysicsRoot
  • PhysicsChild
  • PhysicsPlatformChild
  • Touched
  • TouchEnded

Filters may be combined with + to construct a compound filter that includes packets that match at least one of the filters. For example: InstRefType.Deletion + InstRefType.Event.

Examples

Match all ID_TOUCH packets

local packet = ...

return packet.Type == 0x86

Match all packets that have events

local packet = ...

return packet:HasSubpacket(7)

Match all packets that reference RBXPID1_1337

local packet = ...

return packet:ReferencesInstance(1, 1337)

Match all packets that set properties or send events on RBXPID1_1337

local packet = ...

return packet:ReferencesInstance(1, 1337, InstRefType.SetProperty + InstRefType.Event)
Clone this wiki locally