OpenBone.Scripting.Jint
0.3.0
dotnet add package OpenBone.Scripting.Jint --version 0.3.0
NuGet\Install-Package OpenBone.Scripting.Jint -Version 0.3.0
<PackageReference Include="OpenBone.Scripting.Jint" Version="0.3.0" />
<PackageVersion Include="OpenBone.Scripting.Jint" Version="0.3.0" />
<PackageReference Include="OpenBone.Scripting.Jint" />
paket add OpenBone.Scripting.Jint --version 0.3.0
#r "nuget: OpenBone.Scripting.Jint, 0.3.0"
#:package OpenBone.Scripting.Jint@0.3.0
#addin nuget:?package=OpenBone.Scripting.Jint&version=0.3.0
#tool nuget:?package=OpenBone.Scripting.Jint&version=0.3.0
OpenBone.Scripting.Jint
Runs the JavaScript in OpenBone state machines on .NET, using the Jint interpreter.
OpenBone state machines can carry small scripts that react to pointer input,
events and time, and that drive inputs, bones and slots. OpenBone.Runtime
runs state machines without them. Add this package to run the scripts too. It runs them in
Jint (BSD-2-Clause) with the same ob API, hooks and limits as the reference
QuickJS host, and passes the OpenBone conformance suite. It targets netstandard2.1 and net8.0.
Install
dotnet add package OpenBone.Scripting.Jint
This also installs OpenBone.Runtime.
Quick start
Pass a JintScriptHost when you create the instance:
using OpenBone;
using OpenBone.Scripting;
var doc = DocumentLoader.Load(File.ReadAllBytes("walker.obone"));
var walker = new OpenBoneInstance(doc, new StateMachineOptions { ScriptHost = new JintScriptHost() });
var sm = walker.UseStateMachine("character");
sm.Log += args => Console.WriteLine("script: " + string.Join(" ", args)); // console.log / ob.log
sm.Error += e => Console.WriteLine("script error: " + e.Message); // errors and timeouts
sm.SetInput("walk", true);
sm.SetInput("speed", 1.0);
sm.Fire("jump");
// Once per frame:
walker.Advance(dt);
// When you are done (disposes the script engines):
walker.Dispose();
What scripts can do
Each script gets its own Jint engine. It sees only a frozen global ob object and console.log. Arguments and return
values cross between C# and JavaScript as JSON.
| Hook | When it runs |
|---|---|
onStart() |
Machine scripts: on the first Advance. State scripts: each time the state is entered. |
onUpdate(dt) |
Every Advance. |
onPointer({type, x, y}) |
Machine scripts, for each pointer event, before listeners. |
onEvent(e) |
After posing, for each fired event. |
ob call |
Effect |
|---|---|
time() |
Seconds since the state machine started |
input(n), setInput(n, v), fire(n) |
Read and change inputs, by name or id |
emit(name, {int, float, string}) |
Fire an event (and play its sound) |
bone(n), setBone(n, props) |
Read a bone's pose, or override it |
slot(n, {color, attachment}) |
Override a slot's colour or attachment |
pointer() |
{x, y, down} |
log(...) |
Raise the state machine's Log event |
A script error or timeout raises the state machine's Error event (a ScriptException), and playback goes on.
Limits
JintScriptHost has public fields for its limits. The defaults match the reference host.
| Field | Default | Meaning |
|---|---|---|
CallTimeout |
16 ms | CPU budget for each hook call |
LoadTimeout |
50 ms | Budget for running a script's top level. Each function's first call also gets this budget, to cover warm-up. |
MemoryLimit |
8 MB | Memory limit per script, in bytes (0 = no limit) |
MaxRecursionDepth |
512 | Maximum call depth |
var host = new JintScriptHost
{
CallTimeout = TimeSpan.FromMilliseconds(32),
LoadTimeout = TimeSpan.FromMilliseconds(100),
MemoryLimit = 16 * 1024 * 1024,
};
Unity
Unity users should install the com.openbone.runtime package, which brings the runtime and its script support. In the
Package Manager, choose Add package from git URL and enter:
https://github.com/UXCentury/open-bone.git#upm
Documentation
License
MIT. Copyright (c) UX Century and OpenBone contributors. See LICENSE. Jint is BSD-2-Clause.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Jint (>= 3.1.6)
- OpenBone.Runtime (>= 0.3.0)
-
net8.0
- Jint (>= 3.1.6)
- OpenBone.Runtime (>= 0.3.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on OpenBone.Scripting.Jint:
| Package | Downloads |
|---|---|
|
OpenBone.MonoGame
MonoGame (DesktopGL) integration for the OpenBone C# runtime: renderer (blend modes, clipping, two-colour tint), player component with pointer input, and a SoundEffect bridge for audio commands. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.3.0 | 0 | 11/11/2026 |