FOlib
raw JSON → 0.4.1 verified Fri May 01 auth: no javascript
FOlib provides TypeScript bindings for Fallout 2 engine scripting (sfall/TSSL). Current version 0.4.1, under active development with headers added on demand. Key differentiator: enables type-safe scripting for Fallout 2 mods using TSSL transpiler. Unlike raw JavaScript, provides declarations, definitions, and helper functions for sfall hooks, game APIs, and common patterns. Integrates with ESLint and TypeScript ESLint for linting.
Common errors
error Cannot find module 'folib' or its corresponding type declarations. ↓
cause Missing npm install or incorrect module resolution.
fix
Run
npm install folib and ensure tsconfig.json includes node_modules in module resolution. error Module '"folib"' has no exported member 'fo'. ↓
cause Attempting default import after v0.4.0.
fix
Use named import:
import { fo } from 'folib'. error TypeError: Cannot read properties of undefined (reading 'name') ↓
cause Assuming Game.getPlayer() always returns a valid object.
fix
Check for null/undefined:
const player = Game.getPlayer(); if (player) ... Warnings
deprecated export const fo_version = '0.4.0' - use fo.version instead. ↓
fix Replace fo_version with fo.version.
breaking Removed default export in v0.4.0. `import fo from 'folib'` no longer works. ↓
fix Use named import: `import { fo } from 'folib'`.
gotcha ESLint peer deps are not automatically installed; linting requires manual setup. ↓
fix Install peer deps: `npm install --save-dev eslint eslint-plugin-unused-imports typescript-eslint`
breaking API function `sfall.registerHook` was removed; use `sfall.addHook` instead. ↓
fix Replace `sfall.registerHook(...)` with `sfall.addHook(...)`.
Install
npm install folib yarn add folib pnpm add folib Imports
- fo wrong
import fo from 'folib'correctimport { fo } from 'folib' - Game wrong
const Game = require('folib').Gamecorrectimport { Game } from 'folib' - types
import type { Critter, Item } from 'folib' - sfall wrong
import { sfall } from 'folib/sfall'correctimport { sfall } from 'folib'
Quickstart
import { fo, Game, sfall } from 'folib';
import { critter, item } from 'folib/types';
const player = Game.getPlayer();
if (player) {
fo.printf('Player name: %s', player.name);
const inv = player.getInventory();
inv.forEach(i => sfall.setItemFlag(i, 'no_drop', true));
}