Author Topic: Value becomes nil/invalid/not a vector.  (Read 2131 times)

0 Members and 1 Guest are viewing this topic.

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Value becomes nil/invalid/not a vector.
« on: October 13, 2015, 08:50:03 PM »
Code: [Select]
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

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.
I cry every time I see that I am not a respected member of this community.

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: Value becomes nil/invalid/not a vector.
« Reply #1 on: October 14, 2015, 12:10:26 PM »
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.
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: Value becomes nil/invalid/not a vector.
« Reply #2 on: October 14, 2015, 08:11:34 PM »
Ugh, a rookie mistake. Now people are gonna laugh at me. Thanks for the help tho.
I cry every time I see that I am not a respected member of this community.

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Value becomes nil/invalid/not a vector.
« Reply #3 on: October 14, 2015, 08:56:05 PM »
Ugh, a rookie mistake. Now people are gonna laugh at me. Thanks for the help tho.
Even professionals make rookie mistakes. Don't look down on yourself. ;)
bw81@ulysses-forums ~ % whoami
Homepage

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Value becomes nil/invalid/not a vector.
« Reply #4 on: October 14, 2015, 08:57:02 PM »
Now people are gonna laugh at me.
No worries.
It's not just been 'now'.

* JamminR ducks
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Value becomes nil/invalid/not a vector.
« Reply #5 on: October 14, 2015, 09:00:45 PM »
No worries.
It's not just been 'now'.

* JamminR ducks
Wooooow, Jam. Fight fire with water, not tears with a burn. :P
bw81@ulysses-forums ~ % whoami
Homepage