organize better default Lua stuff
This commit is contained in:
@@ -0,0 +1,43 @@
|
|||||||
|
local defaultLib = {}
|
||||||
|
|
||||||
|
local CreateStatic = LuaSetup.CreateStatic
|
||||||
|
local CreateEnum = LuaUserData.CreateEnumTable
|
||||||
|
|
||||||
|
local localizedStrings = {
|
||||||
|
"LocalizedString", "LimitLString", "WrappedLString", "AddedPunctuationLString", "CapitalizeLString", "ConcatLString", "FallbackLString", "FormattedLString", "InputTypeLString", "JoinLString", "LowerLString", "RawLString", "ReplaceLString", "ServerMsgLString", "SplitLString", "TagLString", "TrimLString", "UpperLString", "StripRichTagsLString",
|
||||||
|
}
|
||||||
|
|
||||||
|
for key, value in pairs(localizedStrings) do
|
||||||
|
defaultLib[value] = CreateStatic("Barotrauma." .. value, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
defaultLib["Sprite"] = CreateStatic("Barotrauma.Sprite", true)
|
||||||
|
defaultLib["PlayerInput"] = CreateStatic("Barotrauma.PlayerInput", true)
|
||||||
|
|
||||||
|
defaultLib["Keys"] = CreateStatic("Microsoft.Xna.Framework.Input.Keys", true)
|
||||||
|
|
||||||
|
defaultLib["GUI"] = {
|
||||||
|
GUI = CreateStatic("Barotrauma.GUI", true),
|
||||||
|
GUIStyle = CreateStatic("Barotrauma.GUIStyle", true),
|
||||||
|
RectTransform = CreateStatic("Barotrauma.RectTransform", 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),
|
||||||
|
NumberInput = CreateStatic("Barotrauma.GUINumberInput", true),
|
||||||
|
|
||||||
|
Screen = CreateStatic("Barotrauma.Screen"),
|
||||||
|
|
||||||
|
Anchor = CreateStatic("Barotrauma.Anchor"),
|
||||||
|
Alignment = CreateStatic("Barotrauma.Alignment"),
|
||||||
|
Pivot = CreateStatic("Barotrauma.Pivot"),
|
||||||
|
}
|
||||||
|
|
||||||
|
return defaultLib
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
local defaultLib = {}
|
||||||
|
|
||||||
|
local CreateStatic = LuaSetup.CreateStatic
|
||||||
|
local CreateEnum = LuaUserData.CreateEnumTable
|
||||||
|
|
||||||
|
local localizedStrings = {
|
||||||
|
"LocalizedString", "AddedPunctuationLString", "CapitalizeLString", "ConcatLString", "FallbackLString", "FormattedLString", "InputTypeLString", "JoinLString", "LowerLString", "RawLString", "ReplaceLString", "ServerMsgLString", "SplitLString", "TagLString", "TrimLString", "UpperLString", "StripRichTagsLString",
|
||||||
|
}
|
||||||
|
|
||||||
|
for key, value in pairs(localizedStrings) do
|
||||||
|
defaultLib[value] = CreateStatic("Barotrauma." .. value, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
return defaultLib
|
||||||
+3
-59
@@ -1,31 +1,8 @@
|
|||||||
local defaultLib = {}
|
local defaultLib = {}
|
||||||
|
|
||||||
local descriptors = require("DefaultRegister")
|
local CreateStatic = LuaSetup.CreateStatic
|
||||||
|
|
||||||
local CreateStatic = function (typeName, addCallMethod)
|
|
||||||
local staticUserdata = LuaUserData.CreateStatic(typeName)
|
|
||||||
|
|
||||||
if addCallMethod then
|
|
||||||
debug.setmetatable(staticUserdata, {
|
|
||||||
__call = function(obj, ...)
|
|
||||||
local success, result = pcall(staticUserdata.__new, ...)
|
|
||||||
|
|
||||||
if not success then
|
|
||||||
error(result, 2)
|
|
||||||
end
|
|
||||||
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
return staticUserdata
|
|
||||||
end
|
|
||||||
|
|
||||||
local CreateEnum = LuaUserData.CreateEnumTable
|
local CreateEnum = LuaUserData.CreateEnumTable
|
||||||
|
|
||||||
defaultLib["Descriptors"] = descriptors
|
|
||||||
|
|
||||||
defaultLib["Byte"] = CreateStatic("Barotrauma.LuaByte", true)
|
defaultLib["Byte"] = CreateStatic("Barotrauma.LuaByte", true)
|
||||||
defaultLib["UShort"] = CreateStatic("Barotrauma.LuaUShort", true)
|
defaultLib["UShort"] = CreateStatic("Barotrauma.LuaUShort", true)
|
||||||
defaultLib["Float"] = CreateStatic("Barotrauma.LuaFloat", true)
|
defaultLib["Float"] = CreateStatic("Barotrauma.LuaFloat", true)
|
||||||
@@ -115,12 +92,12 @@ defaultLib["AIObjectiveRescue"] = CreateStatic("Barotrauma.AIObjectiveRescue", t
|
|||||||
defaultLib["AIObjectiveRescueAll"] = CreateStatic("Barotrauma.AIObjectiveRescueAll", true)
|
defaultLib["AIObjectiveRescueAll"] = CreateStatic("Barotrauma.AIObjectiveRescueAll", true)
|
||||||
defaultLib["AIObjectiveReturn"] = CreateStatic("Barotrauma.AIObjectiveReturn", true)
|
defaultLib["AIObjectiveReturn"] = CreateStatic("Barotrauma.AIObjectiveReturn", true)
|
||||||
|
|
||||||
local barotraumaComponentsToReference = { "DockingPort", "Door", "GeneticMaterial", "Growable", "Holdable", "LevelResource", "ItemComponent", "ItemLabel", "LightComponent", "Controller", "Deconstructor", "Engine", "Fabricator", "OutpostTerminal", "Pump", "Reactor", "Steering", "PowerContainer", "Projectile", "Repairable", "Rope", "Scanner", "ButtonTerminal", "ConnectionPanel", "CustomInterface", "MemoryComponent", "Terminal", "WifiComponent", "Wire", "TriggerComponent", "ElectricalDischarger", "EntitySpawnerComponent", "ProducedItem", "VineTile", "GrowthSideExtension", "IdCard", "MeleeWeapon", "Pickable", "Propulsion", "RangedWeapon", "RepairTool", "Sprayer", "Throwable", "ItemContainer", "Ladder", "LimbPos", "MiniMap", "OxygenGenerator", "Sonar", "SonarTransducer", "Vent", "NameTag", "Planter", "Powered", "PowerTransfer", "Quality", "RemoteController", "AdderComponent", "AndComponent", "ArithmeticComponent", "ColorComponent", "ConcatComponent", "Connection", "DelayComponent", "DivideComponent", "EqualsComponent", "ExponentiationComponent", "FunctionComponent", "GreaterComponent", "ModuloComponent", "MotionSensor", "MultiplyComponent", "NotComponent", "OrComponent", "OscillatorComponent", "OxygenDetector", "RegExFindComponent", "RelayComponent", "SignalCheckComponent", "SmokeDetector", "StringComponent", "SubtractComponent", "TrigonometricFunctionComponent", "WaterDetector", "XorComponent", "StatusHUD", "Turret", "Wearable", "CustomInterface"
|
local componentsToReference = { "DockingPort", "Door", "GeneticMaterial", "Growable", "Holdable", "LevelResource", "ItemComponent", "ItemLabel", "LightComponent", "Controller", "Deconstructor", "Engine", "Fabricator", "OutpostTerminal", "Pump", "Reactor", "Steering", "PowerContainer", "Projectile", "Repairable", "Rope", "Scanner", "ButtonTerminal", "ConnectionPanel", "CustomInterface", "MemoryComponent", "Terminal", "WifiComponent", "Wire", "TriggerComponent", "ElectricalDischarger", "EntitySpawnerComponent", "ProducedItem", "VineTile", "GrowthSideExtension", "IdCard", "MeleeWeapon", "Pickable", "Propulsion", "RangedWeapon", "RepairTool", "Sprayer", "Throwable", "ItemContainer", "Ladder", "LimbPos", "MiniMap", "OxygenGenerator", "Sonar", "SonarTransducer", "Vent", "NameTag", "Planter", "Powered", "PowerTransfer", "Quality", "RemoteController", "AdderComponent", "AndComponent", "ArithmeticComponent", "ColorComponent", "ConcatComponent", "Connection", "DelayComponent", "DivideComponent", "EqualsComponent", "ExponentiationComponent", "FunctionComponent", "GreaterComponent", "ModuloComponent", "MotionSensor", "MultiplyComponent", "NotComponent", "OrComponent", "OscillatorComponent", "OxygenDetector", "RegExFindComponent", "RelayComponent", "SignalCheckComponent", "SmokeDetector", "StringComponent", "SubtractComponent", "TrigonometricFunctionComponent", "WaterDetector", "XorComponent", "StatusHUD", "Turret", "Wearable", "CustomInterface"
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultLib["Components"] = {}
|
defaultLib["Components"] = {}
|
||||||
|
|
||||||
for key, value in pairs(barotraumaComponentsToReference) do
|
for key, value in pairs(componentsToReference) do
|
||||||
defaultLib["Components"][value] = CreateStatic("Barotrauma.Items.Components." .. value, true)
|
defaultLib["Components"][value] = CreateStatic("Barotrauma.Items.Components." .. value, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -132,37 +109,4 @@ defaultLib["Point"] = CreateStatic("Microsoft.Xna.Framework.Point", true)
|
|||||||
defaultLib["Rectangle"] = CreateStatic("Microsoft.Xna.Framework.Rectangle", true)
|
defaultLib["Rectangle"] = CreateStatic("Microsoft.Xna.Framework.Rectangle", true)
|
||||||
defaultLib["Matrix"] = CreateStatic("Microsoft.Xna.Framework.Matrix", true)
|
defaultLib["Matrix"] = CreateStatic("Microsoft.Xna.Framework.Matrix", true)
|
||||||
|
|
||||||
if SERVER then
|
|
||||||
|
|
||||||
elseif CLIENT then
|
|
||||||
defaultLib["Sprite"] = CreateStatic("Barotrauma.Sprite", true)
|
|
||||||
defaultLib["PlayerInput"] = CreateStatic("Barotrauma.PlayerInput", true)
|
|
||||||
|
|
||||||
defaultLib["Keys"] = CreateStatic("Microsoft.Xna.Framework.Input.Keys", true)
|
|
||||||
|
|
||||||
defaultLib["GUI"] = {
|
|
||||||
GUI = CreateStatic("Barotrauma.GUI", true),
|
|
||||||
GUIStyle = CreateStatic("Barotrauma.GUIStyle", true),
|
|
||||||
RectTransform = CreateStatic("Barotrauma.RectTransform", 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),
|
|
||||||
NumberInput = CreateStatic("Barotrauma.GUINumberInput", true),
|
|
||||||
|
|
||||||
Screen = CreateStatic("Barotrauma.Screen"),
|
|
||||||
|
|
||||||
Anchor = CreateStatic("Barotrauma.Anchor"),
|
|
||||||
Alignment = CreateStatic("Barotrauma.Alignment"),
|
|
||||||
Pivot = CreateStatic("Barotrauma.Pivot"),
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
return defaultLib
|
return defaultLib
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
local Register = LuaSetup.Register
|
||||||
|
local RegisterBarotrauma = LuaSetup.RegisterBarotrauma
|
||||||
|
|
||||||
|
local localizedStrings = {
|
||||||
|
"LocalizedString", "LimitLString", "WrappedLString", "AddedPunctuationLString", "CapitalizeLString", "ConcatLString", "FallbackLString", "FormattedLString", "InputTypeLString", "JoinLString", "LowerLString", "RawLString", "ReplaceLString", "ServerMsgLString", "SplitLString", "TagLString", "TrimLString", "UpperLString", "StripRichTagsLString",
|
||||||
|
}
|
||||||
|
|
||||||
|
for key, value in pairs(localizedStrings) do
|
||||||
|
RegisterBarotrauma(value)
|
||||||
|
end
|
||||||
|
|
||||||
|
RegisterBarotrauma("Networking.ClientPeer")
|
||||||
|
|
||||||
|
RegisterBarotrauma("ChatBox")
|
||||||
|
RegisterBarotrauma("GUICanvas")
|
||||||
|
RegisterBarotrauma("Anchor")
|
||||||
|
RegisterBarotrauma("Alignment")
|
||||||
|
RegisterBarotrauma("Pivot")
|
||||||
|
RegisterBarotrauma("Key")
|
||||||
|
RegisterBarotrauma("PlayerInput")
|
||||||
|
RegisterBarotrauma("ScalableFont")
|
||||||
|
|
||||||
|
Register("Microsoft.Xna.Framework.Graphics.Texture2D")
|
||||||
|
Register("EventInput.KeyEventArgs")
|
||||||
|
Register("Microsoft.Xna.Framework.Input.Keys")
|
||||||
|
Register("Microsoft.Xna.Framework.Input.KeyboardState")
|
||||||
|
|
||||||
|
RegisterBarotrauma("Sprite")
|
||||||
|
RegisterBarotrauma("GUI")
|
||||||
|
RegisterBarotrauma("GUIStyle")
|
||||||
|
RegisterBarotrauma("GUILayoutGroup")
|
||||||
|
RegisterBarotrauma("GUITextBox")
|
||||||
|
RegisterBarotrauma("GUITextBlock")
|
||||||
|
RegisterBarotrauma("GUIButton")
|
||||||
|
RegisterBarotrauma("RectTransform")
|
||||||
|
RegisterBarotrauma("GUIFrame")
|
||||||
|
RegisterBarotrauma("GUITickBox")
|
||||||
|
RegisterBarotrauma("GUICustomComponent")
|
||||||
|
RegisterBarotrauma("GUIImage")
|
||||||
|
RegisterBarotrauma("GUIListBox")
|
||||||
|
RegisterBarotrauma("GUIScrollBar")
|
||||||
|
RegisterBarotrauma("GUIDropDown")
|
||||||
|
RegisterBarotrauma("GUINumberInput")
|
||||||
|
|
||||||
|
RegisterBarotrauma("Inventory+SlotReference")
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
local Register = LuaSetup.Register
|
||||||
|
local RegisterBarotrauma = LuaSetup.RegisterBarotrauma
|
||||||
|
|
||||||
|
|
||||||
|
local localizedStrings = {
|
||||||
|
"LocalizedString", "AddedPunctuationLString", "CapitalizeLString", "ConcatLString", "FallbackLString", "FormattedLString", "InputTypeLString", "JoinLString", "LowerLString", "RawLString", "ReplaceLString", "ServerMsgLString", "SplitLString", "TagLString", "TrimLString", "UpperLString", "StripRichTagsLString",
|
||||||
|
}
|
||||||
|
|
||||||
|
for key, value in pairs(localizedStrings) do
|
||||||
|
RegisterBarotrauma(value)
|
||||||
|
end
|
||||||
|
|
||||||
|
RegisterBarotrauma("Networking.GameServer")
|
||||||
|
|
||||||
|
RegisterBarotrauma("Networking.ServerPeer")
|
||||||
|
RegisterBarotrauma("Networking.ServerPeer+PendingClient")
|
||||||
|
|
||||||
|
RegisterBarotrauma("Traitor")
|
||||||
|
RegisterBarotrauma("Traitor+TraitorMission")
|
||||||
+5
-72
@@ -1,23 +1,8 @@
|
|||||||
local descriptors = {}
|
local Register = LuaSetup.Register
|
||||||
|
local RegisterBarotrauma = LuaSetup.RegisterBarotrauma
|
||||||
local function Register(typeName)
|
|
||||||
local descriptor = LuaUserData.RegisterType(typeName)
|
|
||||||
|
|
||||||
descriptors[typeName] = descriptor
|
|
||||||
|
|
||||||
return descriptor
|
|
||||||
end
|
|
||||||
|
|
||||||
local function RegisterBarotrauma(typeName)
|
|
||||||
return Register("Barotrauma." .. typeName)
|
|
||||||
end
|
|
||||||
|
|
||||||
Register("System.TimeSpan")
|
Register("System.TimeSpan")
|
||||||
|
|
||||||
if SERVER then
|
|
||||||
RegisterBarotrauma("Networking.GameServer")
|
|
||||||
end
|
|
||||||
|
|
||||||
RegisterBarotrauma("LuaByte")
|
RegisterBarotrauma("LuaByte")
|
||||||
RegisterBarotrauma("LuaUShort")
|
RegisterBarotrauma("LuaUShort")
|
||||||
RegisterBarotrauma("LuaFloat")
|
RegisterBarotrauma("LuaFloat")
|
||||||
@@ -26,10 +11,6 @@ RegisterBarotrauma("Level+InterestingPosition")
|
|||||||
|
|
||||||
RegisterBarotrauma("Identifier")
|
RegisterBarotrauma("Identifier")
|
||||||
|
|
||||||
RegisterBarotrauma("LocalizedString")
|
|
||||||
RegisterBarotrauma("TagLString")
|
|
||||||
RegisterBarotrauma("RichString")
|
|
||||||
|
|
||||||
RegisterBarotrauma("Job")
|
RegisterBarotrauma("Job")
|
||||||
RegisterBarotrauma("JobPrefab")
|
RegisterBarotrauma("JobPrefab")
|
||||||
RegisterBarotrauma("Level")
|
RegisterBarotrauma("Level")
|
||||||
@@ -89,11 +70,11 @@ RegisterBarotrauma("ItemInventory")
|
|||||||
RegisterBarotrauma("Inventory+ItemSlot")
|
RegisterBarotrauma("Inventory+ItemSlot")
|
||||||
RegisterBarotrauma("FireSource")
|
RegisterBarotrauma("FireSource")
|
||||||
|
|
||||||
local barotraumaComponentsToRegister = { "DockingPort", "Door", "GeneticMaterial", "Growable", "Holdable", "LevelResource", "ItemComponent", "ItemLabel", "LightComponent", "Controller", "Deconstructor", "Engine", "Fabricator", "OutpostTerminal", "Pump", "Reactor", "Steering", "PowerContainer", "Projectile", "Repairable", "Rope", "Scanner", "ButtonTerminal", "ConnectionPanel", "CustomInterface", "MemoryComponent", "Terminal", "WifiComponent", "Wire", "TriggerComponent", "ElectricalDischarger", "EntitySpawnerComponent", "ProducedItem", "VineTile", "GrowthSideExtension", "IdCard", "MeleeWeapon", "Pickable", "AbilityItemPickingTime", "Propulsion", "RangedWeapon", "AbilityRangedWeapon", "RepairTool", "Sprayer", "Throwable", "ItemContainer", "AbilityItemContainer", "Ladder", "LimbPos", "AbilityDeconstructedItem", "AbilityItemCreationMultiplier", "AbilityItemDeconstructedInventory", "MiniMap", "OxygenGenerator", "Sonar", "SonarTransducer", "Vent", "NameTag", "Planter", "Powered", "PowerTransfer", "Quality", "RemoteController", "AdderComponent", "AndComponent", "ArithmeticComponent", "ColorComponent", "ConcatComponent", "Connection", "DelayComponent", "DivideComponent", "EqualsComponent", "ExponentiationComponent", "FunctionComponent", "GreaterComponent", "ModuloComponent", "MotionSensor", "MultiplyComponent", "NotComponent", "OrComponent", "OscillatorComponent", "OxygenDetector", "RegExFindComponent", "RelayComponent", "SignalCheckComponent", "SmokeDetector", "StringComponent", "SubtractComponent", "TrigonometricFunctionComponent", "WaterDetector", "XorComponent", "StatusHUD", "Turret", "Wearable",
|
local componentsToRegister = { "DockingPort", "Door", "GeneticMaterial", "Growable", "Holdable", "LevelResource", "ItemComponent", "ItemLabel", "LightComponent", "Controller", "Deconstructor", "Engine", "Fabricator", "OutpostTerminal", "Pump", "Reactor", "Steering", "PowerContainer", "Projectile", "Repairable", "Rope", "Scanner", "ButtonTerminal", "ConnectionPanel", "CustomInterface", "MemoryComponent", "Terminal", "WifiComponent", "Wire", "TriggerComponent", "ElectricalDischarger", "EntitySpawnerComponent", "ProducedItem", "VineTile", "GrowthSideExtension", "IdCard", "MeleeWeapon", "Pickable", "AbilityItemPickingTime", "Propulsion", "RangedWeapon", "AbilityRangedWeapon", "RepairTool", "Sprayer", "Throwable", "ItemContainer", "AbilityItemContainer", "Ladder", "LimbPos", "AbilityDeconstructedItem", "AbilityItemCreationMultiplier", "AbilityItemDeconstructedInventory", "MiniMap", "OxygenGenerator", "Sonar", "SonarTransducer", "Vent", "NameTag", "Planter", "Powered", "PowerTransfer", "Quality", "RemoteController", "AdderComponent", "AndComponent", "ArithmeticComponent", "ColorComponent", "ConcatComponent", "Connection", "DelayComponent", "DivideComponent", "EqualsComponent", "ExponentiationComponent", "FunctionComponent", "GreaterComponent", "ModuloComponent", "MotionSensor", "MultiplyComponent", "NotComponent", "OrComponent", "OscillatorComponent", "OxygenDetector", "RegExFindComponent", "RelayComponent", "SignalCheckComponent", "SmokeDetector", "StringComponent", "SubtractComponent", "TrigonometricFunctionComponent", "WaterDetector", "XorComponent", "StatusHUD", "Turret", "Wearable",
|
||||||
"GridInfo", "PowerSourceGroup"
|
"GridInfo", "PowerSourceGroup"
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, value in pairs(barotraumaComponentsToRegister) do
|
for key, value in pairs(componentsToRegister) do
|
||||||
RegisterBarotrauma("Items.Components." .. value)
|
RegisterBarotrauma("Items.Components." .. value)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -228,52 +209,4 @@ Register("Microsoft.Xna.Framework.Vector4")
|
|||||||
Register("Microsoft.Xna.Framework.Color")
|
Register("Microsoft.Xna.Framework.Color")
|
||||||
Register("Microsoft.Xna.Framework.Point")
|
Register("Microsoft.Xna.Framework.Point")
|
||||||
Register("Microsoft.Xna.Framework.Rectangle")
|
Register("Microsoft.Xna.Framework.Rectangle")
|
||||||
Register("Microsoft.Xna.Framework.Matrix")
|
Register("Microsoft.Xna.Framework.Matrix")
|
||||||
|
|
||||||
if SERVER then
|
|
||||||
RegisterBarotrauma("Networking.ServerPeer")
|
|
||||||
RegisterBarotrauma("Networking.ServerPeer+PendingClient")
|
|
||||||
|
|
||||||
RegisterBarotrauma("Traitor")
|
|
||||||
RegisterBarotrauma("Traitor+TraitorMission")
|
|
||||||
|
|
||||||
elseif CLIENT then
|
|
||||||
|
|
||||||
RegisterBarotrauma("Networking.ClientPeer")
|
|
||||||
|
|
||||||
RegisterBarotrauma("ChatBox")
|
|
||||||
RegisterBarotrauma("GUICanvas")
|
|
||||||
RegisterBarotrauma("Anchor")
|
|
||||||
RegisterBarotrauma("Alignment")
|
|
||||||
RegisterBarotrauma("Pivot")
|
|
||||||
RegisterBarotrauma("Key")
|
|
||||||
RegisterBarotrauma("PlayerInput")
|
|
||||||
RegisterBarotrauma("ScalableFont")
|
|
||||||
|
|
||||||
Register("Microsoft.Xna.Framework.Graphics.Texture2D")
|
|
||||||
Register("EventInput.KeyEventArgs")
|
|
||||||
Register("Microsoft.Xna.Framework.Input.Keys")
|
|
||||||
Register("Microsoft.Xna.Framework.Input.KeyboardState")
|
|
||||||
|
|
||||||
RegisterBarotrauma("Sprite")
|
|
||||||
RegisterBarotrauma("GUI")
|
|
||||||
RegisterBarotrauma("GUIStyle")
|
|
||||||
RegisterBarotrauma("GUILayoutGroup")
|
|
||||||
RegisterBarotrauma("GUITextBox")
|
|
||||||
RegisterBarotrauma("GUITextBlock")
|
|
||||||
RegisterBarotrauma("GUIButton")
|
|
||||||
RegisterBarotrauma("RectTransform")
|
|
||||||
RegisterBarotrauma("GUIFrame")
|
|
||||||
RegisterBarotrauma("GUITickBox")
|
|
||||||
RegisterBarotrauma("GUICustomComponent")
|
|
||||||
RegisterBarotrauma("GUIImage")
|
|
||||||
RegisterBarotrauma("GUIListBox")
|
|
||||||
RegisterBarotrauma("GUIScrollBar")
|
|
||||||
RegisterBarotrauma("GUIDropDown")
|
|
||||||
RegisterBarotrauma("GUINumberInput")
|
|
||||||
|
|
||||||
RegisterBarotrauma("Inventory+SlotReference")
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
return descriptors
|
|
||||||
@@ -1,115 +1,40 @@
|
|||||||
-- Config
|
LuaSetup = {}
|
||||||
|
|
||||||
|
LuaSetup.Descriptors = {}
|
||||||
|
|
||||||
local path = table.pack(...)[1]
|
local path = table.pack(...)[1]
|
||||||
|
|
||||||
local modulePaths = {path .. "/?.lua"}
|
package.path = {path .. "/?.lua"}
|
||||||
setmodulepaths(modulePaths)
|
|
||||||
|
setmodulepaths(package.path)
|
||||||
|
|
||||||
-- Setup Libraries
|
-- Setup Libraries
|
||||||
|
require("UserDataUtils")
|
||||||
|
|
||||||
local defaultLib = require("DefaultLib")
|
require("DefaultRegister/RegisterShared")
|
||||||
|
|
||||||
for key, value in pairs(defaultLib) do
|
if SERVER then
|
||||||
_G[key] = value
|
require("DefaultRegister/RegisterServer")
|
||||||
|
else
|
||||||
|
require("DefaultRegister/RegisterClient")
|
||||||
end
|
end
|
||||||
|
|
||||||
local compatibilityLib = require("CompatibilityLib")
|
local function AddTableToGlobal(tbl)
|
||||||
|
for k, v in pairs(tbl) do
|
||||||
for key, value in pairs(compatibilityLib) do
|
_G[k] = v
|
||||||
_G[key] = value
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if SERVER then
|
||||||
|
AddTableToGlobal(require("DefaultLib/LibServer"))
|
||||||
|
else
|
||||||
|
AddTableToGlobal(require("DefaultLib/LibClient"))
|
||||||
|
end
|
||||||
|
|
||||||
|
AddTableToGlobal(require("DefaultLib/LibShared"))
|
||||||
|
|
||||||
|
AddTableToGlobal(require("CompatibilityLib"))
|
||||||
|
|
||||||
require("DefaultHook")
|
require("DefaultHook")
|
||||||
|
|
||||||
-- Execute Mods
|
require("ModLoader")
|
||||||
|
|
||||||
local allPackages = ContentPackageManager.AllPackages
|
|
||||||
local localPackages = ContentPackageManager.LocalPackages
|
|
||||||
local enabledPackages = ContentPackageManager.EnabledPackages.All
|
|
||||||
|
|
||||||
local function endsWith(str, suffix)
|
|
||||||
return str:sub(-string.len(suffix)) == suffix
|
|
||||||
end
|
|
||||||
|
|
||||||
local function getFileName(file)
|
|
||||||
return file:match("^.+/(.+)$")
|
|
||||||
end
|
|
||||||
|
|
||||||
local function getPath(str)
|
|
||||||
local sep = "/"
|
|
||||||
return str:match("(.*"..sep..")")
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local function executeProtected(s, folder)
|
|
||||||
loadfile(s)(folder)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function runFolder(folder, rootFolder, package)
|
|
||||||
local search = File.DirSearch(folder)
|
|
||||||
for i = 1, #search, 1 do
|
|
||||||
local s = search[i]:gsub("\\", "/")
|
|
||||||
|
|
||||||
if endsWith(s, ".lua") then
|
|
||||||
print(string.format("%s: Executing %s", package.Name, getFileName(s)))
|
|
||||||
local ok, result = pcall(executeProtected, s, rootFolder)
|
|
||||||
if not ok then
|
|
||||||
printerror(result)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
for package in enabledPackages do
|
|
||||||
if package then
|
|
||||||
local d = package.Path:gsub("\\", "/")
|
|
||||||
d = d:gsub("/filelist.xml", "")
|
|
||||||
|
|
||||||
table.insert(modulePaths, (d .. "/Lua/?.lua"))
|
|
||||||
|
|
||||||
if File.DirectoryExists(d .. "/Lua/Autorun") then
|
|
||||||
runFolder(d .. "/Lua/Autorun", d, package)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- we don't want to execute workshop ForcedAutorun if we have a local Package
|
|
||||||
local executedLocalPackages = {}
|
|
||||||
|
|
||||||
for package in localPackages do
|
|
||||||
if package then
|
|
||||||
local d = package.Path:gsub("\\", "/")
|
|
||||||
d = d:gsub("/filelist.xml", "")
|
|
||||||
|
|
||||||
table.insert(modulePaths, (d .. "/Lua/?.lua"))
|
|
||||||
|
|
||||||
if File.DirectoryExists(d .. "/Lua/ForcedAutorun") then
|
|
||||||
runFolder(d .. "/Lua/ForcedAutorun", d, package)
|
|
||||||
|
|
||||||
executedLocalPackages[package.Name] = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
for package in allPackages do
|
|
||||||
if package and executedLocalPackages[package.Name] == nil then
|
|
||||||
local d = package.Path:gsub("\\", "/")
|
|
||||||
d = d:gsub("/filelist.xml", "")
|
|
||||||
|
|
||||||
table.insert(modulePaths, (d .. "/Lua/?.lua"))
|
|
||||||
|
|
||||||
if File.DirectoryExists(d .. "/Lua/ForcedAutorun") then
|
|
||||||
runFolder(d .. "/Lua/ForcedAutorun", d, package)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
setmodulepaths(modulePaths)
|
|
||||||
|
|
||||||
Hook.Add("stop", "luaSetup.stop", function ()
|
|
||||||
print("Stopping Lua...")
|
|
||||||
end)
|
|
||||||
|
|
||||||
Hook.Call("loaded")
|
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
local allPackages = ContentPackageManager.AllPackages
|
||||||
|
local localPackages = ContentPackageManager.LocalPackages
|
||||||
|
local enabledPackages = ContentPackageManager.EnabledPackages.All
|
||||||
|
|
||||||
|
local function EndsWith(str, suffix)
|
||||||
|
return str:sub(-string.len(suffix)) == suffix
|
||||||
|
end
|
||||||
|
|
||||||
|
local function GetFileName(file)
|
||||||
|
return file:match("^.+/(.+)$")
|
||||||
|
end
|
||||||
|
|
||||||
|
local function ExecuteProtected(s, folder)
|
||||||
|
loadfile(s)(folder)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function RunFolder(folder, rootFolder, package)
|
||||||
|
local search = File.DirSearch(folder)
|
||||||
|
for i = 1, #search, 1 do
|
||||||
|
local s = search[i]:gsub("\\", "/")
|
||||||
|
|
||||||
|
if EndsWith(s, ".lua") then
|
||||||
|
print(string.format("%s: Executing %s", package.Name, GetFileName(s)))
|
||||||
|
local ok, result = pcall(ExecuteProtected, s, rootFolder)
|
||||||
|
if not ok then
|
||||||
|
printerror(result)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
for contentPackage in enabledPackages do
|
||||||
|
if contentPackage then
|
||||||
|
local d = contentPackage.Path:gsub("\\", "/")
|
||||||
|
d = d:gsub("/filelist.xml", "")
|
||||||
|
|
||||||
|
table.insert(package.path, (d .. "/Lua/?.lua"))
|
||||||
|
|
||||||
|
if File.DirectoryExists(d .. "/Lua/Autorun") then
|
||||||
|
RunFolder(d .. "/Lua/Autorun", d, contentPackage)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- we don't want to execute workshop ForcedAutorun if we have a local Package
|
||||||
|
local executedLocalPackages = {}
|
||||||
|
|
||||||
|
for contentPackage in localPackages do
|
||||||
|
if contentPackage then
|
||||||
|
local d = contentPackage.Path:gsub("\\", "/")
|
||||||
|
d = d:gsub("/filelist.xml", "")
|
||||||
|
|
||||||
|
table.insert(package.path, (d .. "/Lua/?.lua"))
|
||||||
|
|
||||||
|
if File.DirectoryExists(d .. "/Lua/ForcedAutorun") then
|
||||||
|
RunFolder(d .. "/Lua/ForcedAutorun", d, contentPackage)
|
||||||
|
|
||||||
|
executedLocalPackages[contentPackage.Name] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for contentPackage in allPackages do
|
||||||
|
if contentPackage and executedLocalPackages[contentPackage.Name] == nil then
|
||||||
|
local d = contentPackage.Path:gsub("\\", "/")
|
||||||
|
d = d:gsub("/filelist.xml", "")
|
||||||
|
|
||||||
|
table.insert(package.path, (d .. "/Lua/?.lua"))
|
||||||
|
|
||||||
|
if File.DirectoryExists(d .. "/Lua/ForcedAutorun") then
|
||||||
|
RunFolder(d .. "/Lua/ForcedAutorun", d, contentPackage)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
setmodulepaths(package.path)
|
||||||
|
|
||||||
|
Hook.Add("stop", "luaSetup.stop", function ()
|
||||||
|
print("Stopping Lua...")
|
||||||
|
end)
|
||||||
|
|
||||||
|
Hook.Call("loaded")
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
LuaSetup.Register = function(typeName)
|
||||||
|
local descriptor = LuaUserData.RegisterType(typeName)
|
||||||
|
|
||||||
|
LuaSetup.Descriptors[typeName] = descriptor
|
||||||
|
|
||||||
|
return descriptor
|
||||||
|
end
|
||||||
|
|
||||||
|
LuaSetup.RegisterBarotrauma = function(typeName)
|
||||||
|
return LuaSetup.Register("Barotrauma." .. typeName)
|
||||||
|
end
|
||||||
|
|
||||||
|
LuaSetup.CreateStatic = function(typeName, addCallMethod)
|
||||||
|
local staticUserdata = LuaUserData.CreateStatic(typeName)
|
||||||
|
|
||||||
|
if addCallMethod then
|
||||||
|
debug.setmetatable(staticUserdata, {
|
||||||
|
__call = function(obj, ...)
|
||||||
|
local success, result = pcall(staticUserdata.__new, ...)
|
||||||
|
|
||||||
|
if not success then
|
||||||
|
error(result, 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
return staticUserdata
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user