Skip to content

Commit e24bdfe

Browse files
authored
Blood manipulation functions for E2 (#3309)
* Blood manipulation functions for E2 * Add missing dot * Fix invalid return * Add missing `IsOwner` check I did this with my phone and completely forgot about it.
1 parent e4a2951 commit e24bdfe

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

lua/entities/gmod_wire_expression2/core/entity.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,26 @@ e2function number entity:getBodygroups(bgrp_id)
591591
return this:GetBodygroupCount(bgrp_id)
592592
end
593593

594+
E2Lib.registerConstant("BLOOD_DONT_BLEED", DONT_BLEED)
595+
E2Lib.registerConstant("BLOOD_COLOR_RED", BLOOD_COLOR_RED)
596+
E2Lib.registerConstant("BLOOD_COLOR_YELLOW", BLOOD_COLOR_YELLOW)
597+
E2Lib.registerConstant("BLOOD_COLOR_GREEN", BLOOD_COLOR_GREEN)
598+
E2Lib.registerConstant("BLOOD_COLOR_MECH", BLOOD_COLOR_MECH)
599+
E2Lib.registerConstant("BLOOD_COLOR_ANTLION", BLOOD_COLOR_ANTLION)
600+
E2Lib.registerConstant("BLOOD_COLOR_ZOMBIE", BLOOD_COLOR_ZOMBIE)
601+
E2Lib.registerConstant("BLOOD_COLOR_ANTLION_WORKER", BLOOD_COLOR_ANTLION_WORKER)
602+
603+
e2function void entity:setBloodColor(number bloodcolor)
604+
if not IsValid(this) then return self:throw("Invalid entity!", nil) end
605+
if not isOwner(self, this) then return self:throw("You do not own this entity!", nil) end
606+
this:SetBloodColor(math.Clamp(bloodcolor, -1, 6))
607+
end
608+
609+
e2function number entity:getBloodColor()
610+
if not IsValid(this) then return self:throw("Invalid entity!", -1) end
611+
return this:GetBloodColor() or -1
612+
end
613+
594614
--[[******************************************************************************]]
595615

596616
e2function number entity:isPlayerHolding()

lua/wire/client/e2descriptions.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,8 @@ E2Helper.Descriptions["runOnChat(n)"] = "DEPRECATED. Use 'event chat(Player:enti
10891089
-- Color
10901090
E2Helper.Descriptions["setBodygroup(e:nn)"] = "Group ID, Group SubID\nSets the bodygroups of the given entity"
10911091
E2Helper.Descriptions["getBodygroups(e:n)"] = "Group ID\nReturns the number of bodygroups in the Group ID of the given entity"
1092+
E2Helper.Descriptions["setBloodColor(e:n)"] = "Sets the blood color of an entity via a number (_BLOOD)."
1093+
E2Helper.Descriptions["getBloodColor(e:)"] = "Returns the blood color of an entity as a number (_BLOOD)."
10921094
E2Helper.Descriptions["setColor(nnn)"] = "Sets the color of the E2 chip"
10931095
E2Helper.Descriptions["setColor(e:vn)"] = "Sets the color (as vector) and alpha (as number) of the entity"
10941096
E2Helper.Descriptions["setColor(e:xv4)"] = "Sets the color and alpha (as 4D vector) of the entity"

0 commit comments

Comments
 (0)