General > Developers Corner

Value becomes nil/invalid/not a vector.

(1/2) > >>

LuaTenshi:

--- Code: ---for _,v in next, ents.FindByClass("prop_*") do
local owner = APA.FindOwner(v);
local box = Vector(0,0,0);

if IsValid(owner) and IsValid(v) and not APA.IsWorld(v) then
box = v:LocalToWorld(v:GetCollisionBounds());
if box and isvector(box) then
for _,x in next, ents.FindInBox(box) do
print(v, owner, x)
if IsValid(x) and isPlayer(x) then
makeSpawnGhost(v,owner)
print(x)
end
end
end
end
end

--- End code ---

Getting the following error...

bad argument #2 to 'FindInBox' (Vector exp
ected, got no value)

This is not the full code, but I assure you that all the functions work, but for some reason the box variable gets lost.

roastchicken:
Bad argument #2 to 'FindInBox' (Vector expected, got no value)

ents/FindInBox takes two arguments, the box minimum and the box maximum. You're taking the return values of Entity/GetCollisionsBounds and putting it in one variable, when it returns two values. Use boxMin, boxMax = v:LocalToWorld(v:GetCollisionBounds()) and then pass those arguments to ents/FindInBox.

LuaTenshi:
Ugh, a rookie mistake. Now people are gonna laugh at me. Thanks for the help tho.

Bytewave:

--- Quote from: LuaTenshi on October 14, 2015, 08:11:34 PM ---Ugh, a rookie mistake. Now people are gonna laugh at me. Thanks for the help tho.

--- End quote ---
Even professionals make rookie mistakes. Don't look down on yourself. ;)

JamminR:

--- Quote from: LuaTenshi on October 14, 2015, 08:11:34 PM ---Now people are gonna laugh at me.

--- End quote ---
No worries.
It's not just been 'now'.

* JamminR ducks

Navigation

[0] Message Index

[#] Next page

Go to full version