SpawnMonster: Difference between revisions
Jump to navigation
Jump to search
Document upcoming 0.1.8 character dimensions: six server APIs, three events and creator guide; not a release announcement |
Release 0.1.8 / BUILD210 / Protocol 40: dimensions API availability, loading and UI fixes |
||
| Line 57: | Line 57: | ||
<!-- dimensions018:start --> | <!-- dimensions018:start --> | ||
== Direct private spawn ( | == Direct private spawn (since 0.1.8) == | ||
The optional <code>options</code> table also accepts <code>dimension</code>, an integer number from 0 to 2147483647. Omitted means 0. Invalid values reject the spawn. This creates the actor directly in that dimension, avoiding temporary public exposure before a setter. All other spawn/type/placement validation remains active | The optional <code>options</code> table also accepts <code>dimension</code>, an integer number from 0 to 2147483647. Omitted means 0. Invalid values reject the spawn. This creates the actor directly in that dimension, avoiding temporary public exposure before a setter. All other spawn/type/placement validation remains active. | ||
See [[Character dimensions]] for examples and [[setMonsterDimension]] for moving an existing owned actor. | See [[Character dimensions]] for examples and [[setMonsterDimension]] for moving an existing owned actor. | ||
<!-- dimensions018:end --> | <!-- dimensions018:end --> | ||
Latest revision as of 21:03, 11 October 2026
spawnMonster
IMPROVED FROM UPDATE 0.1.2
This function is available in earlier releases and has corrected or expanded behavior in G1R:MP 0.1.2 and later. The contract below describes the updated behavior.
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. Set navigationCollisionMode to "combined", "builtin", or "custom"; the default is "combined".
|
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,
navigationCollisionMode = "combined",
})
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.
- The selected navigation collision mode is applied to initial placement. Pass it during spawn when replacing a known baked false positive with custom blockers.
- Spawning an unsupported type or exceeding the server monster limit returns false.
- See Monster type catalog for every currently supported type key.
Direct private spawn (since 0.1.8)
The optional options table also accepts dimension, an integer number from 0 to 2147483647. Omitted means 0. Invalid values reject the spawn. This creates the actor directly in that dimension, avoiding temporary public exposure before a setter. All other spawn/type/placement validation remains active.
See Character dimensions for examples and setMonsterDimension for moving an existing owned actor.