Hi,
I'm learning lua and I know this is an easy question, but I can't seem to figure it out. On my SWEP, which is virtually copied from the Chair throwing SWEP page on the Lua wiki, says that this line has too many syntax levels:
[lua] ent:SetPos(self.Owner:EyePos() + (self.Owner:GetAimVector() * 16))[/lua]
This is in a greater chunk of code that looks like this:
[lua]
local ent = ents.Create("prop_physics")
ent.SetModel(model_file)
ent:SetPos(self.Owner:EyePos() + (self.Owner:GetAimVector() * 16))
ent:SetAngles(self.Owner:EyeAngles())
ent:Spawn()[/lua]
Now, I was looking through the methods associated with 'Player' and I can't seem to even find one called 'EyePos'. I know the tutorial is old, so that may be the problem. I know what is happening here - the entity is being created at the player's eye, plus sixteen unit vectors away from the direction he is aiming. I just don't understand exactly what I can change here.
Would it be appropriate to, perhaps, use an eyetrace instead. Something like self.Owner:GetEyeTrace() = trace and then do trace.StartPos(). I know that trace is defined similarly to this but never seemingly used in the example code.
Thanks for any help. I didn't want to be a bother, but alas, here I am. Just trying to learn.
-- Now I fixed the above, but now when I call SetModel(x), it expects an Entity, when according to the Lua wiki, it should be expecting a String. Why is this? I'm giving it a String.
its ent:SetModel not ent.SetModel
Ah, I'm an idiot. Thanks.
Sorry, you need to Log In to post a reply to this thread.