Barotrauma Server
Loading...
Searching...
No Matches
Barotrauma.LuaUserData Class Reference

Static Public Member Functions

static Type GetType (string typeName)
 
static IUserDataDescriptor RegisterType (string typeName)
 
static bool IsRegistered (string typeName)
 
static void UnregisterType (string typeName, bool deleteHistory=false)
 
static IUserDataDescriptor RegisterGenericType (string typeName, params string[] typeNameArguements)
 
static void UnregisterGenericType (string typeName, params string[] typeNameArguements)
 
static bool IsTargetType (object obj, string typeName)
 
static string TypeOf (object obj)
 
static object CreateStatic (string typeName)
 
static object CreateEnumTable (string typeName)
 
static void MakeFieldAccessible (IUserDataDescriptor IUUD, string fieldName)
 
static void MakeMethodAccessible (IUserDataDescriptor IUUD, string methodName, string[] parameters=null)
 
static void MakePropertyAccessible (IUserDataDescriptor IUUD, string propertyName)
 
static void AddMethod (IUserDataDescriptor IUUD, string methodName, object function)
 
static void AddField (IUserDataDescriptor IUUD, string fieldName, DynValue value)
 
static void RemoveMember (IUserDataDescriptor IUUD, string memberName)
 
static bool HasMember (object obj, string memberName)
 
static DynValue CreateUserDataFromDescriptor (DynValue scriptObject, IUserDataDescriptor desiredTypeDescriptor)
 See CreateUserDataFromType.
 
static DynValue CreateUserDataFromType (DynValue scriptObject, Type desiredType)
 Converts a Lua value to a CLR object of a desired type and wraps it in a userdata. If the type is not registered, then a new MoonSharp.Interpreter.Interop.StandardUserDataDescriptor will be created and used. The goal of this method is to allow Lua scripts to create userdata to wrap certain data without having to register types.
 

Member Function Documentation

◆ AddField()

static void Barotrauma.LuaUserData.AddField ( IUserDataDescriptor IUUD,
string fieldName,
DynValue value )
static

◆ AddMethod()

static void Barotrauma.LuaUserData.AddMethod ( IUserDataDescriptor IUUD,
string methodName,
object function )
static

◆ CreateEnumTable()

static object Barotrauma.LuaUserData.CreateEnumTable ( string typeName)
static

◆ CreateStatic()

static object Barotrauma.LuaUserData.CreateStatic ( string typeName)
static

◆ CreateUserDataFromDescriptor()

static DynValue Barotrauma.LuaUserData.CreateUserDataFromDescriptor ( DynValue scriptObject,
IUserDataDescriptor desiredTypeDescriptor )
static

See CreateUserDataFromType.

Parameters
scriptObjectLua value to convert and wrap in a userdata.
desiredTypeDescriptorDescriptor of the type of the object to convert the Lua value to. Uses MoonSharp ScriptToClr converters.
Returns
A userdata that wraps the Lua value converted to an object of the desired type as described by desiredTypeDescriptor .

◆ CreateUserDataFromType()

static DynValue Barotrauma.LuaUserData.CreateUserDataFromType ( DynValue scriptObject,
Type desiredType )
static

Converts a Lua value to a CLR object of a desired type and wraps it in a userdata. If the type is not registered, then a new MoonSharp.Interpreter.Interop.StandardUserDataDescriptor will be created and used. The goal of this method is to allow Lua scripts to create userdata to wrap certain data without having to register types.

Wrapping the value in a userdata preserves the original type during script-to-CLR conversions.

A Lua script needs to pass a List1 to a CLR method expecting System.Object, MoonSharp gets / in the way by converting the List1 to a MoonSharp.Interpreter.Table and breaking everything. Registering the List1 type can break other scripts relying on default converters, so instead / it is better to manually wrap the List1 object into a userdata.

Parameters
scriptObjectLua value to convert and wrap in a userdata.
desiredTypeType describing the CLR type of the object to convert the Lua value to.
Returns
A userdata that wraps the Lua value converted to an object of the desired type.

◆ GetType()

static Type Barotrauma.LuaUserData.GetType ( string typeName)
static

◆ HasMember()

static bool Barotrauma.LuaUserData.HasMember ( object obj,
string memberName )
static

◆ IsRegistered()

static bool Barotrauma.LuaUserData.IsRegistered ( string typeName)
static

◆ IsTargetType()

static bool Barotrauma.LuaUserData.IsTargetType ( object obj,
string typeName )
static

◆ MakeFieldAccessible()

static void Barotrauma.LuaUserData.MakeFieldAccessible ( IUserDataDescriptor IUUD,
string fieldName )
static

◆ MakeMethodAccessible()

static void Barotrauma.LuaUserData.MakeMethodAccessible ( IUserDataDescriptor IUUD,
string methodName,
string[] parameters = null )
static

◆ MakePropertyAccessible()

static void Barotrauma.LuaUserData.MakePropertyAccessible ( IUserDataDescriptor IUUD,
string propertyName )
static

◆ RegisterGenericType()

static IUserDataDescriptor Barotrauma.LuaUserData.RegisterGenericType ( string typeName,
params string[] typeNameArguements )
static

◆ RegisterType()

static IUserDataDescriptor Barotrauma.LuaUserData.RegisterType ( string typeName)
static

◆ RemoveMember()

static void Barotrauma.LuaUserData.RemoveMember ( IUserDataDescriptor IUUD,
string memberName )
static

◆ TypeOf()

static string Barotrauma.LuaUserData.TypeOf ( object obj)
static

◆ UnregisterGenericType()

static void Barotrauma.LuaUserData.UnregisterGenericType ( string typeName,
params string[] typeNameArguements )
static

◆ UnregisterType()

static void Barotrauma.LuaUserData.UnregisterType ( string typeName,
bool deleteHistory = false )
static

The documentation for this class was generated from the following file: