From b5c16a801bf46709873e9ae9dd93c46e60bc5ace Mon Sep 17 00:00:00 2001 From: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com> Date: Thu, 2 Dec 2021 12:49:51 +0100 Subject: [PATCH 1/4] unnecessary brackets --- gamemode/core/util/cl_draw.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gamemode/core/util/cl_draw.lua b/gamemode/core/util/cl_draw.lua index 3966751d..d587c2a6 100644 --- a/gamemode/core/util/cl_draw.lua +++ b/gamemode/core/util/cl_draw.lua @@ -26,7 +26,7 @@ function nut.util.wrapText(text, width, font) local maxW = 0 if (w <= width) then - return {(text:gsub("%s", " "))}, w + return {text:gsub("%s", " ")}, w end for i = 1, #exploded do From 33950d38eedc454489fa90b1e8d65e32600efb0d Mon Sep 17 00:00:00 2001 From: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com> Date: Sat, 4 Dec 2021 17:09:43 +0100 Subject: [PATCH 2/4] Update sh_outfit.lua Make it so that bodygroups persist after taking off an item that modifies your bodygroups c: --- gamemode/items/base/sh_outfit.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gamemode/items/base/sh_outfit.lua b/gamemode/items/base/sh_outfit.lua index eb91b0af..0957a67d 100644 --- a/gamemode/items/base/sh_outfit.lua +++ b/gamemode/items/base/sh_outfit.lua @@ -60,11 +60,13 @@ function ITEM:removeOutfit(client) client:SetSkin(character:getData("oldSkin", character:getData("skin", 0))) character:setData("oldSkin", nil) + + local oldGroups = character:getData("oldGroups", {}) for k, v in pairs(self.bodyGroups or {}) do local index = client:FindBodygroupByName(k) if (index > -1) then - client:SetBodygroup(index, 0) + client:SetBodygroup(index, oldGroups[index] or 0) local groups = character:getData("groups", {}) @@ -74,6 +76,7 @@ function ITEM:removeOutfit(client) end end end + character:setData("oldGroups", nil) end -- Then, remove PAC parts from this outfit. @@ -185,18 +188,21 @@ ITEM.functions.Equip = { -- Then set appropriate body groups for the model. if (istable(item.bodyGroups)) then + local oldGroups = {} local groups = {} for k, value in pairs(item.bodyGroups) do local index = item.player:FindBodygroupByName(k) if (index > -1) then + oldGroups[index] = item.player:GetBodygroup(index) groups[index] = value end end - local newGroups = char:getData("groups", {}) + char:setData("oldGroups", oldGroups) + local newGroups = char:getData("groups", {}) for index, value in pairs(groups) do newGroups[index] = value item.player:SetBodygroup(index, value) From 0ca7ba91f0476a0a16debe0ce11b44a43749226b Mon Sep 17 00:00:00 2001 From: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com> Date: Sat, 4 Dec 2021 17:23:40 +0100 Subject: [PATCH 3/4] Revert "Update sh_outfit.lua" This reverts commit 33950d38eedc454489fa90b1e8d65e32600efb0d. --- gamemode/items/base/sh_outfit.lua | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/gamemode/items/base/sh_outfit.lua b/gamemode/items/base/sh_outfit.lua index 0957a67d..eb91b0af 100644 --- a/gamemode/items/base/sh_outfit.lua +++ b/gamemode/items/base/sh_outfit.lua @@ -60,13 +60,11 @@ function ITEM:removeOutfit(client) client:SetSkin(character:getData("oldSkin", character:getData("skin", 0))) character:setData("oldSkin", nil) - - local oldGroups = character:getData("oldGroups", {}) for k, v in pairs(self.bodyGroups or {}) do local index = client:FindBodygroupByName(k) if (index > -1) then - client:SetBodygroup(index, oldGroups[index] or 0) + client:SetBodygroup(index, 0) local groups = character:getData("groups", {}) @@ -76,7 +74,6 @@ function ITEM:removeOutfit(client) end end end - character:setData("oldGroups", nil) end -- Then, remove PAC parts from this outfit. @@ -188,21 +185,18 @@ ITEM.functions.Equip = { -- Then set appropriate body groups for the model. if (istable(item.bodyGroups)) then - local oldGroups = {} local groups = {} for k, value in pairs(item.bodyGroups) do local index = item.player:FindBodygroupByName(k) if (index > -1) then - oldGroups[index] = item.player:GetBodygroup(index) groups[index] = value end end - char:setData("oldGroups", oldGroups) - local newGroups = char:getData("groups", {}) + for index, value in pairs(groups) do newGroups[index] = value item.player:SetBodygroup(index, value) From 54ff569077d19f1e42620306e4db8d25860eab42 Mon Sep 17 00:00:00 2001 From: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com> Date: Sat, 4 Dec 2021 17:26:15 +0100 Subject: [PATCH 4/4] Update sh_outfit.lua Allow bodygroups to persist after outfits that edit bodygroups change them --- gamemode/items/base/sh_outfit.lua | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/gamemode/items/base/sh_outfit.lua b/gamemode/items/base/sh_outfit.lua index eb91b0af..e99f30ee 100644 --- a/gamemode/items/base/sh_outfit.lua +++ b/gamemode/items/base/sh_outfit.lua @@ -60,11 +60,13 @@ function ITEM:removeOutfit(client) client:SetSkin(character:getData("oldSkin", character:getData("skin", 0))) character:setData("oldSkin", nil) - for k, v in pairs(self.bodyGroups or {}) do + + local oldGroups = character:getData("oldGroups", {}) + for k in pairs(self.bodyGroups or {}) do local index = client:FindBodygroupByName(k) if (index > -1) then - client:SetBodygroup(index, 0) + client:SetBodygroup(index, oldGroups[index] or 0) local groups = character:getData("groups", {}) @@ -74,6 +76,7 @@ function ITEM:removeOutfit(client) end end end + character:setData("oldGroups", nil) end -- Then, remove PAC parts from this outfit. @@ -134,7 +137,7 @@ ITEM.functions.Equip = { local char = item.player:getChar() local items = char:getInv():getItems() - for id, other in pairs(items) do + for _, other in pairs(items) do if ( item ~= other and item.outfitCategory == other.outfitCategory and @@ -167,7 +170,7 @@ ITEM.functions.Equip = { ):lower() char:setModel(newModel) else - for k, v in ipairs(item.replacements) do + for _, v in ipairs(item.replacements) do char:setModel(item.player:GetModel():gsub(v[1], v[2])) end end @@ -185,18 +188,21 @@ ITEM.functions.Equip = { -- Then set appropriate body groups for the model. if (istable(item.bodyGroups)) then + local oldGroups = {} local groups = {} for k, value in pairs(item.bodyGroups) do local index = item.player:FindBodygroupByName(k) if (index > -1) then + oldGroups[index] = item.player:GetBodygroup(index) groups[index] = value end end - local newGroups = char:getData("groups", {}) + char:setData("oldGroups", oldGroups) + local newGroups = char:getData("groups", {}) for index, value in pairs(groups) do newGroups[index] = value item.player:SetBodygroup(index, value) @@ -239,11 +245,9 @@ function ITEM:onLoadout() end function ITEM:onRemoved() - local inv = nut.item.inventories[self.invID] - if (IsValid(receiver) and receiver:IsPlayer()) then - if (self:getData("equip")) then - self:removeOutfit(receiver) - end + --local inv = nut.item.inventories[self.invID] + if (IsValid(receiver) and receiver:IsPlayer()) and (self:getData("equip")) then + self:removeOutfit(receiver) end end