LuaUserData
Class providing util functions for interacting with the Common Language Runtime.
Functions
LuaUserData.CreateEnumTable(typeName)
Returns a table with the assigned enum values from CLR.
Parameters
-
typeName
LuaUserData.CreateStatic(typeName, addCallConstructor)
Returns the static reference to the reference, allowing you to call static methods and access static fields in that type. Set second argument to true if you want to also add a call constructor to the type, which allows you to create a new instance of it.
Parameters
-
typeName
-
addCallConstructor
LuaUserData.IsRegistered(typeName)
Checks if a CLR type is registered, returns the type descriptor if it exists, otherwise returns nil.
Parameters
-
typeName
LuaUserData.IsTargetType(object, typeName)
Checks if the provided object is the target type.
Parameters
-
object
-
typeName
Example Usage
local unknown = ...
if LuaUserData.IsTargetType(unknown, "Barotrauma.Character") then
print("This is a character!")
end
LuaUserData.MakeFieldAccessible(descriptor, fieldName)
Makes a non-public field accessible on a specific type.
Parameters
-
descriptor
-
fieldName
Example Usage
LuaUserData.MakeFieldAccessible(Descriptors["Barotrauma.Item"], "activeSprite")
local someItem = Item.ItemList
someItem.activeSprite = Sprite("LocalMods/Something/someSprite.png")
LuaUserData.MakeMethodAccessible(descriptor, fieldName, typeArgs)
Makes a non-public method accessible on a specific type.
Parameters
-
descriptor
-
fieldName
-
typeArgs
LuaUserData.MakePropertyAccessible(descriptor, propertyName)
Makes a non-public property accessible on a specific type.
Parameters
-
descriptor
-
propertyName
LuaUserData.RegisterType(typeName)
Registers a CLR type to be able to be interacted with Lua, returns a type descriptor. Automatically inserts the descriptor into a global table called Descriptors.
Parameters
-
typeName
LuaUserData.TypeOf(object)
Returns the type name of the provided object.
Parameters
-
object
LuaUserData.UnregisterType(typeName)
Unregisters a CLR type.
Parameters
-
typeName