SpawnMonster: Difference between revisions
Jump to navigation
Jump to search
Document server-owned monsters and interactions |
Update Lua API reference |
||
| Line 12: | Line 12: | ||
! Name !! Type !! Required !! Description | ! Name !! Type !! Required !! Description | ||
|- | |- | ||
| <code>type</code> || <code>string</code> || yes || | | <code>type</code> || <code>string</code> || yes || A stable type key from [[Monster type catalog]]. | ||
|- | |- | ||
| <code>x</code> || <code>number</code> || yes || World X coordinate in metres. | | <code>x</code> || <code>number</code> || yes || World X coordinate in metres. | ||
| Line 41: | Line 41: | ||
* The server owns identity, AI state, targeting, health, damage, relevance, and late-join replication. | * The server owns identity, AI state, targeting, health, damage, relevance, and late-join replication. | ||
* Spawning an unsupported type or exceeding the server monster limit returns false. | * Spawning an unsupported type or exceeding the server monster limit returns false. | ||
* See [[Monster type catalog]] for every currently supported type key. | |||
[[Category:Server Functions]] | [[Category:Server Functions]] | ||
[[Category:World Functions]] | [[Category:World Functions]] | ||
[[Category:Monster Functions]] | [[Category:Monster Functions]] | ||
Revision as of 09:49, 15 August 2026
spawnMonster
Creates a server-owned monster and replicates it to interested players.
Syntax
string|false spawnMonster(string type, number x, number y, number z [, number yaw = 0] [, table options])
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
type |
string |
yes | A stable type key from Monster type catalog. |
x |
number |
yes | World X coordinate in metres. |
y |
number |
yes | World Y coordinate in metres. |
z |
number |
yes | World Z coordinate in metres. |
yaw |
number |
no | Initial yaw in degrees. |
options |
table |
no | Optional table. Set aggressive to false to create a passive monster.
|
Returns
Returns the new opaque monster identifier string, or false when validation or spawning fails.
Examples
Spawn a passive scavenger:
local monsterId = spawnMonster("scavenger", 15.0, -4.5, 2.0, 90, { aggressive = false })
if monsterId then
outputDebugString("Spawned monster " .. monsterId)
end
Notes
- Available only in server-side resource scripts.
- The server owns identity, AI state, targeting, health, damage, relevance, and late-join replication.
- Spawning an unsupported type or exceeding the server monster limit returns false.
- See Monster type catalog for every currently supported type key.