Data Realms Fan Forums http://45.55.195.193/ |
|
Strange Errors http://45.55.195.193/viewtopic.php?f=73&t=25594 |
Page 1 of 1 |
Author: | The5 [ Tue Sep 20, 2011 5:44 pm ] |
Post subject: | Strange Errors |
I want to create gun that marks the targeted actor and makesa his head flash. This is the first time the lua console gave up on me, it does not display any function names but just random characters. this scrip is on the HDFirearm itself: Code: function Create(self) print("create..."); self.weaponRange = 500; self.alliedTeam = -2; self.owner = MovableMan:GetMOFromID(self.RootID); --Parent Actor if MovableMan:IsActor(self.owner) then self.alliedTeam = ToActor(self.owner).Team; --Parent Team end print("created succesfully"); print("own team = " .. self.alliedTeam); end function Update(self) print("update..."); print("1"); local raycast = SceneMan:CastMORay(ToHDFirearm(self).MuzzlePos,Vector(self.weaponRange,0):RadRotate(ToActor(self.owner):GetAimAngle(true)),self.owner.ID,0,false,2); print("2"); if raycast ~= 255 then print("raycast"); print(raycast); local raycast2 = MovableMan:GetMOFromID(MovableMan:GetMOFromID(raycast).RootID); if raycast2.ClassName == "AHuman" then print("raycast2"); print(raycast2); print("toactor head"); ToActor(raycast2).Head:FlashWhite(100); end end end The error must be in the SceneMan:CastMORay(...) function. Probbably something simple im am just overlooking here. |
Author: | Roast Veg [ Tue Sep 20, 2011 5:58 pm ] |
Post subject: | Re: Strange Errors |
The5 wrote: Vector(self.weaponRange,0):RadRotate(ToActor(self.owner):GetAimAngle(true)) I'm pretty sure you're overloading the colon there, seems to be what the error is describing. Try setting it to variables, like: Code: self.ActorAim = ToActor(self.owner):GetAimAngle(true); self.RangeVector = Vector(self.weaponRange,0); local raycast = SceneMan:CastMORay(ToHDFirearm(self).MuzzlePos,self.RangeVector:RadRotate(self.ActorAim),self.owner.ID,0,false,2); No promises that that's the only thing up with it though. |
Author: | The5 [ Tue Sep 20, 2011 6:26 pm ] |
Post subject: | Re: Strange Errors |
On the projectile of this head-homing weapon i got a similar piece of code, that works. Code: local raycast = SceneMan:CastMORay(ToHDFirearm(gun).MuzzlePos,Vector(self.weaponRange,0):RadRotate(ToActor(owner):GetAimAngle(true)),owner.ID,0,false,2); The only difference is, that "gun" was defined before (since the script is on the projectile, not the gun). Code: local gun = MovableMan:GetMOFromID(i) Same for owner Code: local owner = MovableMan:GetMOFromID(gun.RootID) Comparison: Working: local raycast = SceneMan:CastMORay(ToHDFirearm(gun).MuzzlePos,Vector(self.weaponRange,0):RadRotate(ToActor(owner):GetAimAngle(true)),owner.ID,0,false,2); Not-Working: local raycast = SceneMan:CastMORay(ToHDFirearm(self).MuzzlePos,Vector(self.weaponRange,0):RadRotate(ToActor(self.owner):GetAimAngle(true)),self.owner.ID,0,false,2); Could be that "self" doeas not contain the data I expect it to contain. |
Author: | The5 [ Tue Sep 20, 2011 6:41 pm ] |
Post subject: | Re: Strange Errors |
Code: ToHDFirearm(self.gun) ToActor(self.owner) dind't work so I used Code: self.gun = MovableMan:GetMOFromID(self.ID); self.owner = MovableMan:GetMOFromID(self.RootID); EDIT: Hmm it randomly fails, sometimes it works, sometiems it spams errors? EDIT2: The problem seems to occur when I buy a character with another weapon in the hand and the Head-homing-gun in the inventory. Once I switch to it the errors flow in. When I buy a actor with only that gun initially equiped everything works fine. EDIT3: The problem seems to be that the create block won't work correctly when the gun is in a inventory (not in the hand) when spawning! Code: function Create(self) self.weaponRange = 500; self.alliedTeam = -2; self.gun = MovableMan:GetMOFromID(self.ID); self.owner = MovableMan:GetMOFromID(self.RootID); --Parent Actor if MovableMan:IsActor(self.owner) then self.alliedTeam = ToActor(self.owner).Team; --Parent Team end end |
Author: | Coops [ Wed Sep 21, 2011 1:28 am ] |
Post subject: | Re: Strange Errors |
Why are you giving a separate pointer to the scripted object? Code: function Create(self) self.weaponRange = 500 self.alliedTeam = -1 if MovableMan:IsActor(self.owner) then self.alliedTeam = self.owner.Team --Parent Team else -- this owner part should be in the function Update() call by the way. self.owner = MovableMan:GetMOFromID(self.RootID) --Parent Actor end end Try that instead. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |