SpawnMonster: Difference between revisions
Jump to navigation
Jump to search
Update Lua API reference |
Complete Lua function catalog |
||
| Line 43: | Line 43: | ||
* See [[Monster type catalog]] for every currently supported type key. | * See [[Monster type catalog]] for every currently supported type key. | ||
[[Category:Lua Functions]] | |||
[[Category:Server Functions]] | [[Category:Server Functions]] | ||
[[Category:World Functions]] | [[Category:World Functions]] | ||
[[Category:Monster Functions]] | [[Category:Monster Functions]] | ||
Revision as of 09:55, 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.