Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions entity-foundations/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Entity foundations

Two equivalent component scripts exercise live shared runtime services. Use one at
a time; this is a runnable script demonstration, not a serialized starter project.

1. Build/install the engine branch linked in the companion pull request (an older
release will not contain Tags/Groups/Entity/Components).
2. Create a project and a scene object in the Rustic editor.
3. Use **Programming > New Script > Object Component Script**, choose Lua or Python,
and replace the generated source with `behavior.lua` or `behavior.py` here.
4. Attach that script to the object with **+ Add Component** or by dragging it from
Explorer onto the object. Do not edit the scene/manifest metadata manually.
5. Press **Play**. Expect `entity foundations ready` in the Console; the object
disappears after one scaled fixed second. Stop Play to restore it.

Lua is bundled. Python needs the existing Python 3 toolchain. The engine supplies
`rustic.py`; do not install an unrelated Python package. Keep only one tagged
`enemy` object while running this example, because it asserts exactly one match.
Tags and groups exist only during Play and are not stored in authored scenes.
Paused Play/Clock pause stops the countdown. UI/global scripts should pass a real
scene ID instead of using their synthetic owner.

The companion engine tests execute both scripts against a live SceneWorld, check
that registration reaches Rust, and check destruction and group cleanup. See the
[API reference](https://rustic-game-engine.pages.dev/docs/api/entity-foundations)
for every signature, errors, language differences and limitations.
11 changes: 11 additions & 0 deletions entity-foundations/behavior.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
return {Start=function()
local e=rustic.entity_id()
Tags.add(e,'enemy')
Groups.create('enemies')
Groups.add('enemies',e)
assert(Entity.is_valid(e))
assert(Components.has(e,'rustic.transform'))
assert(#Tags.find_all('enemy')==1)
rustic.log('info','entity foundations ready')
Entity.destroy_after(e,1)
end}
14 changes: 14 additions & 0 deletions entity-foundations/behavior.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from rustic import rustic, Tags, Groups, Entity, Components, run

def on_start():
e = rustic.entity_id()
Tags.add(e, 'enemy')
Groups.create('enemies')
Groups.add('enemies', e)
assert Entity.is_valid(e)
assert Components.has(e, 'rustic.transform')
assert len(Tags.find_all('enemy')) == 1
rustic.log('info', 'entity foundations ready')
Entity.destroy_after(e, 1)

run(globals())