ifdef::env-github[]
:tip-caption: :bulb:
:note-caption: :information_source:
:important-caption: :heavy_exclamation_mark:
:caution-caption: :fire:
:warning-caption: :warning:
endif::[]
:toc: left
:toclevels: 5

= Home

This module adds a home system.

== Extension

=== Component

[source,lua]
----
self.slot 
self.id 
self.index 
self.cfg 
self.x 
self.y 
self.z 

-- called when the component is loaded for a specific slot
Component:load()

-- called when the component is unloaded from a specific slot
Component:unload()

-- called when a player enters the slot
Component:enter(user)

-- called when a player leaves the slot
Component:leave(user)
----

=== Slot

[source,lua]
----
self.type
self.id
self.owner_id -- character id
self.home
self.number
self.users -- map of users
self.components -- map of index => component

Slot:isEmpty()
----

=== User

[source,lua]
----
self.home_slot
self.address

-- access a home by address
-- return true on success
User:accessHome(home, number)

User:leaveHome()

-- check if inside a home
User:inHome()
----

=== Server

[source,lua]
----
self.cfg
self.components
self.slots -- map of type => map of slot id => slot instance

-- address access (online and offline characters)
-- return address or nil
Home:getAddress(cid)

-- return character id or nil
Home:getByAddress(home,number)

-- find a free address number to buy
-- return number or nil if no numbers availables
Home:findFreeNumber(home,max)

-- register home component
-- id: unique component identifier (string)
-- component: Home.Component derived class
Home:registerComponent(component)

-- SLOTS

-- get slot instance
-- return slot or nil
Home:getSlot(stype, sid)

-- get slot instance by address
-- return slot or nil
Home:getSlotByAddress(home, number)

-- return sid or nil
Home:findFreeSlot(stype)
----

.Events
[horizontal]
`characterAddressUpdate(user)`:: called when the address is updated (load, buy, sell...)

== Menu

=== home

Home menu (outside).

.data
[horizontal]
name:: home name

=== home:component:entry

Home entry menu (inside).

.data
[horizontal]
slot:: component slot

== Home component

=== entry

Home entry component.

== Permission

=== home

Home/address check.

`!home[.<name>[.<number>]]`

[horizontal]
name:: (optional) home name, all `.` characters should be removed
number:: (optional) home number

.Example
[horizontal]
`!home`:: has a home
`!home.HLM Vinewood`:: lives at `HLM Vinewood`
`!home.HLM Vinewood.5`:: lives at `5, HLM Vinewood`
