Log inGet started
Package

ecs.module

Newest version

This package holds more than this page lists. See all of its files in its world.

README.md

blobs

Generic binary staging for handing bytes to native components. Content reads a file's bytes (vfs.read, binary-safe, yields until the blob is resident), stages them with set, and passes the returned handle through a component field; the native consumer takes the bytes back by that handle and owns its copy. Staged bytes stay while a component field names their handle; bytes no component names are dropped once the frame after the one they were staged in ends, so a handle goes into its component in the frame it is staged. Writes a queue() body defers hold every staged payload until they land. Component field values travel as JSON (UTF-8 only), so a raw binary payload rides as a staged handle — the CPU-side analogue of the mesh/texture GPU upload.

Methods

  • blobs.set(bytes) -> handle — stage a binary payload, get a short string handle to pass through a component field.
  • blobs.get(handle) -> bytes? — read back a copy of the staged bytes without removing them; nil for an unknown or already-cleared handle.
  • blobs.clear(handle) — drop a staged payload at once, freeing its memory before the engine would drop it unnamed.

Usage

local bytes = vfs.read(clipPath .. "/data.zaud")
local handle = ecs.blobs.set(bytes)
ecs.insertSync(id, ecs.AudioSource { clip = clip, bytesHandle = handle })