Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor changes in the effects core #3174

Merged
merged 1 commit into from
Nov 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions lua/entities/gmod_wire_expression2/core/custom/effects.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
E2Lib.RegisterExtension("effects", false, "Allows E2s to play arbitrary effects.")

local wire_expression2_effect_burst_max = CreateConVar( "wire_expression2_effect_burst_max", 4, {FCVAR_ARCHIVE} )
local wire_expression2_effect_burst_rate = CreateConVar( "wire_expression2_effect_burst_rate", 0.1, {FCVAR_ARCHIVE} )
local wire_expression2_effect_burst_max = CreateConVar("wire_expression2_effect_burst_max", 4, FCVAR_ARCHIVE)
local wire_expression2_effect_burst_rate = CreateConVar("wire_expression2_effect_burst_rate", 0.1, FCVAR_ARCHIVE)

-- Use hook Expression2_CanEffect to blacklist/whitelist effects
local effect_blacklist = {
Expand Down Expand Up @@ -53,14 +53,14 @@ end
e2function effect effect:setOrigin(vector pos)
if not this then return self:throw("Invalid effect!", nil) end

this:SetOrigin(Vector( pos[1], pos[2], pos[3] ))
this:SetOrigin(pos)
return this
end

e2function effect effect:setStart(vector pos)
if not this then return self:throw("Invalid effect!", nil) end

this:SetStart(Vector( pos[1], pos[2], pos[3] ))
this:SetStart(pos)
return this
end

Expand All @@ -74,7 +74,7 @@ end
e2function effect effect:setAngles(angle ang)
if not this then return self:throw("Invalid effect!", nil) end

this:SetAngles( Angle( ang[1] ,ang[2] ,ang[3] ))
this:SetAngles(ang)
return this
end

Expand All @@ -96,7 +96,7 @@ end
e2function effect effect:setNormal(vector norm)
if not this then return self:throw("Invalid effect!", nil) end

this:SetNormal(Vector( norm[1], norm[2], norm[3] ))
this:SetNormal(norm)
return this
end

Expand Down Expand Up @@ -151,8 +151,8 @@ end

e2function effect effect:setColor(number index)
if not this then return self:throw("Invalid effect!", nil) end
index = math.Clamp(index,0,255)
this:SetColor(index)

this:SetColor(math.Clamp(index, 0, 255))
return this
end

Expand All @@ -169,7 +169,7 @@ e2function void effect:play(string name)

name = name:lower()
if effect_blacklist[name] then return self:throw("This effect is blacklisted!", nil) end
if hook.Run( "Expression2_CanEffect", name, self ) == false then return self:throw("A hook prevented this function from running", nil) end
if hook.Run("Expression2_CanEffect", name, self) == false then return self:throw("A hook prevented this function from running", nil) end

fire(self, this, name)
end
Expand All @@ -181,12 +181,11 @@ end
e2function number effectCanPlay(string name)
if not isAllowed(self) then return 0 end
if effect_blacklist[name] then return 0 end
if hook.Run( "Expression2_CanEffect", name:lower(), self ) == false then return 0 end
if hook.Run("Expression2_CanEffect", name:lower(), self) == false then return 0 end

return 1
end


registerCallback("construct", function(self)
self.data.effect_burst = wire_expression2_effect_burst_max:GetInt()
end)
Loading