Lua API/Entity
Материал из CryWiki Russia
Содержание |
Overview
CryEngine supplies a number of Lua functions that operate on entities, defined in the Entity table. However, they are applied in object-oriented Lua fashion, i.e. called in the form: golfball:SetWorldPos({x=0,y=0,z=0});
Spawning & Deleting
To spawn en entity, call this:
- SpawnEntity(Spawn params)
- Spawns entity
To remove an entity from the system, simply call the following function:
- DeleteThis(entity)
- Requests entity deletion
Class
Every entity has an entity class. This can be accessed from a member of the entity: class — The string class name of the entity
ID
Every entity has a globally unique ID, accessible as a member of the entity: id — The entity ID of the entity. This is Lua userdata, so to print it, you need to convert it to a string, e.g. tostring(self.id)
Lua bindings that take entities as parameters typically expect the entity ID, i.e. pass entity.id, not entity.
There is one special entity ID constant: NULL_ENTITY — ID for a null entity.
Names
Every entity has a string name.
- SetName — Set entity name to string name
- GetName — Get entity name (String)
- GetArchetype
- SetAIName
- GetAIName
Flags
Each entity has a set of bit flags controlling various aspects of the entity, e.g. whether it casts a shadow.
- SetFlags
- GetFlags
- HasFlags
Transform
You can set an entity’s position and orientation.
- ToLocal
- ToGlobal
- SetWorldPos
- SetWorldAngles
- SetWorldScale
- GetWorldPos
- GetWorldAngles
- GetWorldScale
- SetPos
- GetPos
- SetAngles
- GetAngles
- SetScale
- GetScale
- SetLocalPos
- SetLocalAngles
- SetLocalScale
- GetLocalPos
- GetLocalAngles
- GetLocalScale
- GetDirectionVector
- SetDirectionVector
- GetDistance
- GetBoneLocal
- IsEntityInside
Misc
- Activate
- ActivateOutput
- ActivatePlayerPhysics
- AddConstraint
- AddImpulse
- AttachChild
- AttachSurfaceEffect
- AwakeCharacterPhysics
- AwakeEnvironment
- AwakePhysics
- BreakToPieces
- CancelSubpipe
- CharacterUpdateAlways
- CharacterUpdateOnRender
- CheckCollisions
- CloneMaterial
- CopySlotTM
- CountLinks
- CreateBoneAttachment
- CreateCameraProxy
- CreateLink
- CreateSkinAttachment
- Damage
- DestroyAttachment
- DestroyPhysics
- DetachAll
- DetachThis
- DisableAnimationEvent
- DrawSlot
- EnableBoneAnimation
- EnableBoneAnimationAll
- EnableDecals
- EnableInheritXForm
- EnableMaterialLayer
- EnablePhysics
- EnableProceduralFacialAnimation
- FadeGlobalDensity
- ForceCharacterUpdate
- ForwardTriggerEventsTo
- FreeAllSlots
- FreeSlot
- GetAnimationLength
- GetAnimationTime
- GetAttachmentBone
- GetAttachmentCGF
- GetBoneAngularVelocity
- GetBoneDir
- GetBoneNameFromTable
- GetBonePos
- GetBoneVelocity
- GetCenterOfMassPos
- GetCharacter
- GetChild
- GetChildCount
- GetCurAnimation
- GetExplosionImpulse
- GetExplosionObstruction
- GetGravity
- GetHelperDir
- GetHelperPos
- GetLink
- GetLinkTarget
- GetLocalBBox
- GetLodRatio
- GetMass
- GetMaterial
- GetMaterialFloat
- GetMaterialVec3
- GetParent
- GetParentSlot
- GetPhysicalStats
- GetProjectedWorldBBox
- GetSlotAngles
- GetSlotCount
- GetSlotHelperPos
- GetSlotPos
- GetSlotScale
- GetSlotWorldDir
- GetSlotWorldPos
- GetSpeed
- GetState
- GetSubmergedVolume
- GetTouchedPoint
- GetTouchedSurfaceID
- GetTriggerBBox
- GetUpdateRadius
- GetVelocity
- GetViewDistRatio
- GetVolume
- GetWorldBBox
- GotoState
- Hide
- HideAllAttachments
- HideAttachment
- HideAttachmentMaster
- IgnorePhysicsUpdatesOnSlot
- InsertSubpipe
- IntersectRay
- InvalidateTrigger
- IsActive
- IsAnimationRunning
- IsColliding
- IsEntityInsideArea
- IsHidden
- IsInState
- IsPointInsideArea
- IsSlotCharacter
- IsSlotGeometry
- IsSlotLight
- IsSlotParticleEmitter
- IsSlotValid
- IsUsingPipe
- KillTimer
- LoadCharacter
- LoadCloud
- LoadFogVolume
- LoadLight
- LoadObject
- LoadObjectLattice
- LoadParticleEffect
- LoadSubObject
- LoadVolumeObject
- MaterialFlashInvoke
- MultiplyWithSlotTM
- NetPresent
- NoExplosionCollision
- PauseSound
- Physicalize
- PhysicalizeSlot
- PlayFacialAnimation
- PlaySound
- PlaySoundEvent
- PlaySoundEventEx
- PreLoadParticleEffect
- ProcessBroadcastEvent
- RagDollize
- RedirectAnimationToLayer0
- RemoveAllLinks
- RemoveDecals
- RemoveLink
- RenderShadow
- ReplaceMaterial
- ResetAnimation
- ResetAttachment
- ResetMaterial
- ResetPhysics
- SelectPipe
- SetAnimationBlendOut
- SetAnimationEvent
- SetAnimationFlip
- SetAnimationKeyEvent
- SetAnimationSpeed
- SetAnimationTime
- SetAttachmentAngles
- SetAttachmentCGF
- SetAttachmentDir
- SetAttachmentEffect
- SetAttachmentLight
- SetAttachmentObject
- SetAttachmentPos
- SetCharacterPhysicParams
- SetCloudMovementProperties
- SetColliderMode
- SetDefaultIdleAnimations
- SetLinkTarget
- SetLocalBBox
- SetLodRatio
- SetMaterial
- SetMaterialFloat
- SetMaterialVec3
- SetParentSlot
- SetPhysicParams
- SetPublicParam
- SetRegisterInSectors
- SetScriptUpdateRate
- SetSlotAngles
- SetSlotPos
- SetSlotScale
- SetSlotWorldTM
- SetSoundEffectRadius
- SetSoundSphereSpec
- SetStateClientside
- SetStaticSound
- SetTimer
- SetTriggerBBox
- SetUpdatePolicy
- SetUpdateRadius
- SetViewDistRatio
- SetViewDistUnlimited
- SetVolumeObjectMovementProperties
- StartAnimation
- StopAllSounds
- StopAnimation
- StopSound
- TriggerEvent
- UnSeenFrames
- UpdateAreas
- UpdateSlotPhysics