diff --git a/Barotrauma/BarotraumaServer/ServerSource/Lua/LuaBarotraumaAdditions.cs b/Barotrauma/BarotraumaServer/ServerSource/Lua/LuaBarotraumaAdditions.cs index cfdba2fb6..5bed0546d 100644 --- a/Barotrauma/BarotraumaServer/ServerSource/Lua/LuaBarotraumaAdditions.cs +++ b/Barotrauma/BarotraumaServer/ServerSource/Lua/LuaBarotraumaAdditions.cs @@ -43,6 +43,34 @@ namespace Barotrauma.Networking namespace Barotrauma { using Microsoft.Xna.Framework; + using System.Reflection; + + partial class Item + { + public object CreateServerEventString(string component) + { + Type type = Type.GetType("Barotrauma.Items.Components." + component); + + if (type == null) + return null; + + MethodInfo method = typeof(Item).GetMethod(nameof(Item.CreateServerEvent)); + MethodInfo generic = method.MakeGenericMethod(type); + return generic.Invoke(this, null); + } + + public object CreateServerEventString(string component, object[] extraData) + { + Type type = Type.GetType("Barotrauma.Items.Components." + component); + + if (type == null) + return null; + + MethodInfo method = typeof(Item).GetMethod(nameof(Item.CreateServerEvent)); + MethodInfo generic = method.MakeGenericMethod(type); + return generic.Invoke(this, new object[]{ extraData }); + } + } partial class ItemPrefab { diff --git a/config.ld b/config.ld index c9a8ceebd..1e7ae04ca 100644 --- a/config.ld +++ b/config.ld @@ -55,6 +55,7 @@ tparam_alias("Client", "client") tparam_alias("Character", "character") tparam_alias("Submarine", "submarine") tparam_alias("Item", "item") +tparam_alias("ItemPrefab", "ItemPrefab") tparam_alias("Vector2", "Vector2") tparam_alias("Vector3", "Vector3") tparam_alias("Vector4", "Vector4") diff --git a/docs/lua/Character.lua b/docs/lua/Character.lua index 0ec44cac8..6eeb4e41a 100644 --- a/docs/lua/Character.lua +++ b/docs/lua/Character.lua @@ -172,6 +172,11 @@ function TeleportTo(position) end -- @realm shared -- @bool IsInFriendlySub +--- +-- WorldPosition, Vector2 position of the Character in the world +-- @realm shared +-- @Vector2 WorldPosition + --- -- Position, returns a Vector2. -- @realm shared diff --git a/docs/lua/Item.lua b/docs/lua/Item.lua index fdc3411f1..c4f691b47 100644 --- a/docs/lua/Item.lua +++ b/docs/lua/Item.lua @@ -34,3 +34,18 @@ function Item:SendSignal(signalOrString, connectionOrConnectionName) end -- Item.ItemList, Table containing all items. -- @realm shared -- @Item Item.ItemList + +--- +-- Prefab, ItemPrefab containing the original prefab of the item. +-- @realm shared +-- @ItemPrefab Prefab + +--- +-- Name, the name of the item. +-- @realm shared +-- @string Name + +--- +-- WorldPosition, Vector2 position of the item in the world +-- @realm shared +-- @Vector2 WorldPosition diff --git a/docs/lua/ItemPrefab.lua b/docs/lua/ItemPrefab.lua index 52dbe581c..b4e175dfb 100644 --- a/docs/lua/ItemPrefab.lua +++ b/docs/lua/ItemPrefab.lua @@ -29,3 +29,8 @@ function ItemPrefab.AddToSpawnQueue(itemPrefab, inventory, spawned) end -- @treturn ItemPrefab -- @realm shared function ItemPrefab.GetItemPrefab(itemNameOrId) end + +--- +-- Identifier, the identifier of the prefab. +-- @realm shared +-- @string Identifier