So, I have been remaking Xytus's Dark Messiah Dragon SNPC using my SNPC base and fixing his. So I got everything working to it's old self and the new upgrades I put in. Well earlier when I started working on it the turning code was messed up. Sense it's an air SNPC I have been struggling with it but I get this error when It tries to turn:
[ERROR] addons/dark messiah snpcs/lua/entities/npc_cpt_dragon/init.lua:249: attempt to call method 'SetAngle' (a nil value)
1. unknown - addons/dark messiah snpcs/lua/entities/npc_cpt_dragon/init.lua:249
Here is the line and some surrounding code:
245 //set fixed angles
246 local phy = self:GetPhysicsObject()
247 if phy:IsValid() then
248 local velocity = phy:GetVelocity()
249 phy:SetAngle( defaultangle )
250 phy:SetVelocity(velocity)
251 end
265 local defaultangle = Angle(20,self:GetAngles().y,0)
I have been up all night so Im kind of tired so I think that might be making it hard for me to figure this out. I can assume this something easy. So please help me figure this out. Also dont say use SetAngles() because it gives the same error.
Quick responses much appreciated
[IMG]http://i57.tinypic.com/71tsvb.jpg[/IMG]
[IMG]http://i62.tinypic.com/2iuw3tu.jpg[/IMG]
Try SetAngles instead.
[QUOTE=Acecool;45117930]Try SetAngles instead.[/QUOTE]
Nope, It gives the same error except it says SetAngles instead of SetAngle in the error :/
Try doing self:SetAngles( ) instead of on the physics object.
[QUOTE=Acecool;45118154]Try doing self:SetAngles( ) instead of on the physics object.[/QUOTE]
BRO THANK YOU!!!
It now turns and attacks =)
Now that I look at it, this was actually a pretty easy error.
I guess you can't use the 'local' as a string.
[IMG]http://i58.tinypic.com/sl7itz.jpg[/IMG]
Why not?
You can define local in places, but make sure you understand scope. If you define a local inside an if; it is local to the inside of that if and nothing outside of it will see it. Likewise, local in a file will only be visible to the file, in a loop, etc etc ...
Please mark this as solved in the upper left corner!
Sorry, you need to Log In to post a reply to this thread.