Skip to content

Commit

Permalink
Update entity.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
shadow7483147 authored Aug 27, 2019
1 parent 4601f5f commit 277ca0a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lua/entities/gmod_wire_expression2/core/entity.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ local validPhysics = E2Lib.validPhysics
local getOwner = E2Lib.getOwner
local isOwner = E2Lib.isOwner

local sun = ents.FindByClass( "env_sun" )[1]
local sun = ents.FindByClass("env_sun")[1] -- used for sunDirection()

hook.Add("InitPostEntity","sunent",function()
sun = ents.FindByClass("env_sun")[1]
timer.Simple(0,function() -- make sure we have a sun first
hook.Remove("InitPostEntity","sunent")
end ) -- then remove this. we don't need it anymore.
end )

registerCallback("e2lib_replace_function", function(funcname, func, oldfunc)
if funcname == "isOwner" then
Expand Down Expand Up @@ -194,7 +201,7 @@ end
--- Specific to env_sun because Source is dum. Use this to trace towards the sun or something.
e2function vector sunDirection()
if not isValid(sun) then return { 0, 0, 0 } end
return sun:GetKeyValues()["sun_dir"]
return sun:GetKeyValues().sun_dir
end

/******************************************************************************/
Expand Down

0 comments on commit 277ca0a

Please sign in to comment.