<!-- Page: https://rustic-game-engine.pages.dev/docs/api/attributes/edit-attribute -->

# rustic.edit_attribute()

[Built-in attributes](https://rustic-game-engine.pages.dev/markdown/api/attributes.md)

## Compatibility

**Supported languages:** C, C++, C#, Python, JavaScript, Lua 5.4, Luau, Java, PHP and HTML/inline JavaScript (binding spellings and return shapes differ).

Use a compatible native engine build and the language tools required by your binding. This does not establish browser/mobile export or release qualification for every OS.

The signature below is the shared reference notation; language examples show the actual binding syntax. Question marks mark optional arguments and explicit defaults are shown where recorded. Do not copy reference notation as a typed declaration.

See [Feature status and compatibility](https://rustic-game-engine.pages.dev/markdown/reference/compatibility.md) for API 1.0/1.1 and per-method restrictions. Engine release tags and Docs v0.1 are independent versions.

## Signature

`rustic.edit_attribute(name, value)`

## Setup and usage

Use attributes for built-in entity state. Prefer `set_translation` for Position and `set_enabled` for Enabled when those dedicated calls better express intent.

## Parameters

| Variable | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | Yes | Name, Position, Size, Color (RGB), CanTouch, CanCollide, Anchored, or Parent. |
| `value` | attribute-specific | Yes | Value matching the attribute type. |

## Return and timing

Get returns the current value. Edit validates a typed mutation; [write timing depends on the runtime](https://rustic-game-engine.pages.dev/markdown/guides/scripting.md#when-mutations-take-effect).

## Execution behavior

Core write timing differs between immediate Lua host calls, deferred JavaScript/Web commands and external SDK query flushes. Scheduled actions advance with the scene clock; synchronous queries evaluate at the call. Follow [execution rules](https://rustic-game-engine.pages.dev/markdown/guides/scripting.md#when-mutations-take-effect) and the return/timing notes for this category.

## Language examples

Use these snippets inside Start/on_start after generating the Programming Workspace and attaching the script. Python imports rustic, Game and instance from rustic; C++ includes rustic.hpp; C includes rustic.h; C# uses using static Rustic; Java runs inside a Rustic subclass; PHP declares global $rustic, $Game, $instance in its callback. HTML uses an inline script in a ui/ asset. See [Lifecycle callbacks](https://rustic-game-engine.pages.dev/markdown/callbacks.md) for complete registration examples. Public-property examples require a declared integer health property. Scene examples require the named objects to exist before Play.

### Lua 5.4

```lua
local name = rustic.get_attribute('Name')
rustic.edit_attribute('Color', {1, .5, 0})
rustic.game.Demo.Room.Player:EditAttribute("Color", {1,.5,0})
local targetColor = rustic.game.Demo.Room.Player:GetAttribute("Color")
rustic.edit_object_attribute("rustic.game.Demo.Room.Player", "Color", {1,.5,0})
local position = rustic.get_object_attribute(rustic.entity_id(), 'Position')
rustic.edit_object_attribute(rustic.entity_id(), 'Color', {1, .5, 0})
```

### JavaScript

```javascript
const name = rustic.get_attribute('Name');
rustic.edit_attribute('Color', [1, .5, 0]);
rustic.game.Demo.Room.Player.EditAttribute("Color", [1,.5,0]);
rustic.edit_object_attribute("rustic.game.Demo.Room.Player", "Color", [1,.5,0]);
const position = rustic.get_object_attribute(rustic.entity_id(), 'Position');
rustic.edit_object_attribute(rustic.entity_id(), 'Color', [1, .5, 0]);
```

### Python

```python
name = rustic.get_attribute('Name')
rustic.edit_attribute('Color', [1, .5, 0])
rustic.game.Demo.Room.Player.EditAttribute("Color", [1,.5,0])
position = rustic.get_object_attribute(rustic.entity_id(), 'Position')
rustic.edit_object_attribute(rustic.entity_id(), 'Color', [1, .5, 0])
```

### C++

```cpp
auto name = rustic.get_attribute("Name");
rustic.edit_attribute("Color", RusticValue::Array{1.0, .5, 0.0});
rustic.game["Demo"]["Room"]["Player"].EditAttribute("Color", RusticValue::Array{1.0,.5,0.0});
auto position = rustic.get_object_attribute(rustic.entity_id(), "Position");
rustic.edit_object_attribute(rustic.entity_id(), "Color", RusticValue::Array{1.0, .5, 0.0});
```

### C#

```csharp
string? name = (string?)rustic.get_attribute("Name");
rustic.edit_attribute("Color",new double[]{1,.5,0});
rustic.game.Demo.Room.Player.EditAttribute("Color", new double[]{1,.5,0});
var position = rustic.get_object_attribute(rustic.entity_id(), "Position");
rustic.edit_object_attribute(rustic.entity_id(), "Color",new double[]{1,.5,0});
```

### Luau

```lua
local name = rustic.get_attribute('Name')
rustic.edit_attribute('Color',{1,.5,0})
rustic.game.Demo.Room.Player:EditAttribute("Color", {1,.5,0})
local position = rustic.get_object_attribute(rustic.entity_id(), 'Position')
rustic.edit_object_attribute(rustic.entity_id(), 'Color',{1,.5,0})
```

### C

```c
RusticValue name = rustic.get_attribute("Name");
rustic.edit_attribute("Color",(RusticValue){.type=RUSTIC_VECTOR,.vector={1,.5,0},.length=3});
rustic.game.EditAttribute("Demo", "Room.Player", "Color", (RusticValue){.type=RUSTIC_VECTOR,.vector={1,.5,0},.length=3});
RusticValue position = rustic.get_object_attribute(rustic.entity_id(), "Position");
rustic.edit_object_attribute(rustic.entity_id(), "Color",(RusticValue){.type=RUSTIC_VECTOR,.vector={1,.5,0},.length=3});
```

### Java

```java
String name = (String)rustic.get_attribute("Name");
rustic.edit_attribute("Color",new double[]{1,.5,0});
rustic.game.scene("Demo").object("Room.Player").EditAttribute("Color", new double[]{1,.5,0});
var position = rustic.get_object_attribute(rustic.entity_id(), "Position");
rustic.edit_object_attribute(rustic.entity_id(), "Color",new double[]{1,.5,0});
```

### PHP

```php
$name = $rustic->get_attribute("Name");
$rustic->edit_attribute("Color",[1,.5,0]);
$rustic->game->Demo->Room->Player->EditAttribute("Color", [1,.5,0]);
$position = $rustic->get_object_attribute($rustic->entity_id(), "Position");
$rustic->edit_object_attribute($rustic->entity_id(), "Color",[1,.5,0]);
```

### HTML / inline JS

```javascript
const name = rustic.get_attribute('Name');
rustic.edit_attribute('Color', [1, .5, 0]);
rustic.game.Demo.Room.Player.EditAttribute("Color", [1,.5,0]);
rustic.edit_object_attribute("rustic.game.Demo.Room.Player", "Color", [1,.5,0]);
const position = rustic.get_object_attribute(rustic.entity_id(), 'Position');
rustic.edit_object_attribute(rustic.entity_id(), 'Color', [1, .5, 0]);
```

## Shared Built-in attributes constraints

- In Play, unanchored built-in primitives fall under gravity; CanCollide enables solid box response only when both objects enable it. Anchored prevents physics movement and clears velocity on the next fixed tick. CanTouch does not affect solids; no collision or touch callbacks are emitted. Imported meshes do not simulate yet. See the Basic physics guide for setup and limits. Unknown attributes and type changes are rejected. Parent accepts a stable entity ID or null. Target another object with rustic.game.Scene.Root.Child:EditAttribute in Lua, native member calls in JavaScript/Python/C#/PHP, C++ subscripts, or an edit_attribute protocol command containing source. See [Edit scene objects](https://rustic-game-engine.pages.dev/markdown/guides/scene-objects.md) for setup, native calls in every language, and runtime limits.
- Every gameplay language calls the engine-owned API. Rustic supplies SDKs and dispatches callbacks; scripts do not parse requests or serialize responses. See the language guide for complete setup and callback registration.
- The direct edit_object_attribute helper is available in embedded Lua and JavaScript (including HTML); other SDKs use the native scene-object call shown above. Only embedded Lua exposes a path-based GetAttribute. For the scene-object example, create a scene named Demo with Room → Player. Change those names to match your scene; see Edit scene objects for full setup.

## Errors and debugging

Read the constraints above and the Console diagnostic. Invalid types, non-finite values, stale targets or unavailable native services can fail validation. A failed callback disables the behavior; a failed source reload keeps the last good instance. Exact error messages depend on the language adapter. See [Troubleshooting](https://rustic-game-engine.pages.dev/markdown/troubleshooting.md).

## Related APIs

- [rustic.get_attribute()](https://rustic-game-engine.pages.dev/markdown/api/attributes/get-attribute.md)
- [rustic.get_object_attribute()](https://rustic-game-engine.pages.dev/markdown/api/attributes/get-object-attribute.md)
- [rustic.edit_object_attribute()](https://rustic-game-engine.pages.dev/markdown/api/attributes/edit-object-attribute.md)
- [rustic.game.Scene.Root.Child.EditAttribute()](https://rustic-game-engine.pages.dev/markdown/api/attributes/child-edit-attribute.md)

[All attributes APIs](https://rustic-game-engine.pages.dev/markdown/api/attributes.md)
