-
Notifications
You must be signed in to change notification settings - Fork 0
1. Exposed stuff
SomeRandomNoobKekeke edited this page Apr 25, 2026
·
5 revisions
By default ClearScript provides just basic language support
All real functionality is located in adapted c# objects explicitly exposed to js
-
host,xHost- magic, utils objects for interacting with C# types and objects, they are key, xHost is just better version of host, read about them here -
JS- Exposes Methods for interacting with the engine -
Console- Exposes Log, Warning, Error methods that writes in both consoles at once -
ModInfo.Package- A variable that is temporarily set to the current package when js loads its scripts -
ModInfo.FullPath- Full patch to the mod folder, also temporary -
API- Contains various easy to use APIs like JSHook for patching the game with harmony, Console for adding console commands or Web for creating web servers -
lib- mega object, contains all host assemblies and types -
modlib- contains all c# mod assemblies, including JSForBarotrauma
-
GetMethod(path)- global func that gets MethodBase by string path, soGetMethod("Barotrauma.GameMain.Update")==xHost.typeOf(lib.Barotrauma.GameMain).GetMethod("Update", lib.HarmonyLib.AccessTools.all), it can accept BindingFlags as second arg, but you can't combine them naturally in js, combinable flags is still wip -
setTimeout(jsfunc, delay)- There's no built-in setTimeout, this one is c# imposter that uses tasks under the hood