SE PB Scripts — Programmable Block scripts
Sandboxed C# that runs inside a Programmable Block. Whitelisted namespaces only. Whitelist restrictions apply throughout — enforce them in every suggestion.
Read first
references/scripts.md — Main loop, UpdateFrequency, IMyGridTerminalSystem, IMyIntergridCommunicationSystem (IGC), coroutines, sandbox restrictions, whitelist reference.
Sandbox — the hard constraints
- No I/O. No
System.IO, no file access, noConsole. State goes inStorage(persistent string) orMe.CustomData(mutable in-game). - No threading. No
Task, noThread, noasync/await. Long work uses coroutines (yield return). - No reflection. No
Type.GetType()beyond whitelisted names. - Limited System.*.
System.Collections.Generic,System.Linq,System.Textmostly OK.System.Net— no. - Instruction budget per tick. Long loops trip
ScriptOutOfRangeException. Break large sweeps across ticks with coroutines.
The five mod types — where PB fits
PB scripts are a completely separate environment from compiled mods. See ../se-core/references/mod-types.md for the table. Get this wrong and none of your compiled-mod code will work in a PB.
Shipping checklist
- Instruction count checked — no unbounded loops over large block lists per tick
-
Storageused for state that must survive recompile -
Echo()used for debug output, notMe.GetSurface(0)hardcoded - Graceful handling when expected blocks are missing from the grid
-
Save()implemented if state persistence matters