Pallidium

Lua executor for Minecraft Bedrock

Lua API reference

General

Scripts run on the game thread, once per frame. Use wait() inside loops. Functions and variables stay defined between runs until Reset. autorun.lua runs on attach.

print(...)

Write to the output.

clear()

Clear the output.

log(x)

Write to the log file.

wait(seconds)

Pause this script. wait() waits one frame.

time()

Seconds since attach.

fps()

Current frames per second.

spawn(fn, ...)

Run fn as its own script, in parallel.

on("tick", fn(dt)) → id

Call fn every frame. Also "render" / "renderstepped".

on("key", fn(name))

A key went down ("W", "SPACE", "MOUSE1"…). Also "keyup".

off(id)

Remove a handler.

bind("G", fn) / unbind("G")

Run fn when a key is pressed.

rgb(r, g, b [, a])

A color, 0–255 each.

command("/time set day") → ok [, reason]

Run a slash command exactly like typing it in chat. The world decides if you're allowed (cheats on, or operator).

stop()

Stop all scripts, handlers, binds and GUI. The camera stays where it is.

eject()

Unload Pallidium from the game.

require("name")

Load scripts\name.lua.

Camera

Yaw 0 = south (+Z), 90 = west (−X). Pitch +90 = straight down.

camera.getPos() → x, y, z
camera.setPos(x, y, z)

Detach the camera and put it there. It stays there.

camera.move(dx, dy, dz)

Move relative to where it is.

camera.getRot() → yaw, pitch
camera.setRot(yaw, pitch)

Lock the view to this rotation.

camera.lookAt(x, y, z)

Lock the view onto a point.

camera.unlockRot()

Give the mouse back control of the view.

camera.getForward() → dx, dy, dz

Unit view vector.

camera.getFov() / setFov(deg) / resetFov()
camera.reset() / camera.clear()

Back to the normal player camera.

camera.isDetached()
camera.freeze(true/false) / isFrozen()

The camera can't move at all. gui.cursor(true) does this too.

Input

input.isDown("W")

Key is held right now.

input.pressed("W") / released("W")

Went down / up this frame.

input.mouseDelta() → dx, dy

Mouse movement this frame. Works while input is blocked.

input.block(true/false) / isBlocked()

The game ignores your keyboard and mouse, so you can make your own controls.

input.inGame()

True while playing (not in chat or menus).

GUI

Drawn inside Minecraft. Positions are pixels at 1080p.

gui.window("Title", {x, y, w}) → w

A window you can add things to.

w:text("hello")

Text. :set("new text")

w:button("Go", fn)

Calls fn() when clicked.

w:checkbox("On", false, fn(v))

:get() / :set(true)

w:slider("Speed", 1, 50, 10, fn(v) [, integer])
w:separator() / hide() / show() / close() / onClose(fn)
gui.text(x, y, "hi" [, color [, size]])

HUD text. :set(), :setPos(x, y), :setColor(rgb(...))

gui.rect(x, y, w, h [, color [, filled [, rounding]]])

A rectangle.

gui.cursor(true/false)

Show a mouse cursor to click windows. Freezes the camera.

gui.screen() → width, height
gui.clear()

Remove everything.

Player

player.getPos() → x, y, z

Position of your feet.

player.getBlockPos() → x, y, z

The block you are standing in.

player.give("diamond", 64) → ok [, reason]

Give yourself an item. Works where /give works (your world with cheats, or operator).

player.useItem() → ok [, reason]

Use the item in your hand, like right-clicking the air.

World

world.placeBlock(x, y, z) → ok [, reason]

Place the block you are holding there.

world.placeUnder()

Place it under your feet.

Example

A tiny freecam you can paste into the executor.

-- simple freecam: WASD + mouse, X to exit
input.block(true)
local x, y, z = camera.getPos()
local yaw, pitch = camera.getRot()
local id
id = on("render", function(dt)
  local mx, my = input.mouseDelta()
  yaw, pitch = yaw - mx * 0.15, math.max(-89, math.min(89, pitch + my * 0.15))
  camera.setRot(yaw, pitch)
  local fx, fy, fz = camera.getForward()
  local s = 12 * dt
  if input.isDown("W") then x, y, z = x + fx*s, y + fy*s, z + fz*s end
  if input.isDown("S") then x, y, z = x - fx*s, y - fy*s, z - fz*s end
  camera.setPos(x, y, z)
  if input.pressed("X") then off(id); input.block(false); camera.reset() end
end)