Repository navigation
Runtime API
English | ็น้ซไธญๆ | ๆฅๆฌ่ช | ํ๊ตญ์ด
This page introduces the runtime scripting API available in BIT8_CLI 0.1.0.
BIT8_CLI uses Lua 5.4 with .b8 scripts and supports func as an alternative to function.
| Property | Value |
|---|---|
| Framebuffer | 64 ร 64 pixels |
| Simulation | Fixed 30 Hz |
| Tile size | 8 ร 8 pixels |
| Map dimensions | Up to 256 ร 256 tiles |
| Scripting | Lua 5.4 |
| Script extension | .b8 |
Called during game initialization.
func init()
x = 32
y = 32
endHandles simulation logic.
func update()
x = x + 1
endSimulation updates run at a fixed 30 Hz.
Draws the current game state.
func draw()
cls(0)
pix(x, y, 7)
endClears the framebuffer using a palette color.
cls(0)clear() is also supported as an alias.
Draws a pixel at the specified screen coordinates.
pix(32, 32, 7)pixel() is also supported as an alias.
Draws a filled rectangle.
rectfill(10, 10, 20, 20, 7)Draws a tile from the registered assets.
BIT8_CLI supports stable Asset IDs.
spr(A4, 16, 16)Legacy numeric sprite references remain supported for compatibility.
Draws map content using the project's registered tiles.
func draw()
cls(0)
map()
endMap rendering can interact with the active Camera.
For detailed map behavior, see Maps.
Returns whether a button is currently held.
if btn(LEFT) then
x = x - 1
endAvailable button constants:
UP
DOWN
LEFT
RIGHT
A
B
Checks whether a button was newly pressed.
if btnp(A) then
print("A pressed")
endUnlike btn(), it is intended for press events rather than continuous holding.
Reads a tile value from the map.
Changes a tile value in the runtime map.
For map coordinates, tile IDs, and editing behavior, see Maps.
Node scripts access their associated runtime Node through self.
func update()
self.x = self.x + 1
end| Property | Description |
|---|---|
self.id |
Stable Node identifier |
self.name |
Node name |
self.x |
World X position |
self.y |
World Y position |
self.enabled |
Whether the Node is enabled |
Checks whether moving the Node by the given offset would collide with supported collision geometry.
if self:collide(1, 0) then
print("Blocked")
endThis check does not move the Node.
Collision uses enabled Node Box Colliders and solid map tiles.
Attempts to move the Node while respecting collision.
self:move(1, 0)Movement is resolved along the X axis before the Y axis.
BIT8_CLI 0.1.0 provides basic collision-aware movement, not a full physics engine.
Binds a registered Sprite definition to the Node.
self:sprite("Player")Plays a named animation from the Node's bound Sprite.
self:play("walk")Repeated requests to play the same animation do not restart it unnecessarily.
Draws the Node's current Sprite animation frame.
func draw()
self:spr()
endSprite definitions are stored in:
bit8.sprites.toml
See Sprites and Animation for configuration details.
BIT8_CLI supports a Camera Node.
The active Camera controls the world-space view used by supported rendering operations.
Camera coordinates represent the center of the 64 ร 64 viewport.
Screen-space drawing operations such as cls(), pix(), and rectfill() are not shifted by the Camera.
See Camera for details.
The following example is intended for a Node with a registered Sprite and suitable animation definitions.
func update()
if btn(LEFT) then
self:move(-1, 0)
self:play("walk")
elseif btn(RIGHT) then
self:move(1, 0)
self:play("walk")
else
self:play("idle")
end
end
func draw()
self:spr()
endThe animation names must exist in the Sprite definition.
This page documents the established BIT8_CLI 0.1.0 API surface. Detailed signatures and edge cases should be checked against the corresponding release source.
Current Version: 0.1.0