Legacy Reference

Using Entity Slots

CryLua is deprecated and will be removed in a future version of Lumberyard.


This page contains information on using Lua scripting to work with the legacy Entity system. These Lua scripts use the legacy script context.

Starting with Lumberyard 1.8, Lua scripts use the newbehavior context. that replaces the legacy script context.

Scripts that were written before the integration of the behavior context no longer work in Lumberyard versions 1.8 and later. For information on updating Lua code from legacy script context to the new behavior context, see the migration notes for Lumberyard 1.8.

For information on using Lua with Lumberyard's new component entity system, see Writing Lua Scripts for the Component Entity System.

Each entity can have slots that are used to hold different resources available in Lumberyard. This topic describes how to work with entity slots.

Allocating a Slot

The following table lists the resources that can be allocated in a slot, along with the ScriptBind function used to allocate it.

Lumberyard resource Function
static geometry LoadObject() or LoadSubObject()
animated character LoadCharacter()
particle emitter LoadParticleEffect()
light LoadLight()
cloud LoadCloud()
fog LoadFogVolume()
volume LoadVolumeObject()

Modifying Slot Parameters

Each of these resource may be moved, rotated, or scaled relative to the entity itself.

  • SetSlotPos()

  • GetSlotPos()

  • SetSlotAngles()

  • GetSlotAngles()

  • SetSlotScale()

  • GetSlotScale()

You can add a parenting link between the slots, making it possible to have related positions.

  • SetParentSlot()

  • GetParentSlot()

Slot Management

To determine whether or not a specified slot is allocated, call the function !IsSlotValid().

To free one slot, call !FreeSlot()

To free all allocated slots within the entity, call !FreeAllSlots().

Loading a Slot

The following example illustrates loading a slot in a script function.

local pos={x=0,y=0,z=0}; self:LoadObject(0,props.fileModel); self:SetSlotPos(0,pos); self:SetCurrentSlot(0);