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

Allow find empty space to accept vectors. #436

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
11 changes: 8 additions & 3 deletions gamemode/core/sh_util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -903,13 +903,18 @@ ALWAYS_RAISED["weapon_physgun"] = true
ALWAYS_RAISED["gmod_tool"] = true
ALWAYS_RAISED["ix_poshelper"] = true

function ix.util.FindEmptySpace(entity, filter, spacing, size, height, tolerance)
function ix.util.FindEmptySpace(variable, filter, spacing, size, height, tolerance)
filter = filter or {}
spacing = spacing or 32
size = size or 3
height = height or 36
tolerance = tolerance or 5

local position = entity:GetPos()
local position = isvector(variable) and variable or isentity(variable) and variable:GetPos()
if (!position) then
return
end

local mins, maxs = Vector(-spacing * 0.5, -spacing * 0.5, 0), Vector(spacing * 0.5, spacing * 0.5, height)
local output = {}

Expand All @@ -920,7 +925,7 @@ function ix.util.FindEmptySpace(entity, filter, spacing, size, height, tolerance
local data = {}
data.start = origin + mins + Vector(0, 0, tolerance)
data.endpos = origin + maxs
data.filter = filter or entity
data.filter = filter or isentity(variable) and variable or {}
local trace = util.TraceLine(data)

data.start = origin + Vector(-maxs.x, -maxs.y, tolerance)
Expand Down
Loading