> For the complete documentation index, see [llms.txt](https://stigmax.gitbook.io/tfs-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stigmax.gitbook.io/tfs-guide/interface-chatchannels/channel-scripting.md).

# Scripting

### Structure

> > #### *canJoin(player)*
> >
> > **Parameters**:
> >
> > * player: Player attempting to join the channel.
> >
> > **Return Value**:
> >
> > * **true**: Player will be allowed to join the channel.
> > * **false**: Player will not be allowed to join the channel.
>
> > #### *onSpeak(player, type, message)*
> >
> > **Parameters**:
> >
> > * **player**: Player who is speaking.
> > * **type**: Talk type (SpeakClasses enum in const.h).
> > * **message**: Message being sent to the channel.
> >
> > **Return Value**:
> >
> > * Talk type (SpeakClasses enum in const.h)
> > * > TALKTYPE\_SAY
> >   >
> >   > TALKTYPE\_WHISPER
> >   >
> >   > TALKTYPE\_YELL
> >   >
> >   > TALKTYPE\_PRIVATE\_FROM
> >   >
> >   > TALKTYPE\_PRIVATE\_TO
> >   >
> >   > TALKTYPE\_CHANNEL\_Y
> >   >
> >   > TALKTYPE\_CHANNEL\_O
> >   >
> >   > TALKTYPE\_PRIVATE\_NP
> >   >
> >   > TALKTYPE\_PRIVATE\_PN
> >   >
> >   > TALKTYPE\_BROADCAST
> >   >
> >   > TALKTYPE\_CHANNEL\_R1
> >   >
> >   > TALKTYPE\_PRIVATE\_RED\_FROM
> >   >
> >   > TALKTYPE\_PRIVATE\_RED\_TO
> >   >
> >   > TALKTYPE\_MONSTER\_SAY
> >   >
> >   > TALKTYPE\_MONSTER\_YELL
> >   >
> >   > TALKTYPE\_CHANNEL\_R2

### Example

```lua
function canJoin(player)
	return player:getName() == "Delusion"
end

function onSpeak(player, type, message)
	-- Force orange messages no matter what in the channel
	return TALKTYPE_CHANNEL_O
end
```
