Lua plugin documentation
API
The following section describes the API that is available for piepan Lua scripts.
piepan is built using the gumble library. Documentation for types not part of piepan itself (including User and Channel) can be found in the gumble documentation.
piepan.Audio
void Play(table obj)
: Plays the media file obj.filename
. obj.callback
can be defined as a function that is called after the playback has completed.
VoiceTarget
NewTarget(int id)
: Create a new voice target object.
void SetTarget(VoiceTarget target)
sets the target of subsequent piepan.Audio.Play()
calls. Call this function with no arguments to remove any voice targeting.
void Stop()
: Stops the currently playing stream.
bool IsPlaying()
: Returns true if an stream is currently playing, false otherwise.
int Bitrate()
: Returns the bitrate of the audio encoder.
void SetBitrate(int bitrate)
: Sets the bitrate of the audio encoder. Calling this function will override the automatically-configured, optimal bitrate.
float Volume()
: Returns the audio volume.
void SetVolume(float volume)
: Sets the volume of transmitted audio (default: 1.0).
Object that contains all of the channels that are on the server. The channels are mapped by their channel IDs. piepan.Channels[0]
is the server's root channel.
piepan.Disconnect()
Disconnects from the server.
piepan.On(string event, function callback)
Registers an event listener for a given event type. The follow events are currently supported:
connect
(Arguments: ConnectEvent event
)
- Called when connection to the server has been made. This is where a script should perform its initialization.
disconnect
(Arguments: DisconnectEvent event
)
- Called when connection to the server has been lost or after
piepan.Disconnect()
is called.
message
(Arguments: TextMessageEvent event
)
- Called when a text message is received.
userChange
(Arguments: UserChangeEvent event
)
- Called when a user's properties changes (e.g. connects to the server).
channelChange
(Arguments: ChannelChangeEvent event
)
- Called when a channel changes state (e.g. is added or removed).
permissionDenied
(Arguments: PermissionDeniedEvent event
)
- Called when a requested action could not be performed.
Note: events with a Type
field have slight changes than what is documented in gumble:
- The
Type
field is changed to a number.
- Individual bit flag values are added to the event as booleans prefixed with
Is
DisconnectEvent
IsError
IsUser
IsOther
IsVersion
IsUserName
IsUserCredentials
IsServerPassword
IsUsernameInUse
IsServerFull
IsNoCertificate
IsAuthenticatorFail
UserChangeEvent
IsConnected
IsDisconnected
IsKicked
IsBanned
IsRegistered
IsUnregistered
IsChangeName
IsChangeChannel
IsChangeComment
IsChangeAudio
IsChangeTexture
IsChangePrioritySpeaker
IsChangeRecording
ChannelChangeEvent
IsCreated
IsRemoved
IsMoved
IsChangeName
IsChangeDescription
IsChangePosition
PermissionDeniedEvent
IsOther
IsPermission
IsSuperUser
IsInvalidChannelName
IsTextTooLong
IsTemporaryChannel
IsMissingCertificate
IsInvalidUserName
IsChannelFull
IsNestingLimit
piepan.Process
-
piepan.Process New(function callback, string command, string arguments...)
: Executes command
in a new process with the given arguments. The function callback
is executed once the process has completed, passing if the execution was successful and the contents of standard output.
-
void Kill()
: Kills the process.
User
piepan.Self
The User
object that references yourself.
piepan.Timer
-
piepan.Timer New(function callback, int timeout)
: Creates a new timer. After at least timeout
milliseconds, callback
will be executed.
-
void Cancel()
: Cancels the timer.
Users
piepan.Users
Object containing each connected user on the server, with the keys being the session ID of the user and the value being their corresponding piepan.User
table.