From 5f1f6144b02af9b2bc48054cc290f834af400956 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Thu, 24 Apr 2025 15:16:57 +0300 Subject: [PATCH 1/4] Blood manipulation functions for E2 --- .../gmod_wire_expression2/core/entity.lua | 19 +++++++++++++++++++ lua/wire/client/e2descriptions.lua | 2 ++ 2 files changed, 21 insertions(+) diff --git a/lua/entities/gmod_wire_expression2/core/entity.lua b/lua/entities/gmod_wire_expression2/core/entity.lua index 9b831c7314..5a13c44ef9 100644 --- a/lua/entities/gmod_wire_expression2/core/entity.lua +++ b/lua/entities/gmod_wire_expression2/core/entity.lua @@ -591,6 +591,25 @@ e2function number entity:getBodygroups(bgrp_id) return this:GetBodygroupCount(bgrp_id) end +E2Lib.registerConstant("BLOOD_DONT_BLEED", DONT_BLEED) +E2Lib.registerConstant("BLOOD_COLOR_RED", BLOOD_COLOR_RED) +E2Lib.registerConstant("BLOOD_COLOR_YELLOW", BLOOD_COLOR_YELLOW) +E2Lib.registerConstant("BLOOD_COLOR_GREEN", BLOOD_COLOR_GREEN) +E2Lib.registerConstant("BLOOD_COLOR_MECH", BLOOD_COLOR_MECH) +E2Lib.registerConstant("BLOOD_COLOR_ANTLION", BLOOD_COLOR_ANTLION) +E2Lib.registerConstant("BLOOD_COLOR_ZOMBIE", BLOOD_COLOR_ZOMBIE) +E2Lib.registerConstant("BLOOD_COLOR_ANTLION_WORKER", BLOOD_COLOR_ANTLION_WORKER) + +e2function void entity:setBloodColor(number bloodcolor) + if not IsValid(this) then return self:throw("Invalid entity!", -1) end + this:SetBloodColor(math.Clamp(bloodcolor, -1, 6)) +end + +e2function number entity:getBloodColor() + if not IsValid(this) then return self:throw("Invalid entity!", -1) end + return this:GetBloodColor() or -1 +end + --[[******************************************************************************]] e2function number entity:isPlayerHolding() diff --git a/lua/wire/client/e2descriptions.lua b/lua/wire/client/e2descriptions.lua index 6558c3a3ab..eb1623b56e 100644 --- a/lua/wire/client/e2descriptions.lua +++ b/lua/wire/client/e2descriptions.lua @@ -1089,6 +1089,8 @@ E2Helper.Descriptions["runOnChat(n)"] = "DEPRECATED. Use 'event chat(Player:enti -- Color E2Helper.Descriptions["setBodygroup(e:nn)"] = "Group ID, Group SubID\nSets the bodygroups of the given entity" E2Helper.Descriptions["getBodygroups(e:n)"] = "Group ID\nReturns the number of bodygroups in the Group ID of the given entity" +E2Helper.Descriptions["setBloodColor(e:n)"] = "Sets the blood color of an entity via a number (_BLOOD)" +E2Helper.Descriptions["getBloodColor(e:)"] = "Returns the blood color of an entity as a number (_BLOOD)." E2Helper.Descriptions["setColor(nnn)"] = "Sets the color of the E2 chip" E2Helper.Descriptions["setColor(e:vn)"] = "Sets the color (as vector) and alpha (as number) of the entity" E2Helper.Descriptions["setColor(e:xv4)"] = "Sets the color and alpha (as 4D vector) of the entity" From 9285bf787638fa68b33b1ce74d877b1bc97dd452 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Thu, 24 Apr 2025 15:19:30 +0300 Subject: [PATCH 2/4] Add missing dot --- lua/wire/client/e2descriptions.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/wire/client/e2descriptions.lua b/lua/wire/client/e2descriptions.lua index eb1623b56e..28849e244c 100644 --- a/lua/wire/client/e2descriptions.lua +++ b/lua/wire/client/e2descriptions.lua @@ -1089,7 +1089,7 @@ E2Helper.Descriptions["runOnChat(n)"] = "DEPRECATED. Use 'event chat(Player:enti -- Color E2Helper.Descriptions["setBodygroup(e:nn)"] = "Group ID, Group SubID\nSets the bodygroups of the given entity" E2Helper.Descriptions["getBodygroups(e:n)"] = "Group ID\nReturns the number of bodygroups in the Group ID of the given entity" -E2Helper.Descriptions["setBloodColor(e:n)"] = "Sets the blood color of an entity via a number (_BLOOD)" +E2Helper.Descriptions["setBloodColor(e:n)"] = "Sets the blood color of an entity via a number (_BLOOD)." E2Helper.Descriptions["getBloodColor(e:)"] = "Returns the blood color of an entity as a number (_BLOOD)." E2Helper.Descriptions["setColor(nnn)"] = "Sets the color of the E2 chip" E2Helper.Descriptions["setColor(e:vn)"] = "Sets the color (as vector) and alpha (as number) of the entity" From b373fbf9f3e16b7a44b300ab88d5802e734cd2b0 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Thu, 24 Apr 2025 15:27:56 +0300 Subject: [PATCH 3/4] Fix invalid return --- lua/entities/gmod_wire_expression2/core/entity.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/entities/gmod_wire_expression2/core/entity.lua b/lua/entities/gmod_wire_expression2/core/entity.lua index 5a13c44ef9..1f24fcdf4e 100644 --- a/lua/entities/gmod_wire_expression2/core/entity.lua +++ b/lua/entities/gmod_wire_expression2/core/entity.lua @@ -601,7 +601,7 @@ E2Lib.registerConstant("BLOOD_COLOR_ZOMBIE", BLOOD_COLOR_ZOMBIE) E2Lib.registerConstant("BLOOD_COLOR_ANTLION_WORKER", BLOOD_COLOR_ANTLION_WORKER) e2function void entity:setBloodColor(number bloodcolor) - if not IsValid(this) then return self:throw("Invalid entity!", -1) end + if not IsValid(this) then return self:throw("Invalid entity!", nil) end this:SetBloodColor(math.Clamp(bloodcolor, -1, 6)) end From 21857ecda5ff84d7597e773967191a6c416c08cd Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Fri, 25 Apr 2025 11:37:04 +0300 Subject: [PATCH 4/4] Add missing `IsOwner` check I did this with my phone and completely forgot about it. --- lua/entities/gmod_wire_expression2/core/entity.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/entities/gmod_wire_expression2/core/entity.lua b/lua/entities/gmod_wire_expression2/core/entity.lua index 1f24fcdf4e..a12a13f817 100644 --- a/lua/entities/gmod_wire_expression2/core/entity.lua +++ b/lua/entities/gmod_wire_expression2/core/entity.lua @@ -602,6 +602,7 @@ E2Lib.registerConstant("BLOOD_COLOR_ANTLION_WORKER", BLOOD_COLOR_ANTLION_WORKER) e2function void entity:setBloodColor(number bloodcolor) if not IsValid(this) then return self:throw("Invalid entity!", nil) end + if not isOwner(self, this) then return self:throw("You do not own this entity!", nil) end this:SetBloodColor(math.Clamp(bloodcolor, -1, 6)) end