Original Code said:
local function IsOutside()
local pos = LocalPlayer():EyePos()
local trace = util.TraceLine( {start = pos, endpos = pos+Vector( 0, 0, 32768), mask=MASK_SOLID_BRUSHONLY + MASK_BLOCKLOS + MASK_SOLID + CONTENTS_MOVEABLE} )
Weather.Outside = (not trace.Hit) or trace.HitSky
if Weather.Outside then
Weather.Height = math.min( (trace.Hit and (trace.HitPos.z - trace.StartPos.z) or 800) - 20, 800 )
else
Weather.Height = math.max( (trace.Hit and (trace.HitPos.z - trace.StartPos.z) or 800) + 100, 400 )
end
return Weather.Outside
end
Click to expand...
Now, I modified it in everyway possible, but I can't seem to NOT make it go through some of the roofs.
This is the code that checks if you are outside, so it will draw the rain outside.
Can anyone help me on this?
Code that Seems to Work with Other Systems said:
local trace = { };
trace.start = pos;
trace.endpos = trace.start + Vector( 0, 0, 32768 );
trace.mask = MASK_BLOCKLOS;
local tr = util.TraceLine( trace );
if( tr.HitSky ) then return true end
return false;
Click to expand...
That is code that seems to work with OTHER systems, but it gives me this error when I replace it:
[Clockwork] The 'Think' hook failed to run.
lua/cl_weather.lua:16: bad argument #1 to '__add' (Vector expected, got nil)
[Clockwork] The 'HUDPaint' hook failed to run.
lua/cl_weather.lua:16: bad argument #1 to '__add' (Vector expected, got nil)
[
Click to expand...
The code is in cl_weather, but it's not working for some reason.
Any help? I'm trying to solve this as we speak, since I'm new to LUA itself. (A programmer, but just new to LUA.)
Line 16 is: trace.endpos = trace.start + Vector( 0, 0, 32768 );