Add other mods
This commit is contained in:
38
Lua Editor/Item.xml
Normal file
38
Lua Editor/Item.xml
Normal file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Items>
|
||||
<Item name="Lua Editor" identifier="luaeditor" category="" cargocontaineridentifier="metalcrate" tags="smallitem,mountableweapon" Scale="0.12" impactsoundtag="impact_metal_light" description="A tool to edit values of items">
|
||||
<Fabricate suitablefabricators="fabricator" requiredtime="60">
|
||||
<RequiredSkill identifier="electrical" level="75" />
|
||||
<RequiredSkill identifier="mechanical" level="55" />
|
||||
<RequiredItem identifier="fpgacircuit" />
|
||||
<RequiredItem identifier="fpgacircuit" />
|
||||
<RequiredItem identifier="titaniumaluminiumalloy" />
|
||||
<RequiredItem identifier="titaniumaluminiumalloy" />
|
||||
<RequiredItem identifier="copper" />
|
||||
</Fabricate>
|
||||
<Deconstruct time="30">
|
||||
<Item identifier="fpgacircuit" />
|
||||
<Item identifier="fpgacircuit" />
|
||||
<Item identifier="titaniumaluminiumalloy" />
|
||||
<Item identifier="titaniumaluminiumalloy" />
|
||||
<Item identifier="copper" />
|
||||
</Deconstruct>
|
||||
<InventoryIcon texture="%ModDir%/toolgun.png" sourcerect="0,0,444,299" origin="0.5,0.5" />
|
||||
<Sprite texture="%ModDir%/toolgun.png" sourcerect="0,0,444,299" origin="0.5,0.5" depth="0.55" />
|
||||
<Body width="72" height="40" density="50" />
|
||||
<Holdable slots="Any,RightHand,LeftHand" controlpose="true" aimpos="70,5" handle1="-170,-90" msg="ItemMsgPickUpSelect" />
|
||||
<RangedWeapon barrelpos="29,11" spread="0" unskilledspread="2" combatPriority="70" drawhudwhenequipped="true" crosshairscale="0.2">
|
||||
<Crosshair texture="Content/Items/Weapons/Crosshairs.png" sourcerect="0,256,256,256" />
|
||||
<CrosshairPointer texture="Content/Items/Weapons/Crosshairs.png" sourcerect="256,256,256,256" />
|
||||
<Sound file="%ModDir%/LuaEditor.ogg" type="OnUse" range="1000" />
|
||||
<ParticleEmitter particle="muzzleflash" particleamount="1" velocitymin="0" velocitymax="0" />
|
||||
<StatusEffect type="OnUse">
|
||||
<Explosion range="150.0" force="1.5" shockwave="false" smoke="false" flames="false" sparks="false" underwaterbubble="false" camerashake="6.0" />
|
||||
</StatusEffect>
|
||||
<StatusEffect type="OnUse" target="Character">
|
||||
<LuaHook name="Lua_Editor" />
|
||||
</StatusEffect>
|
||||
</RangedWeapon>
|
||||
<Upgrade gameversion="0.10.0.0" scale="0.5" />
|
||||
</Item>
|
||||
</Items>
|
||||
5869
Lua Editor/Lua/Autorun/EditGUI.lua
Normal file
5869
Lua Editor/Lua/Autorun/EditGUI.lua
Normal file
File diff suppressed because it is too large
Load Diff
17
Lua Editor/Lua/defaultclientsidesettings.lua
Normal file
17
Lua Editor/Lua/defaultclientsidesettings.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
-- DO NOT EDIT THESE SETTINGS, THIS IS JUST A TEMPLATE --
|
||||
|
||||
local clientsidesettings = {}
|
||||
|
||||
clientsidesettings.targetnoninteractable = "False"
|
||||
|
||||
clientsidesettings.targetingsetting = "Objects"
|
||||
|
||||
clientsidesettings.tagstotarget = ""
|
||||
|
||||
clientsidesettings.movementamount = 1
|
||||
|
||||
clientsidesettings.targetitems = false
|
||||
|
||||
clientsidesettings.targetparentinventory = false
|
||||
|
||||
return clientsidesettings
|
||||
81
Lua Editor/Lua/defaultsettings.lua
Normal file
81
Lua Editor/Lua/defaultsettings.lua
Normal file
@@ -0,0 +1,81 @@
|
||||
-- DO NOT EDIT THESE SETTINGS, THIS IS JUST A TEMPLATE --
|
||||
|
||||
local settings = {}
|
||||
|
||||
settings.permissionsetting = 0
|
||||
|
||||
settings.tagstonottarget = ""
|
||||
|
||||
settings.allowtargetingnoninteractable = true
|
||||
|
||||
settings.allowtargetingitems = false
|
||||
|
||||
settings.allowtargetingstructures = false
|
||||
|
||||
-- main value settings
|
||||
|
||||
settings.spritedepth = true
|
||||
|
||||
settings.rotation = true
|
||||
|
||||
settings.scale = true
|
||||
|
||||
settings.scalemin = 0.1
|
||||
settings.scalemax = 0.9
|
||||
|
||||
settings.condition = false
|
||||
|
||||
settings.spritecolor = true
|
||||
|
||||
settings.alpha = false
|
||||
|
||||
settings.tags = true
|
||||
|
||||
settings.description = true
|
||||
|
||||
settings.noninteractable = true
|
||||
|
||||
settings.nonplayerteaminteractable = false
|
||||
|
||||
settings.invulnerabletodamage = false
|
||||
|
||||
settings.displaysidebysidewhenlinked = true
|
||||
|
||||
settings.hiddeningame = false
|
||||
|
||||
settings.mirror = true
|
||||
|
||||
|
||||
-- Components
|
||||
|
||||
settings.lightcomponent = false
|
||||
|
||||
settings.holdable = false
|
||||
|
||||
settings.connectionpanel = false
|
||||
|
||||
settings.fabricator = false
|
||||
|
||||
settings.deconstructor = false
|
||||
|
||||
settings.reactor = false
|
||||
|
||||
settings.oxygengenerator = false
|
||||
|
||||
settings.sonar = false
|
||||
|
||||
settings.repairable = false
|
||||
|
||||
settings.powertransfer = false
|
||||
|
||||
settings.itemcontainer = false
|
||||
|
||||
settings.door = false
|
||||
|
||||
settings.itemlabel = false
|
||||
|
||||
settings.quality = false
|
||||
|
||||
settings.components = false
|
||||
|
||||
return settings
|
||||
154
Lua Editor/Lua/findtarget.lua
Normal file
154
Lua Editor/Lua/findtarget.lua
Normal file
@@ -0,0 +1,154 @@
|
||||
local findtarget = {}
|
||||
-- findowner
|
||||
findtarget.FindClientCharacter = function(character)
|
||||
if CLIENT then return nil end
|
||||
|
||||
for key, value in pairs(Client.ClientList) do
|
||||
if value.Character == character then
|
||||
return value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
findtarget.cursor_pos = Vector2(0, 0)
|
||||
findtarget.cursor_updated = false
|
||||
|
||||
local function StringToTable(inputString)
|
||||
local result = {}
|
||||
|
||||
if inputString == nil then
|
||||
return result
|
||||
end
|
||||
|
||||
for value in inputString:gmatch("[^,]+") do
|
||||
table.insert(result, value)
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
local function itemsorwalls(submarine)
|
||||
|
||||
if EditGUI.ClientsideSettings.targetingsetting == "Walls" and EditGUI.Settings.allowtargetingstructures == true then
|
||||
targeting = "walls"
|
||||
return submarine.GetWalls(false)
|
||||
elseif EditGUI.ClientsideSettings.targetingsetting == "Hulls" and EditGUI.Settings.allowtargetingstructures == true then
|
||||
targeting = "hulls"
|
||||
return submarine.GetHulls(false)
|
||||
elseif EditGUI.ClientsideSettings.targetingsetting == "Gaps" and EditGUI.Settings.allowtargetingstructures == true then
|
||||
targeting = "gaps"
|
||||
return submarine.GetGaps(false)
|
||||
else
|
||||
targeting = "items"
|
||||
return submarine.GetItems(false)
|
||||
end
|
||||
end
|
||||
|
||||
local function FindClosestItem(submarine, position)
|
||||
local closest = nil
|
||||
for key, value in pairs(submarine and itemsorwalls(submarine) or Item.ItemList) do
|
||||
if targeting == "items" then
|
||||
if EditGUI.Settings.allowtargetingnoninteractable == true then
|
||||
if EditGUI.ClientsideSettings.targetnoninteractable == "False" then
|
||||
targetnoninter = value.NonInteractable == false
|
||||
elseif EditGUI.ClientsideSettings.targetnoninteractable == "Target Both" then
|
||||
targetnoninter = value.NonInteractable == false or true
|
||||
elseif EditGUI.ClientsideSettings.targetnoninteractable == "Target Only Non Interactable" then
|
||||
targetnoninter = value.NonInteractable == true
|
||||
end
|
||||
else
|
||||
targetnoninter = value.NonInteractable == false
|
||||
end
|
||||
else
|
||||
targetnoninter = true
|
||||
end
|
||||
|
||||
if EditGUI.Settings.allowtargetingitems == true then
|
||||
targetitems = EditGUI.ClientsideSettings.targetitems
|
||||
else
|
||||
targetitems = false
|
||||
end
|
||||
|
||||
-- Check if the item has a parent inventory
|
||||
if targeting == "items" then
|
||||
hasParentInventory = value.ParentInventory ~= nil
|
||||
end
|
||||
|
||||
-- Skip items with parent inventories
|
||||
if hasParentInventory == EditGUI.ClientsideSettings.targetparentinventory or targeting ~= "items" then
|
||||
local hasValidTag = true
|
||||
|
||||
if EditGUI.ClientsideSettings.tagstotarget ~= nil and targeting == "items" then
|
||||
for _, tag in ipairs(StringToTable(EditGUI.ClientsideSettings.tagstotarget)) do
|
||||
if value.HasTag(tag) then
|
||||
hasValidTag = true
|
||||
break
|
||||
else
|
||||
hasValidTag = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for _, tag in ipairs(StringToTable(EditGUI.Settings.tagstonottarget)) do
|
||||
if value.HasTag(tag) then
|
||||
hasValidTag = false
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if hasValidTag and targetnoninter then
|
||||
-- check if placable or if it does not have holdable component
|
||||
local check_if_p_or_nh = false
|
||||
if targeting == "items" then
|
||||
local holdable = value.GetComponentString("Holdable")
|
||||
end
|
||||
if targetitems == false then
|
||||
if holdable == nil then
|
||||
check_if_p_or_nh = true
|
||||
else
|
||||
if holdable.attachable == true then
|
||||
check_if_p_or_nh = true
|
||||
end
|
||||
end
|
||||
else
|
||||
check_if_p_or_nh = true
|
||||
end
|
||||
if check_if_p_or_nh == true then
|
||||
if Vector2.Distance(position, value.WorldPosition) < 100 then
|
||||
if closest == nil then closest = value end
|
||||
if Vector2.Distance(position, value.WorldPosition) <
|
||||
Vector2.Distance(position, closest.WorldPosition) then
|
||||
closest = value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return closest
|
||||
end
|
||||
|
||||
findtarget.findtarget = function(item)
|
||||
cursor_updated = false
|
||||
if Client then
|
||||
findtarget.cursor_pos = item.ParentInventory.Owner.CursorWorldPosition
|
||||
cursor_updated = true
|
||||
end
|
||||
|
||||
-- fallback
|
||||
if not cursor_updated and Game.IsMultiplayer then
|
||||
findtarget.cursor_pos = item.WorldPosition
|
||||
end
|
||||
|
||||
if item.ParentInventory == nil or item.ParentInventory.Owner == nil then return end
|
||||
|
||||
local target = FindClosestItem(item.Submarine, findtarget.cursor_pos)
|
||||
return target
|
||||
end
|
||||
|
||||
return findtarget
|
||||
483
Lua Editor/Lua/networking.lua
Normal file
483
Lua Editor/Lua/networking.lua
Normal file
@@ -0,0 +1,483 @@
|
||||
network = {}
|
||||
|
||||
|
||||
-- Shared Side Start --
|
||||
|
||||
local function ConvertStringToRequiredItems(value)
|
||||
local relatedItemClass = LuaUserData.CreateStatic("Barotrauma.RelatedItem")
|
||||
local requiredItems = {}
|
||||
|
||||
for requiredItemXml in value:gmatch("<[^>]+/>") do
|
||||
local xml = XDocument.Parse(requiredItemXml).Root
|
||||
local contentXml = ContentXElement(nil, xml)
|
||||
local relatedItem = relatedItemClass.__new(contentXml, "LuaEditorRequiredItem")
|
||||
local requiredType = relatedItem.Type
|
||||
|
||||
if requiredItems[requiredType] == nil then
|
||||
requiredItems[requiredType] = {relatedItem}
|
||||
else
|
||||
table.insert(requiredItems[requiredType], relatedItem)
|
||||
end
|
||||
end
|
||||
|
||||
return requiredItems
|
||||
end
|
||||
|
||||
-- Shared Side End --
|
||||
-- Client Side Start --
|
||||
|
||||
if CLIENT then
|
||||
|
||||
local function ConvertToString(value)
|
||||
return tostring(value)
|
||||
end
|
||||
|
||||
local function ConvertColorToString(value)
|
||||
if type(value) == "userdata" then
|
||||
return string.format("%f,%f,%f,%f", value.r, value.g, value.b, value.a)
|
||||
else
|
||||
print("failed to convert color")
|
||||
end
|
||||
end
|
||||
|
||||
local function ConvertRequiredItemsToString(value)
|
||||
if type(value) == "table" then
|
||||
local requiredItemsXMLs = " "
|
||||
for requiredType, requiredTypeItems in pairs(value) do
|
||||
for i, requiredItem in ipairs(requiredTypeItems) do
|
||||
local requiredItemsXML = XElement("requireditem")
|
||||
requiredItem.Save(requiredItemsXML)
|
||||
|
||||
requiredItemsXMLs = requiredItemsXMLs .. tostring(requiredItemsXML)
|
||||
end
|
||||
end
|
||||
return requiredItemsXMLs
|
||||
else
|
||||
print("failed to convert RequiredItems to string")
|
||||
end
|
||||
end
|
||||
|
||||
Update = {
|
||||
itemupdatevalue = {
|
||||
{"String", "String", "Number", "Number2"}, -- Three parameters: ItemString, ActionString, Value
|
||||
fn = function(ItemString, ActionString, Value, Value2)
|
||||
if Value2 == "Color" then
|
||||
itemupdatestring = ItemString .. "|" .. ActionString .. "|" .. ConvertColorToString(Value) .. "|" .. Value2
|
||||
elseif Value2 == "RequiredItems" then
|
||||
itemupdatestring = ItemString .. "|" .. ActionString .. "|" .. ConvertRequiredItemsToString(Value) .. "|" .. Value2
|
||||
else
|
||||
if Value2 then
|
||||
itemupdatestring = ItemString .. "|" .. ActionString .. "|" .. ConvertToString(Value) .. "|" .. ConvertToString(Value2)
|
||||
else
|
||||
itemupdatestring = ItemString .. "|" .. ActionString .. "|" .. ConvertToString(Value)
|
||||
end
|
||||
end
|
||||
local itemupdatenetwork = Networking.Start("itemupdatenetworking")
|
||||
itemupdatenetwork.WriteString(itemupdatestring)
|
||||
Networking.Send(itemupdatenetwork)
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
Networking.Receive("settingsnetworking", function (settingsnetwork)
|
||||
local receivedData = settingsnetwork.ReadString() -- Get the received string
|
||||
-- Deserialize the received string into a Lua table
|
||||
local Settings = {}
|
||||
for key, value in string.gmatch(receivedData, '([^;]+)=([^;]+)') do
|
||||
if value == "true" then
|
||||
Settings[key] = true
|
||||
elseif value == "false" then
|
||||
Settings[key] = false
|
||||
else
|
||||
Settings[key] = tonumber(value) or value
|
||||
end
|
||||
end
|
||||
|
||||
-- Update your local settings with the received data
|
||||
EditGUI.Settings = Settings
|
||||
end)
|
||||
|
||||
|
||||
EditGUI.networkstart = function()
|
||||
if Game.IsMultiplayer and settings == false or settings == nil then
|
||||
EditGUI.AddMessage("Applied settings to " .. itemedit.Name, owner)
|
||||
else
|
||||
if settings == true then
|
||||
File.Write(EditGUI.Path .. "/clientsidesettings.json", json.serialize(EditGUI.ClientsideSettings))
|
||||
if Game.IsMultiplayer then
|
||||
|
||||
local serializedData = ""
|
||||
for key, value in pairs(EditGUI.Settings) do
|
||||
if type(value) == "boolean" then
|
||||
value = tostring(value)
|
||||
end
|
||||
serializedData = serializedData .. key .. "=" .. tostring(value) .. ";"
|
||||
end
|
||||
local settingsnetwork = Networking.Start("settingsnetworkupdate")
|
||||
settingsnetwork.WriteString(serializedData)
|
||||
Networking.Send(settingsnetwork)
|
||||
else
|
||||
File.Write(EditGUI.Path .. "/settings.json", json.serialize(EditGUI.Settings))
|
||||
end
|
||||
EditGUI.AddMessage("Saved Changes", owner)
|
||||
else
|
||||
if itemedit == nil then
|
||||
return
|
||||
end
|
||||
EditGUI.AddMessage("Apply unnecessary in singleplayer", owner)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
-- Client Side End --
|
||||
-- Server Side Start
|
||||
|
||||
if SERVER then
|
||||
|
||||
EditGUI.Settings = json.parse(File.Read(EditGUI.Path .. "/settings.json"))
|
||||
|
||||
local function split(str, separator)
|
||||
if str == nil then
|
||||
return {} -- Return an empty table for an empty string
|
||||
end
|
||||
local result = {}
|
||||
local pattern = string.format("([^%s]+)", separator)
|
||||
str:gsub(pattern, function(c) result[#result + 1] = c end)
|
||||
return result
|
||||
end
|
||||
|
||||
function removePeriodsAndNumbers(inputString)
|
||||
local stringWithoutPeriodsAndNumbers = string.gsub(inputString, "[%.%d]", "")
|
||||
return stringWithoutPeriodsAndNumbers
|
||||
end
|
||||
|
||||
Networking.Receive("itemupdatenetworking", function (itemupdatenetwork,sender)
|
||||
if EditGUI.Settings.permissionsetting == 0 then
|
||||
if sender.Permissions == 0 then
|
||||
return
|
||||
end
|
||||
else
|
||||
if not sender.HasPermission(ClientPermissions[EditGUI.Settings.permissionsetting]) then
|
||||
return
|
||||
end
|
||||
end
|
||||
itemupdatestring = itemupdatenetwork.ReadString()
|
||||
local values = split(itemupdatestring, "|")
|
||||
local ItemString = values[1]
|
||||
local ActionString = values[2]
|
||||
local ValueString = values[3]
|
||||
if values[4] then
|
||||
ValueString2 = values[4]
|
||||
else
|
||||
ValueString2 = nil
|
||||
end
|
||||
-- Perform the logic on the server
|
||||
local itemedit = Entity.FindEntityByID(tonumber(ItemString))
|
||||
local Value = nil
|
||||
if ValueString == "true" then
|
||||
Value = true
|
||||
elseif ValueString == "false" then
|
||||
Value = false
|
||||
elseif ValueString2 == "Color" then
|
||||
local colorValues = split(ValueString , ",")
|
||||
if #colorValues == 4 then
|
||||
Value = Color(tonumber(colorValues[1]), tonumber(colorValues[2]), tonumber(colorValues[3]), tonumber(colorValues[4]))
|
||||
end
|
||||
elseif ValueString2 == "RequiredItems" then
|
||||
Value = ConvertStringToRequiredItems(ValueString)
|
||||
else
|
||||
Value = tonumber(ValueString) or ValueString
|
||||
end
|
||||
local mainAction, subAction = ActionString:match("(.-)%.([^%.]+)$")
|
||||
local valueStringOutput = ValueString or "nil"
|
||||
if mainAction and subAction then
|
||||
local key = tonumber(mainAction)
|
||||
itemedit.Components[key][subAction] = Value
|
||||
print(sender.Name .. " edited '" .. itemedit.Name .. "' " .. removePeriodsAndNumbers(ActionString) .. " to " .. valueStringOutput)
|
||||
elseif ActionString == "Move" then
|
||||
Value2 = tonumber(ValueString2) or ValueString2
|
||||
itemedit.Move(Vector2(Value, Value2), false)
|
||||
print(sender.Name .. " moved '" .. itemedit.Name .. "' by x" .. valueStringOutput .. " And y" .. ValueString2)
|
||||
else
|
||||
itemedit[ActionString] = Value
|
||||
print(sender.Name .. " edited '" .. itemedit.Name .. "' " .. removePeriodsAndNumbers(ActionString) .. " to " .. valueStringOutput)
|
||||
end
|
||||
local itemupdatetoclient = Networking.Start("itemupdatetoclients")
|
||||
itemupdatetoclient.WriteString(itemupdatestring)
|
||||
Networking.Send(itemupdatetoclient)
|
||||
end)
|
||||
|
||||
|
||||
|
||||
Networking.Receive("serversettingsstart", function ()
|
||||
|
||||
if not File.Exists(EditGUI.Path .. "/settings.json") then
|
||||
File.Write(EditGUI.Path .. "/settings.json", json.serialize(dofile(EditGUI.Path .. "/Lua/defaultsettings.lua")))
|
||||
end
|
||||
-- Load the settings from file
|
||||
local Settings = json.parse(File.Read(EditGUI.Path .. "/settings.json"))
|
||||
-- Serialize the settings table into a string
|
||||
local serializedData = ""
|
||||
for key, value in pairs(Settings) do
|
||||
serializedData = serializedData .. key .. "=" .. tostring(value) .. ";"
|
||||
end
|
||||
|
||||
-- Send the serialized settings data over the network
|
||||
local settingsnetwork = Networking.Start("settingsnetworking")
|
||||
settingsnetwork.WriteString(serializedData)
|
||||
Networking.Send(settingsnetwork)
|
||||
end)
|
||||
|
||||
|
||||
|
||||
Networking.Receive("settingsnetworkupdate", function (settingsnetwork,sender)
|
||||
if not sender.HasPermission(ClientPermissions.All) then
|
||||
return
|
||||
end
|
||||
local receivedData = settingsnetwork.ReadString()
|
||||
local Settingsupdate = {}
|
||||
for key, value in string.gmatch(receivedData, '([^;]+)=([^;]+)') do
|
||||
if value == "true" then
|
||||
Settingsupdate[key] = true
|
||||
elseif value == "false" then
|
||||
Settingsupdate[key] = false
|
||||
else
|
||||
Settingsupdate[key] = tonumber(value) or value
|
||||
end
|
||||
end
|
||||
File.Write(EditGUI.Path .. "/settings.json", json.serialize(Settingsupdate))
|
||||
-- Load the settings from file
|
||||
local Settings = json.parse(File.Read(EditGUI.Path .. "/settings.json"))
|
||||
-- Serialize the settings table into a string
|
||||
local serializedData = ""
|
||||
for key, value in pairs(Settings) do
|
||||
serializedData = serializedData .. key .. "=" .. tostring(value) .. ";"
|
||||
end
|
||||
|
||||
-- Send the serialized settings data over the network
|
||||
local settingsnetwork = Networking.Start("settingsnetworking")
|
||||
settingsnetwork.WriteString(serializedData)
|
||||
Networking.Send(settingsnetwork)
|
||||
end)
|
||||
|
||||
Networking.Receive("servermsgstart", function (itemeditnetwork,sender)
|
||||
if EditGUI.Settings.permissionsetting == 0 then
|
||||
if sender.Permissions == 0 then
|
||||
return
|
||||
end
|
||||
else
|
||||
if not sender.HasPermission(ClientPermissions[EditGUI.Settings.permissionsetting]) then
|
||||
return
|
||||
end
|
||||
end
|
||||
local itemedit = Entity.FindEntityByID(itemeditnetwork.ReadUInt16())
|
||||
itemedit.SpriteDepth = itemeditnetwork.ReadSingle()
|
||||
itemedit.Rotation = itemeditnetwork.ReadSingle()
|
||||
itemedit.Scale = itemeditnetwork.ReadSingle()
|
||||
itemedit.Condition = itemeditnetwork.ReadSingle()
|
||||
itemedit.Tags = itemeditnetwork.ReadString()
|
||||
itemedit.NonInteractable = itemeditnetwork.ReadBoolean()
|
||||
itemedit.NonPlayerTeamInteractable = itemeditnetwork.ReadBoolean()
|
||||
itemedit.InvulnerableToDamage = itemeditnetwork.ReadBoolean()
|
||||
itemedit.DisplaySideBySideWhenLinked = itemeditnetwork.ReadBoolean()
|
||||
itemedit.HiddenInGame = itemeditnetwork.ReadBoolean()
|
||||
|
||||
|
||||
Networking.CreateEntityEvent(itemedit, Item.ChangePropertyEventData(itemedit.SerializableProperties[Identifier("SpriteDepth")], itemedit))
|
||||
Networking.CreateEntityEvent(itemedit, Item.ChangePropertyEventData(itemedit.SerializableProperties[Identifier("Rotation")], itemedit))
|
||||
Networking.CreateEntityEvent(itemedit, Item.ChangePropertyEventData(itemedit.SerializableProperties[Identifier("Scale")], itemedit))
|
||||
Networking.CreateEntityEvent(itemedit, Item.ChangePropertyEventData(itemedit.SerializableProperties[Identifier("Condition")], itemedit))
|
||||
Networking.CreateEntityEvent(itemedit, Item.ChangePropertyEventData(itemedit.SerializableProperties[Identifier("Tags")], itemedit))
|
||||
Networking.CreateEntityEvent(itemedit, Item.ChangePropertyEventData(itemedit.SerializableProperties[Identifier("NonInteractable")], itemedit))
|
||||
Networking.CreateEntityEvent(itemedit, Item.ChangePropertyEventData(itemedit.SerializableProperties[Identifier("NonPlayerTeamInteractable")], itemedit))
|
||||
Networking.CreateEntityEvent(itemedit, Item.ChangePropertyEventData(itemedit.SerializableProperties[Identifier("InvulnerableToDamage")], itemedit))
|
||||
Networking.CreateEntityEvent(itemedit, Item.ChangePropertyEventData(itemedit.SerializableProperties[Identifier("DisplaySideBySideWhenLinked")], itemedit))
|
||||
Networking.CreateEntityEvent(itemedit, Item.ChangePropertyEventData(itemedit.SerializableProperties[Identifier("HiddenInGame")], itemedit))
|
||||
end)
|
||||
|
||||
Networking.Receive("flipxnetwork", function (mirrorx,sender)
|
||||
if EditGUI.Settings.permissionsetting == 0 then
|
||||
if sender.Permissions == 0 then
|
||||
return
|
||||
end
|
||||
else
|
||||
if not sender.HasPermission(ClientPermissions[EditGUI.Settings.permissionsetting]) then
|
||||
return
|
||||
end
|
||||
end
|
||||
local itemedit = Entity.FindEntityByID(mirrorx.ReadUInt16())
|
||||
if itemedit then
|
||||
itemedit.FlipX(false)
|
||||
print(sender.Name .. " MirroredX '" .. itemedit.Name .. "'")
|
||||
|
||||
local flipx = Networking.Start("flipxclientnetwork")
|
||||
flipx.WriteUInt16(UShort(itemedit.ID))
|
||||
Networking.Send(flipx)
|
||||
end
|
||||
end)
|
||||
|
||||
Networking.Receive("flipynetwork", function (mirrory,sender)
|
||||
if EditGUI.Settings.permissionsetting == 0 then
|
||||
if sender.Permissions == 0 then
|
||||
return
|
||||
end
|
||||
else
|
||||
if not sender.HasPermission(ClientPermissions[EditGUI.Settings.permissionsetting]) then
|
||||
return
|
||||
end
|
||||
end
|
||||
local itemedit = Entity.FindEntityByID(mirrory.ReadUInt16())
|
||||
|
||||
if itemedit then
|
||||
itemedit.FlipY(false)
|
||||
print(sender.Name .. " MirroredY '" .. itemedit.Name .. "'")
|
||||
|
||||
local flipy = Networking.Start("flipyclientnetwork")
|
||||
flipy.WriteUInt16(UShort(itemedit.ID))
|
||||
Networking.Send(flipy)
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
|
||||
Networking.Receive("linkremove", function (msg,sender)
|
||||
if EditGUI.Settings.permissionsetting == 0 then
|
||||
if sender.Permissions == 0 then
|
||||
return
|
||||
end
|
||||
else
|
||||
if not sender.HasPermission(ClientPermissions[EditGUI.Settings.permissionsetting]) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local itemedit1 = Entity.FindEntityByID(msg.ReadUInt16())
|
||||
local itemedit2 = Entity.FindEntityByID(msg.ReadUInt16())
|
||||
LinkRemove(itemedit1, itemedit2)
|
||||
print(sender.Name .. " unlinked '" .. itemedit1.Name .. "' and '" .. itemedit2.Name .. "'")
|
||||
|
||||
local msg = Networking.Start("lualinker.remove")
|
||||
msg.WriteUInt16(UShort(itemedit1.ID))
|
||||
msg.WriteUInt16(UShort(itemedit2.ID))
|
||||
Networking.Send(msg)
|
||||
end)
|
||||
|
||||
Networking.Receive("linkadd", function (msg,sender)
|
||||
if EditGUI.Settings.permissionsetting == 0 then
|
||||
if sender.Permissions == 0 then
|
||||
return
|
||||
end
|
||||
else
|
||||
if not sender.HasPermission(ClientPermissions[EditGUI.Settings.permissionsetting]) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local itemedit1 = Entity.FindEntityByID(msg.ReadUInt16())
|
||||
local itemedit2 = Entity.FindEntityByID(msg.ReadUInt16())
|
||||
LinkAdd(itemedit1, itemedit2)
|
||||
print(sender.Name .. " linked '" .. itemedit1.Name .. "' and '" .. itemedit2.Name .. "'")
|
||||
|
||||
local msg = Networking.Start("lualinker.add")
|
||||
msg.WriteUInt16(UShort(itemedit1.ID))
|
||||
msg.WriteUInt16(UShort(itemedit2.ID))
|
||||
Networking.Send(msg)
|
||||
|
||||
end)
|
||||
|
||||
|
||||
end
|
||||
|
||||
-- Server Side End --
|
||||
-- Client Side Start --
|
||||
|
||||
if CLIENT and Game.IsMultiplayer then
|
||||
|
||||
local function split(str, separator)
|
||||
if str == nil then
|
||||
return {} -- Return an empty table for an empty string
|
||||
end
|
||||
local result = {}
|
||||
local pattern = string.format("([^%s]+)", separator)
|
||||
str:gsub(pattern, function(c) result[#result + 1] = c end)
|
||||
return result
|
||||
end
|
||||
|
||||
Networking.Receive("itemupdatetoclients", function (itemupdatetoclient)
|
||||
itemupdatestring = itemupdatetoclient.ReadString()
|
||||
local values = split(itemupdatestring, "|")
|
||||
local ItemString = values[1]
|
||||
local ActionString = values[2]
|
||||
local ValueString = values[3]
|
||||
if values[4] then
|
||||
ValueString2 = values[4]
|
||||
else
|
||||
ValueString2 = nil
|
||||
end
|
||||
-- Perform the logic on the server
|
||||
local itemedit = Entity.FindEntityByID(tonumber(ItemString))
|
||||
local Value = nil
|
||||
if ValueString == "true" then
|
||||
Value = true
|
||||
elseif ValueString == "false" then
|
||||
Value = false
|
||||
elseif ValueString2 == "Color" then
|
||||
local colorValues = split(ValueString , ",")
|
||||
if #colorValues == 4 then
|
||||
Value = Color(tonumber(colorValues[1]), tonumber(colorValues[2]), tonumber(colorValues[3]), tonumber(colorValues[4]))
|
||||
end
|
||||
elseif ValueString2 == "RequiredItems" then
|
||||
Value = ConvertStringToRequiredItems(ValueString)
|
||||
else
|
||||
Value = tonumber(ValueString) or ValueString
|
||||
end
|
||||
local mainAction, subAction = ActionString:match("(.-)%.([^%.]+)$")
|
||||
if mainAction and subAction then
|
||||
local key = tonumber(mainAction)
|
||||
itemedit.Components[key][subAction] = Value
|
||||
elseif ActionString == "Move" then
|
||||
Value2 = tonumber(ValueString2) or ValueString2
|
||||
itemedit.Move(Vector2(Value, Value2), false)
|
||||
else
|
||||
itemedit[ActionString] = Value
|
||||
end
|
||||
end)
|
||||
|
||||
Networking.Send(Networking.Start("serversettingsstart"))
|
||||
|
||||
Networking.Receive("flipxclientnetwork", function (flipx)
|
||||
local itemedit = Entity.FindEntityByID(flipx.ReadUInt16())
|
||||
if itemedit then
|
||||
itemedit.FlipX(false)
|
||||
end
|
||||
end)
|
||||
|
||||
Networking.Receive("flipyclientnetwork", function (flipy)
|
||||
local itemedit = Entity.FindEntityByID(flipy.ReadUInt16())
|
||||
if itemedit then
|
||||
itemedit.FlipY(false)
|
||||
end
|
||||
end)
|
||||
|
||||
Networking.Receive("lualinker.add", function (msg)
|
||||
local itemedit1 = Entity.FindEntityByID(msg.ReadUInt16())
|
||||
local itemedit2 = Entity.FindEntityByID(msg.ReadUInt16())
|
||||
LinkAdd(itemedit1, itemedit2)
|
||||
if links == true then
|
||||
Links()
|
||||
end
|
||||
end)
|
||||
|
||||
Networking.Receive("lualinker.remove", function (msg)
|
||||
local itemedit1 = Entity.FindEntityByID(msg.ReadUInt16())
|
||||
local itemedit2 = Entity.FindEntityByID(msg.ReadUInt16())
|
||||
LinkRemove(itemedit1, itemedit2)
|
||||
if links == true then
|
||||
Links()
|
||||
end
|
||||
end)
|
||||
end
|
||||
-- Client Side End --
|
||||
BIN
Lua Editor/LuaEditor.ogg
LFS
Normal file
BIN
Lua Editor/LuaEditor.ogg
LFS
Normal file
Binary file not shown.
1
Lua Editor/clientsidesettings.json
Normal file
1
Lua Editor/clientsidesettings.json
Normal file
@@ -0,0 +1 @@
|
||||
{"targetnoninteractable":"False","targetingsetting":"Objects","tagstotarget":"","movementamount":1,"targetitems":false,"targetparentinventory":false}
|
||||
4
Lua Editor/filelist.xml
Normal file
4
Lua Editor/filelist.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<contentpackage name="Lua Editor" modversion="1.1.0" corepackage="False" steamworkshopid="2983569829" gameversion="1.5.9.2" expectedhash="2F0A8B96C7FA8BA74043A5C3C8D845BA">
|
||||
<Item file="%ModDir%/Item.xml" />
|
||||
</contentpackage>
|
||||
1
Lua Editor/settings.json
Normal file
1
Lua Editor/settings.json
Normal file
@@ -0,0 +1 @@
|
||||
{"permissionsetting":0,"tagstonottarget":"","allowtargetingnoninteractable":true,"allowtargetingitems":false,"allowtargetingstructures":false,"spritedepth":true,"rotation":true,"scale":true,"scalemin":0.1,"scalemax":0.9,"condition":false,"spritecolor":true,"alpha":false,"tags":true,"description":true,"noninteractable":true,"nonplayerteaminteractable":false,"invulnerabletodamage":false,"displaysidebysidewhenlinked":true,"hiddeningame":false,"mirror":true,"lightcomponent":false,"holdable":false,"connectionpanel":false,"fabricator":false,"deconstructor":false,"reactor":false,"oxygengenerator":false,"sonar":false,"repairable":false,"powertransfer":false,"itemcontainer":false,"door":false,"itemlabel":false,"quality":false,"components":false}
|
||||
BIN
Lua Editor/toolgun.png
LFS
Normal file
BIN
Lua Editor/toolgun.png
LFS
Normal file
Binary file not shown.
Reference in New Issue
Block a user