This is the complete public Lua surface available in editor Play Mode and in a
PS1 build. Names are case-sensitive. Optional parameters are shown in square
brackets. The generated .polygon/lua/POLYGON_LUA_API.md inside a configured
project is produced from the same engine declaration and is the exact local
reference for that installed build.
Lifecycle Callbacks
| Callback | When it runs |
|---|
Awake(gameObjectId) | Once after the Lua Behaviour is loaded. |
OnEnable(gameObjectId) | Whenever the Lua Behaviour becomes active. |
Start(gameObjectId) | Before the first Update. |
FixedUpdate(gameObjectId, fixedDeltaTime) | At the bounded 30 Hz simulation step. |
Update(gameObjectId, deltaTime) | Once per rendered frame. |
LateUpdate(gameObjectId, deltaTime) | After Update. |
OnCollisionEnter(gameObjectId, otherGameObjectId) | When a collision starts. |
OnCollisionStay(gameObjectId, otherGameObjectId) | While a collision remains active. |
OnCollisionExit(gameObjectId, otherGameObjectId) | When a collision ends. |
OnTriggerEnter(gameObjectId, otherGameObjectId) | When a trigger overlap starts. |
OnTriggerStay(gameObjectId, otherGameObjectId) | While a trigger overlap remains active. |
OnTriggerExit(gameObjectId, otherGameObjectId) | When a trigger overlap ends. |
OnDisable(gameObjectId) | When the Lua Behaviour becomes inactive. |
OnDestroy(gameObjectId) | Before script state is released. |
Core
Log and Time
| Method | Returns | Purpose |
|---|
Log.Print(message) | none | Writes one runtime-safe log line. |
Time.DeltaTime() | number | Returns the scaled frame delta in seconds. |
Time.UnscaledDeltaTime() | number | Returns frame delta before time scale is applied. |
Time.GetTimeScale() | number | Returns the current gameplay time scale. |
Time.SetTimeScale(scale) | boolean | Sets time scale in 0.0..4.0; zero pauses scaled simulation while UI, input, and Lua frame callbacks remain active. |
| Method | Returns | Purpose |
|---|
Transform.GetPosition(gameObjectId) | Vec3 or nil | Reads world position. |
Transform.SetPosition(gameObjectId, position) | boolean | Sets world position from a Vec3. |
Transform.SetPosition(gameObjectId, x, y, z) | boolean | Sets world position from scalars. |
Transform.GetPositionX/Y/Z(gameObjectId) | number or nil | Reads one world-position axis. |
Transform.GetRotation(gameObjectId) | Vec3 or nil | Reads Euler rotation in degrees. |
Transform.SetRotation(gameObjectId, rotation) | boolean | Sets Euler rotation from a Vec3. |
Transform.SetRotation(gameObjectId, x, y, z) | boolean | Sets Euler rotation from scalars. |
Transform.GetRotationX/Y/Z(gameObjectId) | number or nil | Reads one Euler axis. |
Transform.GetScale(gameObjectId) | Vec3 or nil | Reads local scale. |
Transform.SetScale(gameObjectId, scale) | boolean | Sets scale from a Vec3. |
Transform.SetScale(gameObjectId, x, y, z) | boolean | Sets scale from scalars. |
Transform.GetScaleX/Y/Z(gameObjectId) | number or nil | Reads one scale axis. |
Transform.RotateX/Y/Z(gameObjectId, degrees) | boolean | Rotates around one axis. |
Transform.Translate(gameObjectId, x, y, z) | boolean | Applies a world-space translation. |
Transform setters reject non-finite or out-of-range PS1 values instead of
silently corrupting scene state.
GameObject
| Method | Returns | Purpose |
|---|
GameObject.Find(name) | integer | Finds a GameObject by exact name, including inactive objects in the current implementation, or -1. |
GameObject.Exists(gameObjectId) | boolean | Checks ID validity. |
GameObject.GetName(gameObjectId) | string or nil | Reads the display name. |
GameObject.IsActive(gameObjectId) | boolean or nil | Reads active state. |
GameObject.SetActive(gameObjectId, active) | boolean | Changes active state. |
GameObject.Invoke(gameObjectId, functionName[, int1, int2, string1, string2]) | boolean | Calls a function on the target Lua Behaviour. |
GameObject.CompareTag(gameObjectId, tag) | boolean | Compares a baked tag without allocating. |
GameObject.GetLayer(gameObjectId) | integer | Reads the physics/render layer. |
GameObject.SetLayer(gameObjectId, layer) | boolean | Changes the layer inside the baked range. |
| Method | Returns | Purpose |
|---|
Input.GetButton(buttonOrAction) | boolean | Tests a physical button constant or semantic action. |
Input.GetButtonDown(buttonOrAction) | boolean | True only on the pressed frame. |
Input.GetButtonUp(buttonOrAction) | boolean | True only on the released frame. |
Input.GetAxis([stickOrAction], [deadZone]) | number, number | Returns normalized X/Y in -1.0..1.0, with an optional smooth stick dead zone. Captured mouse look is not filtered. |
Input.IsConnected() | boolean | Reports Port 1 controller connection state. |
Input.HasAnalog() | boolean | Reports whether analog input is available. |
Input.GetPadType() | integer | Returns the PS1 controller type code. |
Button constants: CROSS, CIRCLE, SQUARE, TRIANGLE, UP, DOWN,
LEFT, RIGHT, START, SELECT, L1, L2, L3, R1, R2, and R3.
Stick selectors: STICK_LEFT and STICK_RIGHT.
| Method | Returns | Purpose |
|---|
PlayerInput.SetEnabled(gameObjectId, enabled) | boolean | Changes runtime PlayerInput state without deactivating the GameObject or LuaBehaviour. |
PlayerInput.IsEnabled(gameObjectId) | boolean or nil | Reads runtime state, or returns nil when the component is absent. |
Disabling PlayerInput stops native movement, look, interaction, and interaction
prompts. Raw Input queries remain active for menus and custom scripting.
Rumble
| Method | Returns | Purpose |
|---|
Rumble.Play([lowFrequency, highFrequency, durationSeconds]) | boolean | Starts bounded vibration. |
Rumble.Stop() | none | Stops vibration. |
Rumble.IsSupported() | boolean | Reports vibration capability. |
Audio and Presentation
AudioSource and Music
| Method | Returns | Purpose |
|---|
AudioSource.Play(gameObjectId) | boolean | Plays the assigned resident clip. |
AudioSource.PlayOneShot(gameObjectId) | boolean | Starts an independent one-shot voice for the assigned clip. |
AudioSource.Stop(gameObjectId) | boolean | Stops playback. |
AudioSource.SetVolume(gameObjectId, volume) | boolean | Sets normalized source volume. |
AudioSource.SetPan(gameObjectId, pan) | boolean | Sets stereo pan in -1.0..1.0. |
AudioSource.IsPlaying(gameObjectId) | boolean | Reads source playback state. |
Music.Play(name[, loop]) | boolean | Starts a named streamed CD-XA track. |
Music.Stop() | boolean | Stops streamed music. |
Music.SetVolume(volume) | boolean | Sets streamed-music volume. |
Music.IsPlaying() | boolean | Reads streamed-music state. |
Camera
| Method | Returns | Purpose |
|---|
Camera.Has(gameObjectId) | boolean | Checks for a Camera component. |
Camera.GetActive() | integer | Returns the active Camera GameObject. |
Camera.GetFieldOfView(gameObjectId) | number or nil | Reads vertical field of view. |
Camera.SetFieldOfView(gameObjectId, degrees) | boolean | Sets vertical field of view. |
Light
| Method | Returns | Purpose |
|---|
Light.Has(gameObjectId) | boolean | Checks for a Light component. |
Light.GetDirection(gameObjectId) | Vec3 or nil | Reads light direction. |
Light.SetDirection(gameObjectId, x, y, z) | boolean | Sets light direction. |
Light.GetColor(gameObjectId) | RGB table or nil | Reads 8-bit directional color. |
Light.SetColor(gameObjectId, r, g, b) | boolean | Sets 8-bit directional color. |
Light.GetIntensity(gameObjectId) | number or nil | Reads intensity. |
Light.SetIntensity(gameObjectId, intensity) | boolean | Sets intensity. |
Light.GetAmbient(gameObjectId) | RGB table or nil | Reads 8-bit ambient color. |
Light.SetAmbient(gameObjectId, r, g, b) | boolean | Sets 8-bit ambient color. |
ParticleSystem
| Method | Returns | Purpose |
|---|
ParticleSystem.Emit(x, y, z, vx, vy, vz, lifetime[, r, g, b]) | none | Emits one bounded billboard particle. |
ParticleSystem.Clear() | none | Clears all emitted particles. |
Physics and Movement
Collider
Collider.ShapeBox and Collider.ShapeSphere identify the supported shapes.
| Method | Returns | Purpose |
|---|
Collider.Has(gameObjectId) | boolean | Checks for a Collider. |
Collider.GetShape(gameObjectId) | integer or nil | Reads the shape constant. |
Collider.SetShape(gameObjectId, shape) | boolean | Sets a supported shape. |
Collider.IsTrigger(gameObjectId) | boolean | Reads trigger state. |
Collider.SetIsTrigger(gameObjectId, isTrigger) | boolean | Changes trigger state. |
Collider.GetSize(gameObjectId) | Vec3 or nil | Reads box size. |
Collider.SetSize(gameObjectId, x, y, z) | boolean | Sets box size. |
Collider.GetRadius(gameObjectId) | number or nil | Reads sphere radius. |
Collider.SetRadius(gameObjectId, radius) | boolean | Sets sphere radius. |
Physics
| Method | Returns | Purpose |
|---|
Physics.IsColliding(gameObjectId[, otherGameObjectId]) | boolean | Tests any collision or a specific pair. |
Physics.GetCollisionCount(gameObjectId) | integer | Counts active collisions. |
Physics.Raycast(ox, oy, oz, dx, dy, dz, maxDistance[, layerMask, queryTriggers]) | hit, ID, point XYZ, normal XYZ, distance | Performs an allocation-free raycast. |
CharacterController
| Method | Returns | Purpose |
|---|
CharacterController.Move(gameObjectId, x, y, z) | boolean | Moves through the kinematic collision world. |
CharacterController.IsGrounded(gameObjectId) | boolean | Reads grounded state. |
CharacterController.GetVelocityY(gameObjectId) | number | Reads vertical velocity. |
CharacterController.SetVelocityY(gameObjectId, velocity) | boolean | Sets vertical velocity. |
Scenes, Navigation, and Interaction
SceneManager
| Method | Returns | Purpose |
|---|
SceneManager.LoadScene(scenePath[, options]) | boolean | Queues one valid built scene; accepts EntryPoint and Presentation options. True means accepted, not finished. |
SceneManager.GetEntryPoint() | string | Reads the entry name before destination Start. |
NavMesh and NavMeshAgent
NavMeshAgent.PathInvalid and NavMeshAgent.PathComplete are the current path
status constants.
| Method | Returns | Purpose |
|---|
NavMesh.FindPath(sx, sy, sz, ex, ey, ez) | table | Returns a complete path of at most 32 Vec3 points, or an empty table. |
NavMesh.SamplePosition(x, y, z, maxDistance[, surfaceGameObjectId]) | found, x, y, z | Finds the nearest point on a baked NavMesh. |
NavMeshAgent.SetDestination(gameObjectId, x, y, z) | boolean | Starts movement toward a complete path destination. |
NavMeshAgent.Stop(gameObjectId) | none | Stops and clears agent movement. |
NavMeshAgent.IsMoving(gameObjectId) | boolean | Reads active movement state. |
NavMeshAgent.HasPath(gameObjectId) | boolean | Reports whether a valid path is owned. |
NavMeshAgent.HasReachedDestination(gameObjectId) | boolean | Tests the stopping distance. |
NavMeshAgent.IsOnNavMesh(gameObjectId) | boolean | Tests binding to a baked surface. |
NavMeshAgent.GetRemainingDistance(gameObjectId) | number | Reads bounded remaining path distance. |
NavMeshAgent.GetSpeed(gameObjectId) | number | Reads current movement speed. |
NavMeshAgent.GetPathStatus(gameObjectId) | integer | Reads a path status constant. |
Portal and Interactable
| Method | Returns | Purpose |
|---|
Portal.SetOpen(portalGameObjectId, open) | boolean | Changes Room connectivity through a Portal. |
Interactable.SetEnabled(gameObjectId, enabled) | boolean | Changes built-in interaction state. |
Interactable.IsEnabled(gameObjectId) | boolean | Reads built-in interaction state. |
Animation and Timelines
| Method | Returns | Purpose |
|---|
Timeline.Play(name[, { OnComplete = fn }]) | boolean | Starts an authored Timeline. |
Timeline.Stop() | none | Stops the active Timeline. |
Timeline.IsPlaying() | boolean | Reads Timeline state. |
Animation.Play(name[, loop]) | boolean | Starts an authored standalone clip. |
Animation.Play(name[, { Loop = bool, OnComplete = fn }]) | boolean | Starts a clip with options. |
Animation.Stop([name]) | none | Stops one clip or every clip. |
Animation.IsPlaying([name]) | boolean | Tests one clip or any clip. |
TransformAnimator.Play(gameObjectId[, state]) | boolean | Starts a transform state. |
TransformAnimator.Stop(gameObjectId) | boolean | Stops transform animation. |
TransformAnimator.SetSpeed(gameObjectId, speed) | boolean | Changes playback speed. |
TransformAnimator.IsPlaying(gameObjectId) | boolean | Reads playback state. |
TransformAnimator.SetState(gameObjectId, state) | boolean | Selects an authored state. |
TransformAnimator.GetState(gameObjectId) | string or nil | Reads the selected state. |
Animator.Play(gameObjectId, clipName[, loop]) | boolean | Starts an imported skeletal clip. |
Animator.Stop(gameObjectId) | boolean | Stops skeletal playback. |
Animator.IsPlaying(gameObjectId) | boolean | Reads skeletal playback state. |
Animator.GetClip(gameObjectId) | string or nil | Reads the active clip name. |
Animator.ConsumeFinished(gameObjectId) | string or nil | Consumes the finished non-looping clip name. |
Authored UI
| Table | Methods |
|---|
UI | Find(name), GetType(elementId), GetCount(), DrawText(x, y, text), SetInputEnabled(enabled), SetSubmitButton(buttonOrAction), SetSelectionColor(r, g, b) |
Canvas | Find(name), SetEnabled(canvasId, enabled), IsEnabled(canvasId), SetSortOrder(canvasId, order), GetCount(), SetModal(canvasId) |
Text | SetText(elementId, text), GetText(elementId) |
Image | SetTexture(elementId, textureGuid), GetTexture(elementId) |
Button | SetInteractable(elementId, interactable), IsInteractable(elementId) |
RectTransform | SetPosition(elementId, x, y), GetPosition(elementId), SetSize(elementId, width, height), GetSize(elementId) |
Graphic | SetColor(elementId, r, g, b[, a]), GetColor(elementId), SetEnabled(elementId, enabled), IsEnabled(elementId) |
Selectable | Select(elementId), GetSelected() |
ProgressBar | SetValue(elementId, value), GetValue(elementId) |
UI.DrawText is transient debug output. Use authored Text elements for player
UI. UI element IDs are global within the scene; Canvas IDs belong to the Canvas
collection.
Session and Transitions
These services behave the same in editor Play Mode and on PS1. See
Session and transitions for limits and the door recipe.
| Method | Returns | Purpose |
|---|
Session.Read(key) | string or nil | Reads run-owned data that survives scene loads. |
Session.Write(key, value) | boolean | Writes a bounded string without touching Memory Card storage. |
Session.Delete(key) | boolean | Releases a session entry. |
ScreenFade.ToBlack([seconds]) | boolean | Fades the screen using unscaled time. |
ScreenFade.FromBlack([seconds]) | boolean | Reveals the scene from the current fade opacity. |
ScreenFade.IsPlaying() | boolean | Reports whether the fade is still changing. |
Persistence
PlayerPrefs
| Method | Returns | Purpose |
|---|
PlayerPrefs.SetInt(key, value) | boolean | Stores an integer. |
PlayerPrefs.GetInt(key[, defaultValue]) | integer | Reads an integer. |
PlayerPrefs.SetFloat(key, value) | boolean | Stores a finite float. |
PlayerPrefs.GetFloat(key[, defaultValue]) | number | Reads a float. |
PlayerPrefs.SetString(key, value) | boolean | Stores a string. |
PlayerPrefs.GetString(key[, defaultValue]) | string | Reads a string. |
PlayerPrefs.HasKey(key) | boolean | Checks for a typed preference. |
PlayerPrefs.DeleteKey(key) | boolean | Deletes one typed preference. |
PlayerPrefs.DeleteAll() | boolean | Deletes only PlayerPrefs entries. |
PlayerPrefs.Save() | boolean | Flushes preferences to the platform save device. |
SaveData
| Method | Returns | Purpose |
|---|
SaveData.Write(key, value) | boolean | Writes an advanced raw string value. |
SaveData.Read(key) | string or nil | Reads a raw value. |
SaveData.Delete(key) | boolean | Removes one in-memory raw key; call Flush to persist. An absent key succeeds. |
SaveData.Flush() | boolean | Flushes raw data to the platform save device. |
SaveData.Clear() | boolean | Clears all raw and typed entries in memory. |
SaveData.Reload() | boolean | Reloads from the platform save device. |
SaveData.GetLastError() | string | Reads the latest persistence failure. |
Engine Identity
| Value | Type | Purpose |
|---|
Engine.Name | string | Runtime implementation name. |
Engine.ApiVersion | integer | Compatibility identifier for the installed scripting contract. |
Use Authoring Workflow for tooling and bytecode behavior,
and the topic pages for component setup, examples, and PS1-specific constraints.
For exact argument and return-type declarations, including every scalar-axis method, see the generated API Contract.