building
building
Buildings in Stranded III are defined in def.building.* or embedded in entity definition tables under the building = { ... } key. They provide hooks to validate site placement, handle construction progress, and finalize building completion.
Overview
Hooks & Events (6)
| Hook Signature | Returns | Summary |
|---|---|---|
building:canBuild(x, y, z)
|
string|boolean
|
Validates whether building site can be placed at coordinates. |
building:isAvailable(player)
|
boolean
|
Checks if building recipe is unlocked and visible in construction menu. |
building:onCancel(siteEntity)
|
void
|
Triggered when building site is cancelled or dismantled. |
building:onFinish(siteEntity, finishedEntity)
|
void
|
Triggered when building construction finishes. |
building:onProgress(siteEntity, progress)
|
void
|
Triggered as construction progress increases. |
building:onStart(x, y, z)
|
boolean
|
Triggered when construction site marker is placed. |
Detailed Reference
building:canBuild(x, y, z)| Parameter | Type | Default | Description |
|---|---|---|---|
x | number | X position. | |
y | number | Y position. | |
z | number | Z position. |
string|booleanReturn an error message string or false to disallow construction.
Called during placement preview. Can return an error string to display in the HUD when placement is invalid.
building = {
canBuild = function(x, y, z)
if y < 0 then return "Cannot build underwater!" end
return true
end
}building:isAvailable(player)| Parameter | Type | Default | Description |
|---|---|---|---|
player | entity | The player checking recipes. |
booleanTrue if building option should appear in construction menu.
Controls recipe visibility in the building craft UI.
building:onCancel(siteEntity)| Parameter | Type | Default | Description |
|---|---|---|---|
siteEntity | entity | Cancelled site entity. |
Called when the player dismantles an unfinished building site.
building:onFinish(siteEntity, finishedEntity)| Parameter | Type | Default | Description |
|---|---|---|---|
siteEntity | entity | Completed site entity. | |
finishedEntity | entity | Finished building entity. |
Called when the building is completed and replaces the site marker.
building:onProgress(siteEntity, progress)| Parameter | Type | Default | Description |
|---|---|---|---|
siteEntity | entity | Construction site entity. | |
progress | number | Progress percentage (0.0 to 1.0). |
Called as materials are added to the site.
building:onStart(x, y, z)| Parameter | Type | Default | Description |
|---|---|---|---|
x | number | X position. | |
y | number | Y position. | |
z | number | Z position. |
booleanReturn true to cancel site creation.
Called when the player begins constructing the site.