# Scripting

### Script Structure

> > #### _onThink(monster, interval)_
> >
> > **Parameters**:
> >
> > * **monster**: Monster that is thinking.
> > * **interval**: Interval for each think execution (1000ms)
> >
> > **Return Value**:
> >
> > * None
> >
> > **Example**:
> >
> > ```lua
> > function onThink(monster, interval)
> >     print("I'm thinking")
> > end
> > ```
>
> > #### _onAppear(monster, creature)_
> >
> > **Parameters**:
> >
> > * **monster**: Monster that witnessed the appearance of the creature.
> > * **creature**: Creature that has appeared into the monster's view.
> >
> > **Return Value**:
> >
> > * None
> >
> > **Example**:
> >
> > ```lua
> > function onAppear(monster, creature)
> >     if monster:getId() == creature:getId() then
> >         print(monster:getId(), creature:getId())
> >     end
> > end
> > ```
>
> > #### _onDisappear(monster, creature)_
> >
> > **Parameters**:
> >
> > * **monster**: Monster that witnessed the disappearance of the creature.
> > * **creature**: Creature that has disappeared from the monster's view.
> >
> > **Return Value**:
> >
> > * None
> >
> > **Example**:
> >
> > ```lua
> > function onDisappear(monster, creature)
> >     if monster:getId() == creature:getId() then
> >         print(monster:getId(), creature:getId())
> >     end
> > end
> > ```
>
> > #### _onMove(monster, creature, fromPosition, toPosition)_
> >
> > **Parameters**:
> >
> > * **monster**: Monster watching the creature move.
> > * **creature**: Creature that is moving.
> > * **fromPosition**: Position the creature is moving from.
> > * **toPosition**: Position the creature is moving to.
> >
> > **Return Value**:
> >
> > * None
> >
> > **Example**:
> >
> > ```lua
> > function onMove(monster, creature, fromPosition, toPosition)
> >     if monster:getId() == creature:getId() then
> >         print(monster:getId(), creature:getId(), fromPosition, toPosition)
> >     end
> > end
> > ```
>
> > #### _onSay(monster, creature, type, message)_
> >
> > **Parameters**:
> >
> > * monster: Monster seeing the message.
> > * creature: Creature saying the message.
> > * type: Message type (Type list can be found [Here](https://github.com/otland/forgottenserver/blob/d342e499429ec3204edd2af2d621b8430576f276/src/const.h#L180-L196))
> > * message: Message sent by the creature.
> >
> > **Return Value**:
> >
> > * None
> >
> > **Example**:
> >
> > ```lua
> > function onSay(monster, creature, type, message)
> >     print(monster:getId(), creature:getId(), type, message)
> > end
> > ```
