SpawnItem: Difference between revisions

From Wiki G1R-MP G1 Remake Multiplayer
Jump to navigation Jump to search
Document Lua functions planned for G1R:MP update 0.1.2
 
Document Lua APIs available or improved from G1R:MP 0.1.2
Line 1: Line 1:
= spawnItem =
= spawnItem =
<div style="background:#0b0b0b; border:1px solid #d13b3b; border-left:5px solid #d13b3b; color:#f1f1f1; padding:0.85rem 1rem; margin:0.75rem 0 1rem;">
<div style="background:#fff5f5; border:1px solid #d13b3b; border-left:5px solid #d13b3b; color:#111111; padding:0.85rem 1rem; margin:0.75rem 0 1rem;">
<div style="color:#ff5a5a; font-weight:bold; letter-spacing:0.04em;">COMING IN UPDATE 0.1.2</div>
<div style="color:#111111; font-weight:bold; letter-spacing:0.04em;">AVAILABLE FROM UPDATE 0.1.2</div>
<div style="color:#f1f1f1; margin-top:0.25rem;">This function is documented in advance and is not yet available in the current public release.</div>
<div style="color:#111111; margin-top:0.25rem;">This function is available in G1R:MP 0.1.2 and later. The contract below includes the compatibility guarantees introduced in that update.</div>
</div>
</div>



Revision as of 18:40, 3 September 2026

spawnItem

AVAILABLE FROM UPDATE 0.1.2
This function is available in G1R:MP 0.1.2 and later. The contract below includes the compatibility guarantees introduced in that update.

Spawns an allowlisted synchronized pickup near a player.

Syntax

bool spawnItem(int playerId, string itemKey [, number heightOffset])

Parameters

Name Type Required Description
playerId int yes The connected player identifier.
itemKey string yes A verified public world-item key or inventory key from the server catalog allowlist, for example apple or itfo_apple.
heightOffset number no Optional finite vertical offset in metres from -100 through 100. Values outside this range are rejected. Omit it to request ground snapping; an explicit 0 keeps the player's snapshot height without ground snapping.

Returns

Returns true after the server accepts and creates the item; otherwise returns false.

Examples

Example 1

Spawn an allowlisted apple near the invoking player:

addCommandHandler("spawnitem", function(playerId)
    if not spawnItem(playerId, "itfo_apple") then
        outputChatBox("The item could not be spawned.", playerId)
    end
end)

Example 2

Spawn other verified food, weapon, and rune entries:

spawnItem(playerId, "ItFo_Loaf")
spawnItem(playerId, "ItMw_1H_Axe_01")
spawnItem(playerId, "ItAr_Rune_FireBolt")

Notes

  • Available only in server-side resource scripts.
  • Each accepted call spawns exactly one item 0.7 metres in front of the player's latest replicated position and facing direction.
  • The update 0.1.2 catalog contains 681 structurally verified world-item entries. Item codes are case-insensitive; the server canonicalizes every accepted value before replication.
  • The Gothic Remake item-code reference is useful when looking up candidate codes. A code is spawnable only when it also exists in the current server catalog; unsupported codes return false.
  • The server owns the item identity, revision, visibility, pickup validation, inventory award, and late-join state.
  • Only entries mapped by the verified world-item catalog may be spawned; arbitrary asset names and paths are rejected.