Updated Moonsharp Interpreter, added support for implicit conversions, new types: LuaByte, LuaUShort and LuaFloat added to solve method overload conflict, support for setting UserData metatables, remove LuaUserData.AddCallMetaMethod and moved GUI object to Lua
This commit is contained in:
@@ -8,63 +8,6 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
partial class LuaSetup
|
partial class LuaSetup
|
||||||
{
|
{
|
||||||
public class LuaGUI
|
|
||||||
{
|
|
||||||
LuaSetup env;
|
|
||||||
public LuaGUI(LuaSetup _env)
|
|
||||||
{
|
|
||||||
env = _env;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CreateStaticValues()
|
|
||||||
{
|
|
||||||
RectTransform = UserData.CreateStatic<RectTransform>();
|
|
||||||
LayoutGroup = UserData.CreateStatic<GUILayoutGroup>();
|
|
||||||
Button = UserData.CreateStatic<GUIButton>();
|
|
||||||
TextBox = UserData.CreateStatic<GUITextBox>();
|
|
||||||
Canvas = UserData.CreateStatic<GUICanvas>();
|
|
||||||
Frame = UserData.CreateStatic<GUIFrame>();
|
|
||||||
TextBlock = UserData.CreateStatic<GUITextBlock>();
|
|
||||||
TickBox = UserData.CreateStatic<GUITickBox>();
|
|
||||||
Image = UserData.CreateStatic<GUIImage>();
|
|
||||||
ListBox = UserData.CreateStatic<GUIListBox>();
|
|
||||||
ScrollBar = UserData.CreateStatic<GUIScrollBar>();
|
|
||||||
DropDown = UserData.CreateStatic<GUIDropDown>();
|
|
||||||
|
|
||||||
Screen = UserData.CreateStatic<Screen>();
|
|
||||||
|
|
||||||
Anchor = UserData.CreateStatic<Anchor>();
|
|
||||||
Alignment = UserData.CreateStatic<Alignment>();
|
|
||||||
Pivot = UserData.CreateStatic<Pivot>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChatBox ChatBox
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return GameMain.Client.ChatBox;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static object Screen;
|
|
||||||
|
|
||||||
public static object RectTransform;
|
|
||||||
public static object LayoutGroup;
|
|
||||||
public static object Button;
|
|
||||||
public static object TextBox;
|
|
||||||
public static object Canvas;
|
|
||||||
public static object Frame;
|
|
||||||
public static object TextBlock;
|
|
||||||
public static object TickBox;
|
|
||||||
public static object Image;
|
|
||||||
public static object ListBox;
|
|
||||||
public static object ScrollBar;
|
|
||||||
public static object DropDown;
|
|
||||||
|
|
||||||
public static object Pivot;
|
|
||||||
public static object Anchor;
|
|
||||||
public static object Alignment;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,6 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="MonoMod.Common" Version="22.1.20.1" />
|
<PackageReference Include="MonoMod.Common" Version="22.1.20.1" />
|
||||||
<PackageReference Include="MoonSharp" Version="2.0.0" />
|
|
||||||
<PackageReference Include="NVorbis" Version="0.8.6" />
|
<PackageReference Include="NVorbis" Version="0.8.6" />
|
||||||
<PackageReference Include="RestSharp" Version="106.12.0" />
|
<PackageReference Include="RestSharp" Version="106.12.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -130,6 +129,9 @@
|
|||||||
<Reference Include="0Harmony">
|
<Reference Include="0Harmony">
|
||||||
<HintPath>..\..\Libraries\0Harmony.dll</HintPath>
|
<HintPath>..\..\Libraries\0Harmony.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="MoonSharp.Interpreter">
|
||||||
|
<HintPath>..\..\Libraries\MoonSharp.Interpreter.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Sourced from https://stackoverflow.com/a/45248069 -->
|
<!-- Sourced from https://stackoverflow.com/a/45248069 -->
|
||||||
|
|||||||
@@ -122,7 +122,6 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="MonoMod.Common" Version="22.1.20.1" />
|
<PackageReference Include="MonoMod.Common" Version="22.1.20.1" />
|
||||||
<PackageReference Include="MoonSharp" Version="2.0.0" />
|
|
||||||
<PackageReference Include="NVorbis" Version="0.8.6" />
|
<PackageReference Include="NVorbis" Version="0.8.6" />
|
||||||
<PackageReference Include="RestSharp" Version="106.12.0" />
|
<PackageReference Include="RestSharp" Version="106.12.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -138,6 +137,9 @@
|
|||||||
<Reference Include="0Harmony">
|
<Reference Include="0Harmony">
|
||||||
<HintPath>..\..\Libraries\0Harmony.dll</HintPath>
|
<HintPath>..\..\Libraries\0Harmony.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="MoonSharp.Interpreter">
|
||||||
|
<HintPath>..\..\Libraries\MoonSharp.Interpreter.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Update="libfreetype6.dylib">
|
<None Update="libfreetype6.dylib">
|
||||||
|
|||||||
@@ -128,7 +128,6 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="MonoMod.Common" Version="22.1.20.1" />
|
<PackageReference Include="MonoMod.Common" Version="22.1.20.1" />
|
||||||
<PackageReference Include="MoonSharp" Version="2.0.0" />
|
|
||||||
<PackageReference Include="NVorbis" Version="0.8.6" />
|
<PackageReference Include="NVorbis" Version="0.8.6" />
|
||||||
<PackageReference Include="RestSharp" Version="106.12.0" />
|
<PackageReference Include="RestSharp" Version="106.12.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -137,6 +136,9 @@
|
|||||||
<Reference Include="0Harmony">
|
<Reference Include="0Harmony">
|
||||||
<HintPath>..\..\Libraries\0Harmony.dll</HintPath>
|
<HintPath>..\..\Libraries\0Harmony.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="MoonSharp.Interpreter">
|
||||||
|
<HintPath>..\..\Libraries\MoonSharp.Interpreter.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -75,7 +75,6 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="MonoMod.Common" Version="22.1.20.1" />
|
<PackageReference Include="MonoMod.Common" Version="22.1.20.1" />
|
||||||
<PackageReference Include="MoonSharp" Version="2.0.0" />
|
|
||||||
<PackageReference Include="RestSharp" Version="106.13.0" />
|
<PackageReference Include="RestSharp" Version="106.13.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
@@ -83,6 +82,9 @@
|
|||||||
<Reference Include="0Harmony">
|
<Reference Include="0Harmony">
|
||||||
<HintPath>..\..\Libraries\0Harmony.dll</HintPath>
|
<HintPath>..\..\Libraries\0Harmony.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="MoonSharp.Interpreter">
|
||||||
|
<HintPath>..\..\Libraries\MoonSharp.Interpreter.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Sourced from https://stackoverflow.com/a/45248069 -->
|
<!-- Sourced from https://stackoverflow.com/a/45248069 -->
|
||||||
|
|||||||
@@ -82,7 +82,6 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="MonoMod.Common" Version="22.1.20.1" />
|
<PackageReference Include="MonoMod.Common" Version="22.1.20.1" />
|
||||||
<PackageReference Include="MoonSharp" Version="2.0.0" />
|
|
||||||
<PackageReference Include="RestSharp" Version="106.13.0" />
|
<PackageReference Include="RestSharp" Version="106.13.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
@@ -97,6 +96,9 @@
|
|||||||
<Reference Include="0Harmony">
|
<Reference Include="0Harmony">
|
||||||
<HintPath>..\..\Libraries\0Harmony.dll</HintPath>
|
<HintPath>..\..\Libraries\0Harmony.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="MoonSharp.Interpreter">
|
||||||
|
<HintPath>..\..\Libraries\MoonSharp.Interpreter.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Target Name="GetGitRevision" BeforeTargets="WriteGitRevision" Condition="'$(BuildHash)' == ''">
|
<Target Name="GetGitRevision" BeforeTargets="WriteGitRevision" Condition="'$(BuildHash)' == ''">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|||||||
@@ -83,7 +83,6 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="MonoMod.Common" Version="22.1.20.1" />
|
<PackageReference Include="MonoMod.Common" Version="22.1.20.1" />
|
||||||
<PackageReference Include="MoonSharp" Version="2.0.0" />
|
|
||||||
<PackageReference Include="RestSharp" Version="106.13.0" />
|
<PackageReference Include="RestSharp" Version="106.13.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
@@ -91,6 +90,9 @@
|
|||||||
<Reference Include="0Harmony">
|
<Reference Include="0Harmony">
|
||||||
<HintPath>..\..\Libraries\0Harmony.dll</HintPath>
|
<HintPath>..\..\Libraries\0Harmony.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="MoonSharp.Interpreter">
|
||||||
|
<HintPath>..\..\Libraries\MoonSharp.Interpreter.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Sourced from https://stackoverflow.com/a/45248069 -->
|
<!-- Sourced from https://stackoverflow.com/a/45248069 -->
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
local compatibilityLib = {}
|
local compatibilityLib = {}
|
||||||
|
|
||||||
|
LuaUserData.AddMethod(LuaUserData.RegisterType("Barotrauma.LuaSetup+LuaUserData"), "AddCallMetaMember", function (v)
|
||||||
|
print("AddCallMetaMember is deprecated, use debug.setmetatable instead.")
|
||||||
|
end)
|
||||||
|
|
||||||
compatibilityLib.CreateVector2 = Vector2.__new
|
compatibilityLib.CreateVector2 = Vector2.__new
|
||||||
compatibilityLib.CreateVector3 = Vector3.__new
|
compatibilityLib.CreateVector3 = Vector3.__new
|
||||||
compatibilityLib.CreateVector4 = Vector4.__new
|
compatibilityLib.CreateVector4 = Vector4.__new
|
||||||
|
|||||||
@@ -2,41 +2,42 @@ local defaultLib = {}
|
|||||||
|
|
||||||
require("DefaultRegister")
|
require("DefaultRegister")
|
||||||
|
|
||||||
local CreateStatic = function (typeName)
|
local CreateStatic = function (typeName, addCallMethod)
|
||||||
return LuaUserData.CreateStatic("Barotrauma." .. typeName)
|
local staticUserdata = LuaUserData.CreateStatic(typeName)
|
||||||
|
|
||||||
|
if addCallMethod then
|
||||||
|
debug.setmetatable(staticUserdata, {
|
||||||
|
__call = function(obj, ...)
|
||||||
|
return staticUserdata.__new(...)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
return staticUserdata
|
||||||
end
|
end
|
||||||
|
|
||||||
defaultLib["WayPoint"] = CreateStatic("WayPoint")
|
defaultLib["Byte"] = CreateStatic("Barotrauma.LuaByte", true)
|
||||||
defaultLib["SpawnType"] = CreateStatic("SpawnType")
|
defaultLib["UShort"] = CreateStatic("Barotrauma.LuaUShort", true)
|
||||||
defaultLib["ChatMessageType"] = CreateStatic("Networking.ChatMessageType")
|
defaultLib["Float"] = CreateStatic("Barotrauma.LuaFloat", true)
|
||||||
defaultLib["ServerLog_MessageType"] = CreateStatic("Networking.ServerLog+MessageType")
|
|
||||||
defaultLib["ServerLogMessageType"] = CreateStatic("Networking.ServerLog+MessageType")
|
defaultLib["SpawnType"] = CreateStatic("Barotrauma.SpawnType")
|
||||||
defaultLib["Submarine"] = CreateStatic("Submarine")
|
defaultLib["ChatMessageType"] = CreateStatic("Barotrauma.Networking.ChatMessageType")
|
||||||
defaultLib["Client"] = CreateStatic("Networking.Client")
|
defaultLib["ServerLog_MessageType"] = CreateStatic("Barotrauma.Networking.ServerLog+MessageType")
|
||||||
defaultLib["Character"] = CreateStatic("Character")
|
defaultLib["ServerLogMessageType"] = CreateStatic("Barotrauma.Networking.ServerLog+MessageType")
|
||||||
defaultLib["CharacterInfo"] = CreateStatic("CharacterInfo")
|
defaultLib["PositionType"] = CreateStatic("Barotrauma.Level+PositionType")
|
||||||
defaultLib["Item"] = CreateStatic("Item")
|
defaultLib["InvSlotType"] = CreateStatic("Barotrauma.InvSlotType")
|
||||||
defaultLib["ItemPrefab"] = CreateStatic("ItemPrefab")
|
defaultLib["LimbType"] = CreateStatic("Barotrauma.LimbType")
|
||||||
defaultLib["Level"] = CreateStatic("Level")
|
defaultLib["ActionType"] = CreateStatic("Barotrauma.ActionType")
|
||||||
defaultLib["PositionType"] = CreateStatic("Level+PositionType")
|
defaultLib["DeliveryMethod"] = CreateStatic("Barotrauma.Networking.DeliveryMethod")
|
||||||
defaultLib["Job"] = CreateStatic("Job")
|
defaultLib["ClientPacketHeader"] = CreateStatic("Barotrauma.Networking.ClientPacketHeader")
|
||||||
defaultLib["JobPrefab"] = CreateStatic("JobPrefab")
|
defaultLib["ServerPacketHeader"] = CreateStatic("Barotrauma.Networking.ServerPacketHeader")
|
||||||
defaultLib["TraitorMessageType"] = CreateStatic("Networking.TraitorMessageType")
|
defaultLib["RandSync"] = CreateStatic("Barotrauma.Rand+RandSync")
|
||||||
defaultLib["CauseOfDeathType"] = CreateStatic("CauseOfDeathType")
|
defaultLib["DisconnectReason"] = CreateStatic("Barotrauma.Networking.DisconnectReason")
|
||||||
defaultLib["AfflictionPrefab"] = CreateStatic("AfflictionPrefab")
|
defaultLib["TraitorMessageType"] = CreateStatic("Barotrauma.Networking.TraitorMessageType")
|
||||||
defaultLib["CharacterTeamType"] = CreateStatic("CharacterTeamType")
|
defaultLib["CombatMode"] = CreateStatic("Barotrauma.AIObjectiveCombat+CombatMode")
|
||||||
defaultLib["Vector2"] = LuaUserData.CreateStatic("Microsoft.Xna.Framework.Vector2")
|
defaultLib["CauseOfDeathType"] = CreateStatic("Barotrauma.CauseOfDeathType")
|
||||||
defaultLib["Vector3"] = LuaUserData.CreateStatic("Microsoft.Xna.Framework.Vector3")
|
defaultLib["CharacterTeamType"] = CreateStatic("Barotrauma.CharacterTeamType")
|
||||||
defaultLib["Vector4"] = LuaUserData.CreateStatic("Microsoft.Xna.Framework.Vector4")
|
|
||||||
defaultLib["Color"] = LuaUserData.CreateStatic("Microsoft.Xna.Framework.Color")
|
|
||||||
defaultLib["Point"] = LuaUserData.CreateStatic("Microsoft.Xna.Framework.Point")
|
|
||||||
defaultLib["ChatMessage"] = CreateStatic("Networking.ChatMessage")
|
|
||||||
defaultLib["Hull"] = CreateStatic("Hull")
|
|
||||||
defaultLib["InvSlotType"] = CreateStatic("InvSlotType")
|
|
||||||
defaultLib["LimbType"] = CreateStatic("LimbType")
|
|
||||||
defaultLib["ActionType"] = CreateStatic("ActionType")
|
|
||||||
defaultLib["Gap"] = CreateStatic("Gap")
|
|
||||||
defaultLib["ContentPackage"] = CreateStatic("ContentPackage")
|
|
||||||
defaultLib["ClientPermissions"] = {
|
defaultLib["ClientPermissions"] = {
|
||||||
None = 0x0,
|
None = 0x0,
|
||||||
ManageRound = 0x1,
|
ManageRound = 0x1,
|
||||||
@@ -53,58 +54,94 @@ defaultLib["ClientPermissions"] = {
|
|||||||
KarmaImmunity = 0x800,
|
KarmaImmunity = 0x800,
|
||||||
All = 0xFFF
|
All = 0xFFF
|
||||||
}
|
}
|
||||||
defaultLib["Signal"] = CreateStatic("Items.Components.Signal")
|
|
||||||
defaultLib["DeliveryMethod"] = CreateStatic("Networking.DeliveryMethod")
|
|
||||||
defaultLib["ClientPacketHeader"] = CreateStatic("Networking.ClientPacketHeader")
|
|
||||||
defaultLib["ServerPacketHeader"] = CreateStatic("Networking.ServerPacketHeader")
|
|
||||||
defaultLib["RandSync"] = CreateStatic("Rand+RandSync")
|
|
||||||
defaultLib["SubmarineInfo"] = CreateStatic("SubmarineInfo")
|
|
||||||
defaultLib["Rectangle"] = LuaUserData.CreateStatic("Microsoft.Xna.Framework.Rectangle")
|
|
||||||
defaultLib["Entity"] = CreateStatic("Entity")
|
|
||||||
defaultLib["Physics"] = CreateStatic("Physics")
|
|
||||||
defaultLib["FireSource"] = CreateStatic("FireSource")
|
|
||||||
defaultLib["TextManager"] = CreateStatic("TextManager")
|
|
||||||
defaultLib["NetEntityEvent"] = CreateStatic("Networking.NetEntityEvent")
|
|
||||||
|
|
||||||
defaultLib["AIObjective"] = CreateStatic("AIObjective")
|
|
||||||
defaultLib["AIObjectiveChargeBatteries"] = CreateStatic("AIObjectiveChargeBatteries")
|
|
||||||
defaultLib["AIObjectiveCleanupItem"] = CreateStatic("AIObjectiveCleanupItem")
|
|
||||||
defaultLib["AIObjectiveCleanupItems"] = CreateStatic("AIObjectiveCleanupItems")
|
|
||||||
defaultLib["AIObjectiveCombat"] = CreateStatic("AIObjectiveCombat")
|
|
||||||
defaultLib["AIObjectiveContainItem"] = CreateStatic("AIObjectiveContainItem")
|
|
||||||
defaultLib["AIObjectiveDecontainItem"] = CreateStatic("AIObjectiveDecontainItem")
|
|
||||||
defaultLib["AIObjectiveEscapeHandcuffs"] = CreateStatic("AIObjectiveEscapeHandcuffs")
|
|
||||||
defaultLib["AIObjectiveExtinguishFire"] = CreateStatic("AIObjectiveExtinguishFire")
|
|
||||||
defaultLib["AIObjectiveExtinguishFires"] = CreateStatic("AIObjectiveExtinguishFires")
|
|
||||||
defaultLib["AIObjectiveFightIntruders"] = CreateStatic("AIObjectiveFightIntruders")
|
|
||||||
defaultLib["AIObjectiveFindDivingGear"] = CreateStatic("AIObjectiveFindDivingGear")
|
|
||||||
defaultLib["AIObjectiveFindSafety"] = CreateStatic("AIObjectiveFindSafety")
|
|
||||||
defaultLib["AIObjectiveFixLeak"] = CreateStatic("AIObjectiveFixLeak")
|
|
||||||
defaultLib["AIObjectiveFixLeaks"] = CreateStatic("AIObjectiveFixLeaks")
|
|
||||||
defaultLib["AIObjectiveGetItem"] = CreateStatic("AIObjectiveGetItem")
|
|
||||||
defaultLib["AIObjectiveGoTo"] = CreateStatic("AIObjectiveGoTo")
|
|
||||||
defaultLib["AIObjectiveIdle"] = CreateStatic("AIObjectiveIdle")
|
|
||||||
defaultLib["AIObjectiveOperateItem"] = CreateStatic("AIObjectiveOperateItem")
|
|
||||||
defaultLib["AIObjectiveOperateItem"] = CreateStatic("AIObjectiveOperateItem")
|
|
||||||
defaultLib["AIObjectivePumpWater"] = CreateStatic("AIObjectivePumpWater")
|
|
||||||
defaultLib["AIObjectiveRepairItem"] = CreateStatic("AIObjectiveRepairItem")
|
|
||||||
defaultLib["AIObjectiveRepairItems"] = CreateStatic("AIObjectiveRepairItems")
|
|
||||||
defaultLib["AIObjectiveRescue"] = CreateStatic("AIObjectiveRescue")
|
|
||||||
defaultLib["AIObjectiveRescueAll"] = CreateStatic("AIObjectiveRescueAll")
|
|
||||||
defaultLib["AIObjectiveReturn"] = CreateStatic("AIObjectiveReturn")
|
|
||||||
defaultLib["CombatMode"] = CreateStatic("AIObjectiveCombat+CombatMode")
|
|
||||||
|
|
||||||
defaultLib["DisconnectReason"] = CreateStatic("Networking.DisconnectReason")
|
defaultLib["WayPoint"] = CreateStatic("Barotrauma.WayPoint", true)
|
||||||
|
defaultLib["Submarine"] = CreateStatic("Barotrauma.Submarine", true)
|
||||||
|
defaultLib["Client"] = CreateStatic("Barotrauma.Networking.Client", true)
|
||||||
|
defaultLib["Character"] = CreateStatic("Barotrauma.Character")
|
||||||
|
defaultLib["CharacterInfo"] = CreateStatic("Barotrauma.CharacterInfo", true)
|
||||||
|
defaultLib["Item"] = CreateStatic("Barotrauma.Item", true)
|
||||||
|
defaultLib["ItemPrefab"] = CreateStatic("Barotrauma.ItemPrefab", true)
|
||||||
|
defaultLib["Level"] = CreateStatic("Barotrauma.Level")
|
||||||
|
defaultLib["Job"] = CreateStatic("Barotrauma.Job", true)
|
||||||
|
defaultLib["JobPrefab"] = CreateStatic("Barotrauma.JobPrefab", true)
|
||||||
|
defaultLib["AfflictionPrefab"] = CreateStatic("Barotrauma.AfflictionPrefab", true)
|
||||||
|
defaultLib["ChatMessage"] = CreateStatic("Barotrauma.Networking.ChatMessage")
|
||||||
|
defaultLib["Hull"] = CreateStatic("Barotrauma.Hull", true)
|
||||||
|
defaultLib["Gap"] = CreateStatic("Barotrauma.Gap", true)
|
||||||
|
defaultLib["ContentPackage"] = CreateStatic("Barotrauma.ContentPackage", true)
|
||||||
|
defaultLib["Signal"] = CreateStatic("Barotrauma.Items.Components.Signal", true)
|
||||||
|
defaultLib["SubmarineInfo"] = CreateStatic("Barotrauma.SubmarineInfo", true)
|
||||||
|
defaultLib["Entity"] = CreateStatic("Barotrauma.Entity", true)
|
||||||
|
defaultLib["Physics"] = CreateStatic("Barotrauma.Physics")
|
||||||
|
defaultLib["FireSource"] = CreateStatic("Barotrauma.FireSource", true)
|
||||||
|
defaultLib["TextManager"] = CreateStatic("Barotrauma.TextManager")
|
||||||
|
defaultLib["NetEntityEvent"] = CreateStatic("Barotrauma.Networking.NetEntityEvent")
|
||||||
|
defaultLib["Screen"] = CreateStatic("Barotrauma.Screen")
|
||||||
|
|
||||||
|
defaultLib["AIObjective"] = CreateStatic("Barotrauma.AIObjective", true)
|
||||||
|
defaultLib["AIObjectiveChargeBatteries"] = CreateStatic("Barotrauma.AIObjectiveChargeBatteries", true)
|
||||||
|
defaultLib["AIObjectiveCleanupItem"] = CreateStatic("Barotrauma.AIObjectiveCleanupItem", true)
|
||||||
|
defaultLib["AIObjectiveCleanupItems"] = CreateStatic("Barotrauma.AIObjectiveCleanupItems", true)
|
||||||
|
defaultLib["AIObjectiveCombat"] = CreateStatic("Barotrauma.AIObjectiveCombat", true)
|
||||||
|
defaultLib["AIObjectiveContainItem"] = CreateStatic("Barotrauma.AIObjectiveContainItem", true)
|
||||||
|
defaultLib["AIObjectiveDecontainItem"] = CreateStatic("Barotrauma.AIObjectiveDecontainItem", true)
|
||||||
|
defaultLib["AIObjectiveEscapeHandcuffs"] = CreateStatic("Barotrauma.AIObjectiveEscapeHandcuffs", true)
|
||||||
|
defaultLib["AIObjectiveExtinguishFire"] = CreateStatic("Barotrauma.AIObjectiveExtinguishFire", true)
|
||||||
|
defaultLib["AIObjectiveExtinguishFires"] = CreateStatic("Barotrauma.AIObjectiveExtinguishFires", true)
|
||||||
|
defaultLib["AIObjectiveFightIntruders"] = CreateStatic("Barotrauma.AIObjectiveFightIntruders", true)
|
||||||
|
defaultLib["AIObjectiveFindDivingGear"] = CreateStatic("Barotrauma.AIObjectiveFindDivingGear", true)
|
||||||
|
defaultLib["AIObjectiveFindSafety"] = CreateStatic("Barotrauma.AIObjectiveFindSafety", true)
|
||||||
|
defaultLib["AIObjectiveFixLeak"] = CreateStatic("Barotrauma.AIObjectiveFixLeak", true)
|
||||||
|
defaultLib["AIObjectiveFixLeaks"] = CreateStatic("Barotrauma.AIObjectiveFixLeaks", true)
|
||||||
|
defaultLib["AIObjectiveGetItem"] = CreateStatic("Barotrauma.AIObjectiveGetItem", true)
|
||||||
|
defaultLib["AIObjectiveGoTo"] = CreateStatic("Barotrauma.AIObjectiveGoTo", true)
|
||||||
|
defaultLib["AIObjectiveIdle"] = CreateStatic("Barotrauma.AIObjectiveIdle", true)
|
||||||
|
defaultLib["AIObjectiveOperateItem"] = CreateStatic("Barotrauma.AIObjectiveOperateItem", true)
|
||||||
|
defaultLib["AIObjectiveOperateItem"] = CreateStatic("Barotrauma.AIObjectiveOperateItem", true)
|
||||||
|
defaultLib["AIObjectivePumpWater"] = CreateStatic("Barotrauma.AIObjectivePumpWater", true)
|
||||||
|
defaultLib["AIObjectiveRepairItem"] = CreateStatic("Barotrauma.AIObjectiveRepairItem", true)
|
||||||
|
defaultLib["AIObjectiveRepairItems"] = CreateStatic("Barotrauma.AIObjectiveRepairItems", true)
|
||||||
|
defaultLib["AIObjectiveRescue"] = CreateStatic("Barotrauma.AIObjectiveRescue", true)
|
||||||
|
defaultLib["AIObjectiveRescueAll"] = CreateStatic("Barotrauma.AIObjectiveRescueAll", true)
|
||||||
|
defaultLib["AIObjectiveReturn"] = CreateStatic("Barotrauma.AIObjectiveReturn", true)
|
||||||
|
|
||||||
|
defaultLib["Vector2"] = CreateStatic("Microsoft.Xna.Framework.Vector2")
|
||||||
|
defaultLib["Vector3"] = CreateStatic("Microsoft.Xna.Framework.Vector3", true)
|
||||||
|
defaultLib["Vector4"] = CreateStatic("Microsoft.Xna.Framework.Vector4", true)
|
||||||
|
defaultLib["Color"] = CreateStatic("Microsoft.Xna.Framework.Color", true)
|
||||||
|
defaultLib["Point"] = CreateStatic("Microsoft.Xna.Framework.Point", true)
|
||||||
|
defaultLib["Rectangle"] = CreateStatic("Microsoft.Xna.Framework.Rectangle", true)
|
||||||
|
|
||||||
if SERVER then
|
if SERVER then
|
||||||
|
|
||||||
elseif CLIENT then
|
elseif CLIENT then
|
||||||
defaultLib["Sprite"] = CreateStatic("Sprite")
|
defaultLib["Sprite"] = CreateStatic("Barotrauma.Sprite", true)
|
||||||
defaultLib["Keys"] = LuaUserData.CreateStatic("Microsoft.Xna.Framework.Input.Keys")
|
defaultLib["PlayerInput"] = CreateStatic("Barotrauma.PlayerInput", true)
|
||||||
defaultLib["PlayerInput"] = CreateStatic("PlayerInput")
|
|
||||||
|
|
||||||
GUI.CreateStaticValues()
|
defaultLib["Keys"] = CreateStatic("Microsoft.Xna.Framework.Input.Keys", true)
|
||||||
|
|
||||||
|
defaultLib["GUI"] = {
|
||||||
|
RectTransform = CreateStatic("Barotrauma.RectTransform, true", true),
|
||||||
|
LayoutGroup = CreateStatic("Barotrauma.GUILayoutGroup", true),
|
||||||
|
Button = CreateStatic("Barotrauma.GUIButton", true),
|
||||||
|
TextBox = CreateStatic("Barotrauma.GUITextBox", true),
|
||||||
|
Canvas = CreateStatic("Barotrauma.GUICanvas", true),
|
||||||
|
Frame = CreateStatic("Barotrauma.GUIFrame", true),
|
||||||
|
TextBlock = CreateStatic("Barotrauma.GUITextBlock", true),
|
||||||
|
TickBox = CreateStatic("Barotrauma.GUITickBox", true),
|
||||||
|
Image = CreateStatic("Barotrauma.GUIImage", true),
|
||||||
|
ListBox = CreateStatic("Barotrauma.GUIListBox", true),
|
||||||
|
ScrollBar = CreateStatic("Barotrauma.GUIScrollBar", true),
|
||||||
|
DropDown = CreateStatic("Barotrauma.GUIDropDown", true),
|
||||||
|
|
||||||
|
Screen = CreateStatic("Barotrauma.Screen"),
|
||||||
|
|
||||||
|
Anchor = CreateStatic("Barotrauma.Anchor"),
|
||||||
|
Alignment = CreateStatic("Barotrauma.Alignment"),
|
||||||
|
Pivot = CreateStatic("Barotrauma.Pivot"),
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
return defaultLib
|
return defaultLib
|
||||||
|
|||||||
@@ -2,14 +2,16 @@ local function RegisterBarotrauma(typeName)
|
|||||||
return LuaUserData.RegisterType("Barotrauma." .. typeName)
|
return LuaUserData.RegisterType("Barotrauma." .. typeName)
|
||||||
end
|
end
|
||||||
|
|
||||||
local AddCallMetaMember = LuaUserData.AddCallMetaMember
|
|
||||||
|
|
||||||
LuaUserData.RegisterType("System.TimeSpan")
|
LuaUserData.RegisterType("System.TimeSpan")
|
||||||
|
|
||||||
if SERVER then
|
if SERVER then
|
||||||
RegisterBarotrauma("Networking.GameServer")
|
RegisterBarotrauma("Networking.GameServer")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
RegisterBarotrauma("LuaByte")
|
||||||
|
RegisterBarotrauma("LuaUShort")
|
||||||
|
RegisterBarotrauma("LuaFloat")
|
||||||
|
|
||||||
RegisterBarotrauma("CauseOfDeathType")
|
RegisterBarotrauma("CauseOfDeathType")
|
||||||
RegisterBarotrauma("Level+InterestingPosition")
|
RegisterBarotrauma("Level+InterestingPosition")
|
||||||
RegisterBarotrauma("Level+PositionType")
|
RegisterBarotrauma("Level+PositionType")
|
||||||
@@ -18,7 +20,7 @@ RegisterBarotrauma("SpawnType")
|
|||||||
RegisterBarotrauma("Networking.ChatMessageType")
|
RegisterBarotrauma("Networking.ChatMessageType")
|
||||||
RegisterBarotrauma("InputType")
|
RegisterBarotrauma("InputType")
|
||||||
|
|
||||||
AddCallMetaMember(RegisterBarotrauma("Job"))
|
RegisterBarotrauma("Job")
|
||||||
RegisterBarotrauma("JobPrefab")
|
RegisterBarotrauma("JobPrefab")
|
||||||
RegisterBarotrauma("Level")
|
RegisterBarotrauma("Level")
|
||||||
RegisterBarotrauma("Networking.ServerLog+MessageType")
|
RegisterBarotrauma("Networking.ServerLog+MessageType")
|
||||||
@@ -64,7 +66,7 @@ RegisterBarotrauma("Networking.ServerSettings")
|
|||||||
RegisterBarotrauma("Networking.ServerSettings+SavedClientPermission")
|
RegisterBarotrauma("Networking.ServerSettings+SavedClientPermission")
|
||||||
RegisterBarotrauma("Inventory")
|
RegisterBarotrauma("Inventory")
|
||||||
RegisterBarotrauma("ItemInventory")
|
RegisterBarotrauma("ItemInventory")
|
||||||
AddCallMetaMember(RegisterBarotrauma("FireSource"))
|
RegisterBarotrauma("FireSource")
|
||||||
|
|
||||||
RegisterBarotrauma("Items.Components.Connection")
|
RegisterBarotrauma("Items.Components.Connection")
|
||||||
RegisterBarotrauma("Items.Components.Fabricator")
|
RegisterBarotrauma("Items.Components.Fabricator")
|
||||||
@@ -129,32 +131,32 @@ RegisterBarotrauma("AITrigger")
|
|||||||
RegisterBarotrauma("WreckAI")
|
RegisterBarotrauma("WreckAI")
|
||||||
RegisterBarotrauma("WreckAIConfig")
|
RegisterBarotrauma("WreckAIConfig")
|
||||||
|
|
||||||
AddCallMetaMember(RegisterBarotrauma("AIObjective"))
|
RegisterBarotrauma("AIObjectiveChargeBatteries")
|
||||||
AddCallMetaMember(RegisterBarotrauma("AIObjectiveChargeBatteries"))
|
RegisterBarotrauma("AIObjective")
|
||||||
AddCallMetaMember(RegisterBarotrauma("AIObjectiveCleanupItem"))
|
RegisterBarotrauma("AIObjectiveCleanupItem")
|
||||||
AddCallMetaMember(RegisterBarotrauma("AIObjectiveCleanupItems"))
|
RegisterBarotrauma("AIObjectiveCleanupItems")
|
||||||
AddCallMetaMember(RegisterBarotrauma("AIObjectiveCombat"))
|
RegisterBarotrauma("AIObjectiveCombat")
|
||||||
AddCallMetaMember(RegisterBarotrauma("AIObjectiveContainItem"))
|
RegisterBarotrauma("AIObjectiveContainItem")
|
||||||
AddCallMetaMember(RegisterBarotrauma("AIObjectiveDecontainItem"))
|
RegisterBarotrauma("AIObjectiveDecontainItem")
|
||||||
AddCallMetaMember(RegisterBarotrauma("AIObjectiveEscapeHandcuffs"))
|
RegisterBarotrauma("AIObjectiveEscapeHandcuffs")
|
||||||
AddCallMetaMember(RegisterBarotrauma("AIObjectiveExtinguishFire"))
|
RegisterBarotrauma("AIObjectiveExtinguishFire")
|
||||||
AddCallMetaMember(RegisterBarotrauma("AIObjectiveExtinguishFires"))
|
RegisterBarotrauma("AIObjectiveExtinguishFires")
|
||||||
AddCallMetaMember(RegisterBarotrauma("AIObjectiveFightIntruders"))
|
RegisterBarotrauma("AIObjectiveFightIntruders")
|
||||||
AddCallMetaMember(RegisterBarotrauma("AIObjectiveFindDivingGear"))
|
RegisterBarotrauma("AIObjectiveFindDivingGear")
|
||||||
AddCallMetaMember(RegisterBarotrauma("AIObjectiveFindSafety"))
|
RegisterBarotrauma("AIObjectiveFindSafety")
|
||||||
AddCallMetaMember(RegisterBarotrauma("AIObjectiveFixLeak"))
|
RegisterBarotrauma("AIObjectiveFixLeak")
|
||||||
AddCallMetaMember(RegisterBarotrauma("AIObjectiveFixLeaks"))
|
RegisterBarotrauma("AIObjectiveFixLeaks")
|
||||||
AddCallMetaMember(RegisterBarotrauma("AIObjectiveGetItem"))
|
RegisterBarotrauma("AIObjectiveGetItem")
|
||||||
AddCallMetaMember(RegisterBarotrauma("AIObjectiveGoTo"))
|
RegisterBarotrauma("AIObjectiveGoTo")
|
||||||
AddCallMetaMember(RegisterBarotrauma("AIObjectiveIdle"))
|
RegisterBarotrauma("AIObjectiveIdle")
|
||||||
AddCallMetaMember(RegisterBarotrauma("AIObjectiveOperateItem"))
|
RegisterBarotrauma("AIObjectiveOperateItem")
|
||||||
AddCallMetaMember(RegisterBarotrauma("AIObjectiveOperateItem"))
|
RegisterBarotrauma("AIObjectiveOperateItem")
|
||||||
AddCallMetaMember(RegisterBarotrauma("AIObjectivePumpWater"))
|
RegisterBarotrauma("AIObjectivePumpWater")
|
||||||
AddCallMetaMember(RegisterBarotrauma("AIObjectiveRepairItem"))
|
RegisterBarotrauma("AIObjectiveRepairItem")
|
||||||
AddCallMetaMember(RegisterBarotrauma("AIObjectiveRepairItems"))
|
RegisterBarotrauma("AIObjectiveRepairItems")
|
||||||
AddCallMetaMember(RegisterBarotrauma("AIObjectiveRescue"))
|
RegisterBarotrauma("AIObjectiveRescue")
|
||||||
AddCallMetaMember(RegisterBarotrauma("AIObjectiveRescueAll"))
|
RegisterBarotrauma("AIObjectiveRescueAll")
|
||||||
AddCallMetaMember(RegisterBarotrauma("AIObjectiveReturn"))
|
RegisterBarotrauma("AIObjectiveReturn")
|
||||||
RegisterBarotrauma("AIObjectiveCombat+CombatMode")
|
RegisterBarotrauma("AIObjectiveCombat+CombatMode")
|
||||||
|
|
||||||
RegisterBarotrauma("TalentPrefab")
|
RegisterBarotrauma("TalentPrefab")
|
||||||
@@ -224,19 +226,19 @@ RegisterBarotrauma("Pair`2[[Barotrauma.JobPrefab],[System.Int32]]")
|
|||||||
|
|
||||||
RegisterBarotrauma("Range`1[System.Single]")
|
RegisterBarotrauma("Range`1[System.Single]")
|
||||||
|
|
||||||
AddCallMetaMember(RegisterBarotrauma("CharacterInfo"))
|
RegisterBarotrauma("CharacterInfo")
|
||||||
AddCallMetaMember(RegisterBarotrauma("Items.Components.Signal"))
|
RegisterBarotrauma("Items.Components.Signal")
|
||||||
AddCallMetaMember(RegisterBarotrauma("SubmarineInfo"))
|
RegisterBarotrauma("SubmarineInfo")
|
||||||
|
|
||||||
RegisterBarotrauma("MapCreatures.Behavior.BallastFloraBehavior")
|
RegisterBarotrauma("MapCreatures.Behavior.BallastFloraBehavior")
|
||||||
RegisterBarotrauma("MapCreatures.Behavior.BallastFloraBranch")
|
RegisterBarotrauma("MapCreatures.Behavior.BallastFloraBranch")
|
||||||
|
|
||||||
AddCallMetaMember(LuaUserData.RegisterType("Microsoft.Xna.Framework.Vector2"))
|
LuaUserData.RegisterType("Microsoft.Xna.Framework.Vector2")
|
||||||
AddCallMetaMember(LuaUserData.RegisterType("Microsoft.Xna.Framework.Vector3"))
|
LuaUserData.RegisterType("Microsoft.Xna.Framework.Vector3")
|
||||||
AddCallMetaMember(LuaUserData.RegisterType("Microsoft.Xna.Framework.Vector4"))
|
LuaUserData.RegisterType("Microsoft.Xna.Framework.Vector4")
|
||||||
AddCallMetaMember(LuaUserData.RegisterType("Microsoft.Xna.Framework.Color"))
|
LuaUserData.RegisterType("Microsoft.Xna.Framework.Color")
|
||||||
AddCallMetaMember(LuaUserData.RegisterType("Microsoft.Xna.Framework.Point"))
|
LuaUserData.RegisterType("Microsoft.Xna.Framework.Point")
|
||||||
AddCallMetaMember(LuaUserData.RegisterType("Microsoft.Xna.Framework.Rectangle"))
|
LuaUserData.RegisterType("Microsoft.Xna.Framework.Rectangle")
|
||||||
|
|
||||||
if SERVER then
|
if SERVER then
|
||||||
RegisterBarotrauma("Networking.ServerPeer")
|
RegisterBarotrauma("Networking.ServerPeer")
|
||||||
@@ -262,18 +264,18 @@ LuaUserData.RegisterType("Microsoft.Xna.Framework.Graphics.Texture2D")
|
|||||||
LuaUserData.RegisterType("EventInput.KeyEventArgs")
|
LuaUserData.RegisterType("EventInput.KeyEventArgs")
|
||||||
LuaUserData.RegisterType("Microsoft.Xna.Framework.Input.Keys")
|
LuaUserData.RegisterType("Microsoft.Xna.Framework.Input.Keys")
|
||||||
|
|
||||||
AddCallMetaMember(RegisterBarotrauma("Sprite"))
|
RegisterBarotrauma("Sprite")
|
||||||
AddCallMetaMember(RegisterBarotrauma("GUILayoutGroup"))
|
RegisterBarotrauma("GUILayoutGroup")
|
||||||
AddCallMetaMember(RegisterBarotrauma("GUITextBox"))
|
RegisterBarotrauma("GUITextBox")
|
||||||
AddCallMetaMember(RegisterBarotrauma("GUITextBlock"))
|
RegisterBarotrauma("GUITextBlock")
|
||||||
AddCallMetaMember(RegisterBarotrauma("GUIButton"))
|
RegisterBarotrauma("GUIButton")
|
||||||
AddCallMetaMember(RegisterBarotrauma("RectTransform"))
|
RegisterBarotrauma("RectTransform")
|
||||||
AddCallMetaMember(RegisterBarotrauma("GUIFrame"))
|
RegisterBarotrauma("GUIFrame")
|
||||||
AddCallMetaMember(RegisterBarotrauma("GUITickBox"))
|
RegisterBarotrauma("GUITickBox")
|
||||||
AddCallMetaMember(RegisterBarotrauma("GUICustomComponent"))
|
RegisterBarotrauma("GUICustomComponent")
|
||||||
AddCallMetaMember(RegisterBarotrauma("GUIImage"))
|
RegisterBarotrauma("GUIImage")
|
||||||
AddCallMetaMember(RegisterBarotrauma("GUIListBox"))
|
RegisterBarotrauma("GUIListBox")
|
||||||
AddCallMetaMember(RegisterBarotrauma("GUIScrollBar"))
|
RegisterBarotrauma("GUIScrollBar")
|
||||||
AddCallMetaMember(RegisterBarotrauma("GUIDropDown"))
|
RegisterBarotrauma("GUIDropDown")
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -17,7 +17,6 @@ using System.Diagnostics;
|
|||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
|
|
||||||
partial class LuaSetup
|
partial class LuaSetup
|
||||||
{
|
{
|
||||||
partial class LuaUserData
|
partial class LuaUserData
|
||||||
@@ -39,6 +38,12 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
Type type = GetType(typeName);
|
Type type = GetType(typeName);
|
||||||
|
|
||||||
|
if (type == null)
|
||||||
|
{
|
||||||
|
GameMain.Lua.HandleLuaException(new Exception($"Tried to register a type that doesn't exist: {typeName}."));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
MethodInfo method = typeof(UserData).GetMethod(nameof(UserData.RegisterType), new Type[2] { typeof(InteropAccessMode), typeof(string) });
|
MethodInfo method = typeof(UserData).GetMethod(nameof(UserData.RegisterType), new Type[2] { typeof(InteropAccessMode), typeof(string) });
|
||||||
MethodInfo generic = method.MakeGenericMethod(type);
|
MethodInfo generic = method.MakeGenericMethod(type);
|
||||||
return (IUserDataDescriptor)generic.Invoke(null, new object[] { null, null });
|
return (IUserDataDescriptor)generic.Invoke(null, new object[] { null, null });
|
||||||
@@ -48,6 +53,12 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
Type type = GetType(typeName);
|
Type type = GetType(typeName);
|
||||||
|
|
||||||
|
if (type == null)
|
||||||
|
{
|
||||||
|
GameMain.Lua.HandleLuaException(new Exception($"Tried to unregister a type that doesn't exist: {typeName}."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
MethodInfo method = typeof(UserData).GetMethod(nameof(UserData.UnregisterType), new Type[2] { typeof(InteropAccessMode), typeof(string) });
|
MethodInfo method = typeof(UserData).GetMethod(nameof(UserData.UnregisterType), new Type[2] { typeof(InteropAccessMode), typeof(string) });
|
||||||
MethodInfo generic = method.MakeGenericMethod(type);
|
MethodInfo generic = method.MakeGenericMethod(type);
|
||||||
generic.Invoke(null, new object[] { null, null });
|
generic.Invoke(null, new object[] { null, null });
|
||||||
@@ -82,18 +93,17 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
Type type = GetType(typeName);
|
Type type = GetType(typeName);
|
||||||
|
|
||||||
|
if (type == null)
|
||||||
|
{
|
||||||
|
GameMain.Lua.HandleLuaException(new Exception($"Tried to create a static userdata of a type that doesn't exist: {typeName}."));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
MethodInfo method = typeof(UserData).GetMethod(nameof(UserData.CreateStatic), 1, new Type[0]);
|
MethodInfo method = typeof(UserData).GetMethod(nameof(UserData.CreateStatic), 1, new Type[0]);
|
||||||
MethodInfo generic = method.MakeGenericMethod(type);
|
MethodInfo generic = method.MakeGenericMethod(type);
|
||||||
return generic.Invoke(null, null);
|
return generic.Invoke(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddCallMetaMember(IUserDataDescriptor IUDD)
|
|
||||||
{
|
|
||||||
var descriptor = (StandardUserDataDescriptor)IUDD;
|
|
||||||
descriptor.RemoveMetaMember("__call");
|
|
||||||
descriptor.AddMetaMember("__call", new ObjectCallbackMemberDescriptor("__call", LuaSetup.luaSetup.HandleCall));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void MakeFieldAccessible(IUserDataDescriptor IUUD, string fieldName)
|
public static void MakeFieldAccessible(IUserDataDescriptor IUUD, string fieldName)
|
||||||
{
|
{
|
||||||
var descriptor = (StandardUserDataDescriptor)IUUD;
|
var descriptor = (StandardUserDataDescriptor)IUUD;
|
||||||
|
|||||||
@@ -5,56 +5,4 @@ using Barotrauma.Networking;
|
|||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
|
|
||||||
partial class LuaSetup
|
|
||||||
{
|
|
||||||
public class LuaWriteOnlyMessage
|
|
||||||
{
|
|
||||||
private WriteOnlyMessage target;
|
|
||||||
|
|
||||||
[MoonSharpHidden]
|
|
||||||
public LuaWriteOnlyMessage(WriteOnlyMessage p)
|
|
||||||
{
|
|
||||||
target = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void WriteByte(byte v) => target.Write(v);
|
|
||||||
public void WriteUShort(ushort v) => target.Write(v);
|
|
||||||
|
|
||||||
public void Write(bool val) => target.Write(val);
|
|
||||||
public void WritePadBits() => target.WritePadBits();
|
|
||||||
public void Write(byte val) => target.Write(val);
|
|
||||||
public void Write(Int16 val) => target.Write(val);
|
|
||||||
public void Write(UInt16 val) => target.Write(val);
|
|
||||||
public void Write(Int32 val) => target.Write(val);
|
|
||||||
public void Write(UInt32 val) => target.Write(val);
|
|
||||||
public void Write(Int64 val) => target.Write(val);
|
|
||||||
public void Write(UInt64 val) => target.Write(val);
|
|
||||||
public void Write(Single val) => target.Write(val);
|
|
||||||
public void Write(Double val) => target.Write(val);
|
|
||||||
public void WriteColorR8G8B8(Microsoft.Xna.Framework.Color val) => target.WriteColorR8G8B8(val);
|
|
||||||
public void WriteColorR8G8B8A8(Microsoft.Xna.Framework.Color val) => target.WriteColorR8G8B8A8(val);
|
|
||||||
public void WriteVariableUInt32(UInt32 val) => target.WriteVariableUInt32(val);
|
|
||||||
public void Write(string val) => target.Write(val);
|
|
||||||
public void WriteRangedInteger(int val, int min, int max) => target.WriteRangedInteger(val, min, max);
|
|
||||||
public void WriteRangedSingle(Single val, Single min, Single max, int bitCount) => target.WriteRangedSingle(val, min, max, bitCount);
|
|
||||||
public void Write(byte[] val, int startIndex, int length) => target.Write(val, startIndex, length);
|
|
||||||
|
|
||||||
public void PrepareForSending(ref byte[] outBuf, out bool isCompressed, out int outLength) => target.PrepareForSending(ref outBuf, out isCompressed, out outLength);
|
|
||||||
|
|
||||||
public int BitPosition
|
|
||||||
{
|
|
||||||
get { return target.BitPosition; }
|
|
||||||
set { target.BitPosition = value; }
|
|
||||||
}
|
|
||||||
public int BytePosition => target.BytePosition;
|
|
||||||
public byte[] Buffer => target.Buffer;
|
|
||||||
public int LengthBits
|
|
||||||
{
|
|
||||||
get { return target.LengthBits; }
|
|
||||||
set { target.LengthBits = value; }
|
|
||||||
}
|
|
||||||
public int LengthBytes => target.LengthBytes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -222,41 +222,6 @@ namespace Barotrauma
|
|||||||
return value * 2;
|
return value * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// messy solution
|
|
||||||
public object HandleCall(object arg1, ScriptExecutionContext arg2, CallbackArguments arg3)
|
|
||||||
{
|
|
||||||
|
|
||||||
var what = arg3.RawGet(0, true);
|
|
||||||
|
|
||||||
var code = "return " + what.UserData.Descriptor.Type.Name + ".__new(";
|
|
||||||
|
|
||||||
var tbl = new Table(lua);
|
|
||||||
tbl[what.UserData.Descriptor.Type.Name] = what;
|
|
||||||
|
|
||||||
for(var i=1; i < arg3.Count; i++)
|
|
||||||
{
|
|
||||||
if (i == arg3.Count - 1)
|
|
||||||
code = code + "arg" + i;
|
|
||||||
else
|
|
||||||
code = code + "arg" + i + ",";
|
|
||||||
|
|
||||||
tbl["arg" + i] = arg3.RawGet(i, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
code = code + ")";
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return lua.DoString(code, tbl);
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
HandleLuaException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if SERVER
|
#if SERVER
|
||||||
public static void InstallClientSideLua()
|
public static void InstallClientSideLua()
|
||||||
@@ -324,7 +289,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
LuaCustomConverters.RegisterAll();
|
LuaCustomConverters.RegisterAll();
|
||||||
|
|
||||||
lua = new Script(CoreModules.Preset_SoftSandbox);
|
lua = new Script(CoreModules.Preset_SoftSandbox | CoreModules.Debug);
|
||||||
lua.Options.DebugPrint = PrintMessage;
|
lua.Options.DebugPrint = PrintMessage;
|
||||||
lua.Options.ScriptLoader = luaScriptLoader;
|
lua.Options.ScriptLoader = luaScriptLoader;
|
||||||
|
|
||||||
@@ -344,14 +309,6 @@ namespace Barotrauma
|
|||||||
UserData.RegisterType<LuaUserData>();
|
UserData.RegisterType<LuaUserData>();
|
||||||
UserData.RegisterType<IUserDataDescriptor>();
|
UserData.RegisterType<IUserDataDescriptor>();
|
||||||
|
|
||||||
UserData.RegisterProxyType<LuaWriteOnlyMessage, WriteOnlyMessage>(r => new LuaWriteOnlyMessage(r));
|
|
||||||
|
|
||||||
#if SERVER
|
|
||||||
|
|
||||||
#elif CLIENT
|
|
||||||
UserData.RegisterType<LuaGUI>();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
lua.Globals["setmodulepaths"] = (Action<string[]>)SetModulePaths;
|
lua.Globals["setmodulepaths"] = (Action<string[]>)SetModulePaths;
|
||||||
|
|
||||||
lua.Globals["TestFunction"] = (Func<float, float>)TestFunction;
|
lua.Globals["TestFunction"] = (Func<float, float>)TestFunction;
|
||||||
@@ -364,7 +321,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
lua.Globals["dostring"] = (Func<string, Table, string, DynValue>)DoString;
|
lua.Globals["dostring"] = (Func<string, Table, string, DynValue>)DoString;
|
||||||
lua.Globals["load"] = (Func<string, Table, string, DynValue>)LoadString;
|
lua.Globals["load"] = (Func<string, Table, string, DynValue>)LoadString;
|
||||||
|
|
||||||
lua.Globals["LuaUserData"] = UserData.CreateStatic<LuaUserData>();
|
lua.Globals["LuaUserData"] = UserData.CreateStatic<LuaUserData>();
|
||||||
lua.Globals["Game"] = game;
|
lua.Globals["Game"] = game;
|
||||||
lua.Globals["Hook"] = hook;
|
lua.Globals["Hook"] = hook;
|
||||||
@@ -373,12 +330,6 @@ namespace Barotrauma
|
|||||||
lua.Globals["File"] = UserData.CreateStatic<LuaFile>();
|
lua.Globals["File"] = UserData.CreateStatic<LuaFile>();
|
||||||
lua.Globals["Networking"] = networking;
|
lua.Globals["Networking"] = networking;
|
||||||
|
|
||||||
#if SERVER
|
|
||||||
|
|
||||||
#elif CLIENT
|
|
||||||
lua.Globals["GUI"] = new LuaGUI(this);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool isServer = true;
|
bool isServer = true;
|
||||||
|
|
||||||
#if SERVER
|
#if SERVER
|
||||||
@@ -397,7 +348,7 @@ namespace Barotrauma
|
|||||||
else if (File.Exists("Mods/LuaForBarotrauma/Lua/LuaSetup.lua")) // in case its the workshop version
|
else if (File.Exists("Mods/LuaForBarotrauma/Lua/LuaSetup.lua")) // in case its the workshop version
|
||||||
DoFile("Mods/LuaForBarotrauma/Lua/LuaSetup.lua");
|
DoFile("Mods/LuaForBarotrauma/Lua/LuaSetup.lua");
|
||||||
else
|
else
|
||||||
PrintError("Lua loader not found! Lua/LuaSetup.lua, no lua scripts will be executed or work.");
|
PrintError("Lua loader not found! Lua/LuaSetup.lua, no Lua scripts will be executed or work.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public LuaSetup()
|
public LuaSetup()
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace Barotrauma
|
||||||
|
{
|
||||||
|
public class LuaByte
|
||||||
|
{
|
||||||
|
public byte Value;
|
||||||
|
|
||||||
|
public LuaByte(byte v)
|
||||||
|
{
|
||||||
|
Value = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator byte(LuaByte lb) => lb.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class LuaUShort
|
||||||
|
{
|
||||||
|
public ushort Value;
|
||||||
|
|
||||||
|
public LuaUShort(ushort v)
|
||||||
|
{
|
||||||
|
Value = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator ushort(LuaUShort lb) => lb.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class LuaFloat
|
||||||
|
{
|
||||||
|
public float Value;
|
||||||
|
|
||||||
|
public LuaFloat(float v)
|
||||||
|
{
|
||||||
|
Value = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator float(LuaFloat lb) => lb.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
Reference in New Issue
Block a user