Class LPCRuntime
This runtime is distinct from io.github.protasm.jvmud.compiler.runtime, which contains the
language-level helpers used by generated bytecode. LPCRuntime sits above the compiler
pipeline and provides a minimal API for loading LPC objects from source code.
The runtime registers shared objects before running compiler-generated LPC initialization so
benign circular singleton references can resolve an in-progress object. Direct recursive load
re-entry that cannot be resolved through a registered object still fails with a clear
LPCRuntimeException.
Usage example:
LPCRuntime runtime = new LPCRuntime(LPCRuntimeConfig.builder()
.baseIncludePath(Path.of("mudlibs", "lp245"))
.build());
LPCObjectHandle orc = runtime.load("/obj/orc.c");
runtime.withRuntimeContext(() -> {
orc.instance().getClass().getMethod("init").invoke(orc.instance());
return null;
});
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintappendMudlibText(String path, Object text) Appends text to a mudlib-rooted file, returning LP-style success.voidbindPlayerSession(String sessionId, String remoteAddress, Consumer<String> sessionOutputSink) Binds a host session id to an engine Player before a Persona has been resolved.voidbindSession(String sessionId, Object persona, String remoteAddress, Consumer<String> sessionOutputSink) Binds a host session id to a persona and session-specific output sink.voidbindSession(String sessionId, Object persona, String remoteAddress, Consumer<String> sessionOutputSink, MudlibProjection mudlibProjection) Binds a host session id to a persona with an explicit mudlib compatibility projection.booleancapturedSessionInputNoEcho(Object persona) Returns whether the pending captured input should suppress terminal echo.voidClears the accumulated default output transcript.cloneObject(String sourcePath) Creates a new clone of a compiled LPC object.Compiles one source file using this runtime's include, efun, and mudlib boundary context.intcopyMudlibText(String source, String destination) Copies a mudlib-rooted file, returning LDMud-style zero for success.intcreateMudlibDirectory(String path) Creates a mudlib-rooted directory, returning LP-style success.deliverCapturedSessionInput(Object persona, String line) Delivers one captured input line to a persona.voiddestructObject(Object object) Destructs a runtime object and removes it from object identity and containment indexes.dispatchCommand(Object actor, String commandLine) Dispatches one player command line through the Persona's registered command actions.environment(Object object) Returns the immediate runtime environment/container for an object.firstInventory(Object container) Returns the first object contained by a runtime object.booleanhasCapturedSessionInput(Object persona) Returns whether a persona is waiting for captured session input.inspectObject(Object object) Builds a reflection-backed inspection snapshot for admin tooling.invokeObject(Object object, String methodName, Object... args) Invokes a public LPC method with this runtime installed as the current generated-code context.invokeOptionalObject(Object object, String methodName, Object... args) Invokes a public LPC method when present, returning 0 if the object does not implement it.booleanisInteractive(Object user) Returns true when the supplied LPC object is currently attached to a host session.listMudlibPaths(String path, int flags) Lists mudlib-rooted files using the common LPget_dir()flag shape.Loads, compiles, instantiates, registers, and initializes one LPC source file.Loads, compiles, instantiates, registers, and initializes one source file.loadOrGetObject(String sourcePath) Returns a registered shared object for a source path, loading it if needed.loadSource(String sourceName, String source) Compiles and loads in-memory LPC source under the supplied source name.lpcObjectForSession(String sessionId) Returns the LPC object currently bound to a host session, when one exists.voidmoveObject(Object object, Object destination) Moves one runtime object into another object or into the shared object named by a path.Returns the active mudlib boundary metadata.nextInventory(Object object) Returns the next sibling object in inventory traversal.Returns the registered object id for an object, ornullif it is not registered.Returns the accumulated default output transcript for diagnostics and tests.personaRecordForProjection(Object persona) Returns the engine-owned Persona record associated with a compatibility persona projection.playerRecordForSession(String sessionId) Returns the engine-owned Player record associated with a bound host session.Resolves an object by identifier in a container, using current-context defaults when needed.readMudlibText(String path) Reads a mudlib-relative text file, returning LPC false (0) when unavailable.booleanrebindSessionLpcObject(Object newObject, Object oldObject) Rebinds an existing host session from one LPC object to another.voidrefreshCommandActions(Object actor) Rebuilds command actions for a Persona from nearby mudlib objects.voidregisterEfun(Efun efun) Registers one LPC-facing engine function in this runtime.voidregisterHostObject(String objectId, Object object) Registers a host-created object under a mudlib-style object id.voidregisterMudlibBoundary(MudlibBoundary mudlibBoundary) Registers mudlib boundary metadata and updates generated-code helper configuration.Reloads an LPC source path, replacing the shared registered object if it already exists.Reloads a source file from a filesystem path.intremoveMudlibDirectory(String path) Removes an empty mudlib-rooted directory, returning LP-style success.intremoveMudlibText(String path) Removes a mudlib-rooted text or storage file, returning LP-style success.intrenameMudlibText(String source, String destination) Renames a mudlib-rooted file or directory, returning LDMud-style zero for success.intrestoreLPCObjectState(String path, Object object) Restores scalar LPC object fields from mudlib-rooted storage, returning LP-style success.voidrunWithCurrentObject(Object object, Runnable action) Runnable convenience wrapper forwithCurrentObject(Object, Supplier).voidrunWithRuntimeContext(Runnable action) Runnable convenience wrapper forwithRuntimeContext(Supplier).intsaveLPCObjectState(String path, Object object) Saves scalar LPC object fields to mudlib-rooted storage, returning LP-style success.sessionRecord(String sessionId) Returns the engine-owned Session record for a bound host session.voidsetOutputSink(Consumer<String> outputSink) Sets the default output sink used for runtime text delivery.voidsetPlayerTransferHandler(BiFunction<Object, String, Integer> playerTransferHandler) Sets the server-owned handler for moving the active Player between hosted games.voidsetScheduler(WorldScheduler scheduler) Connects this LPC runtime to the deterministic scheduler for its owning world.Attempts to load source and captures runtime failures as a result object.Attempts to load source and captures runtime failures as a result object.voidunbindSession(String sessionId) Removes a host session binding.<T> TwithCommandActor(Object actor, Supplier<T> action) Runs an operation with the supplied object as the active command actor.<T> TwithCurrentObject(Object object, Supplier<T> action) Runs an action with this runtime and a current LPC object installed.<T> TwithRuntimeContext(Supplier<T> action) Runs an action with this runtime installed as the current generated-code context.booleanwriteToPersona(PersonaId personaId, Object value) Writes engine gameplay text to one bound Persona.booleanwriteToPlayer(PlayerId playerId, Object value) Writes engine control-plane text to all active Sessions for one Player.booleanwriteToSession(SessionId sessionId, Object value) Writes engine control-plane or transport text to one bound Session.
-
Constructor Details
-
LPCRuntime
-
-
Method Details
-
load
Loads, compiles, instantiates, registers, and initializes one LPC source file.Relative paths are resolved under the configured base include path. Absolute-looking mudlib paths such as
/room/churchare also resolved under that base path when one is configured. -
loadOrGetObject
-
reload
Reloads an LPC source path, replacing the shared registered object if it already exists. -
reload
Reloads a source file from a filesystem path.Reloading creates a fresh class loader because generated JVM classes cannot be redefined in the same loader.
-
load
Loads, compiles, instantiates, registers, and initializes one source file. -
compile
Compiles one source file using this runtime's include, efun, and mudlib boundary context. -
tryLoad
Attempts to load source and captures runtime failures as a result object. -
tryLoad
Attempts to load source and captures runtime failures as a result object. -
loadSource
Compiles and loads in-memory LPC source under the supplied source name. -
cloneObject
-
moveObject
-
environment
-
present
-
firstInventory
-
nextInventory
-
destructObject
Destructs a runtime object and removes it from object identity and containment indexes. -
registerHostObject
-
objectId
-
readMudlibText
-
listMudlibPaths
Lists mudlib-rooted files using the common LPget_dir()flag shape.The initial JVMud contract supports the startup-critical name listing behavior: literal paths or single-segment globs such as
/dir/*.sql, sorted unless the unsorted bit is set, and path-qualified names when theGETDIR_PATHbit is set. Metadata flags are intentionally left for later expansion. -
appendMudlibText
-
removeMudlibText
Removes a mudlib-rooted text or storage file, returning LP-style success. -
copyMudlibText
-
renameMudlibText
-
createMudlibDirectory
Creates a mudlib-rooted directory, returning LP-style success. -
removeMudlibDirectory
Removes an empty mudlib-rooted directory, returning LP-style success. -
saveLPCObjectState
-
restoreLPCObjectState
-
mudlibBoundary
Returns the active mudlib boundary metadata. -
registerMudlibBoundary
Registers mudlib boundary metadata and updates generated-code helper configuration. -
setScheduler
Connects this LPC runtime to the deterministic scheduler for its owning world. -
invokeObject
-
invokeOptionalObject
-
refreshCommandActions
Rebuilds command actions for a Persona from nearby mudlib objects.This invokes the configured interaction-scope lifecycle method on the Persona, its environment, and immediately nearby inventory objects so LPC
init/add_actionstyle registrations can be refreshed. -
dispatchCommand
-
withCommandActor
-
hasCapturedSessionInput
Returns whether a persona is waiting for captured session input. -
capturedSessionInputNoEcho
Returns whether the pending captured input should suppress terminal echo. -
deliverCapturedSessionInput
-
inspectObject
Builds a reflection-backed inspection snapshot for admin tooling. -
registerEfun
Registers one LPC-facing engine function in this runtime. -
setPlayerTransferHandler
Sets the server-owned handler for moving the active Player between hosted games. -
setOutputSink
-
bindPlayerSession
-
bindSession
-
bindSession
-
rebindSessionLpcObject
-
unbindSession
Removes a host session binding. -
sessionRecord
Returns the engine-owned Session record for a bound host session. -
lpcObjectForSession
-
isInteractive
Returns true when the supplied LPC object is currently attached to a host session. -
playerRecordForSession
Returns the engine-owned Player record associated with a bound host session. -
personaRecordForProjection
Returns the engine-owned Persona record associated with a compatibility persona projection. -
writeToSession
-
writeToPlayer
-
writeToPersona
-
outputTranscript
Returns the accumulated default output transcript for diagnostics and tests. -
clearOutputTranscript
public void clearOutputTranscript()Clears the accumulated default output transcript. -
withRuntimeContext
Runs an action with this runtime installed as the current generated-code context. -
withCurrentObject
-
runWithCurrentObject
Runnable convenience wrapper forwithCurrentObject(Object, Supplier). -
runWithRuntimeContext
Runnable convenience wrapper forwithRuntimeContext(Supplier).
-