Scriptclass

A reusable script created by `Sandbox.Game.Scripting`. Arguments expire after each invocation; local variables are fresh each run. Use sequentially on the owning context's thread.

object→Script
Namespace
Sandbox
Assembly
Sandbox.Engine
Declaration
public sealed class Sandbox.Script

Methods6

Showing 6 methods

public bool Compile()PUBLIC

Checks that the script compiles with its supplied arguments without executing it. Arguments remain available for the next Run. Failure sets LastError.

Returns:bool—

public bool HasArgument(string name)PUBLIC

Whether this script references a named external argument. Use before supplying optional host inputs. Names are case sensitive; locals do not count as external arguments.

ParameterTypeDescription
namestring—
Returns:bool—

public bool Run(int instructionLimit = 10000000)PUBLIC

Runs the script, returning false and setting LastError on failure.

ParameterTypeDescription
instructionLimit = 10000000int—
Returns:bool—

public T RunAndReturn(int instructionLimit = 10000000)PUBLIC

Runs the script and reads its result. Returns default on failure or when no value is returned. An incompatible return type is reported through LastError.

ParameterTypeDescription
instructionLimit = 10000000int—
Returns:T—

public void SetArgument(string name, T value)PUBLIC

Supplies a named input for the next invocation only. Unknown names and changes during execution are API usage errors. Supply every input needed to bind host member calls before running.

ParameterTypeDescription
namestring—
valueT—
Returns:void—

public Sandbox.ScriptInvocation`1<T> With(string name, T value)PUBLIC

Creates a stack-only invocation with a temporary argument. Chain With to supply more arguments, then call Run or Compile. Names must be referenced by the script; repeated names replace earlier values.

ParameterTypeDescription
namestring—
valueT—
Returns:ScriptInvocation<T>—

Properties1

Showing 1 properties

On this page