SOURCE / PINNED RELEASE
Made of little things.
Powder Tool V600Billion
- Release
- 142767edcab8…
- Author-recorded commit
- 6d92971effd0…
- License
- LICENSE
- Author’s source reference
- nostr://npub1fllw8kw0thjj55wds0uugcnp5kej2nfxd36eruq39d56wwz8r44q5q78wj/wss%3A%2F%2Fgit.napplet.soy%2F/powder-toy
Archive hash verified: ed7d6a8ea7083197…. The source-to-build association is the author’s claim; it has not been independently rebuilt.
/**
* The page's line into the running game: its Lua API, through the two
* functions patches/the-powder-toy-napplet-bridge.patch exports. Usable once
* the game has marked itself presentable (before that its Lua state and game
* view do not exist yet).
*/
/** Lua reported an error (a syntax error, or one raised while running). */
export class LuaError extends Error {
name = 'LuaError';
}
/** Long enough for any scene; the argument is copied onto the wasm stack (64 KiB). */
const MAX_CODE = 24_000;
export function connectGame(module) {
const run = module.cwrap('Napplet_Lua', 'string', ['string']);
const onTop = module.cwrap('Napplet_GameViewActive', 'number', []);
return {
/** Runs Lua as the game's console does; returns what it prints, throws what it reports. */
lua(code) {
if (code.length > MAX_CODE) throw new LuaError(`Lua code of ${code.length} characters is longer than ${MAX_CODE}`);
const reply = run(code);
if (reply.startsWith('ok:')) return reply.slice(3);
throw new LuaError(reply.replace(/^error:/, '') || 'Lua failed');
},
/** Whether the game's own view is on top: no dialog, save browser or console over it. */
gameViewActive: () => onTop() === 1,
};
}
