Data Realms Fan Forums http://45.55.195.193/ |
|
Need some lua to actor (LaserHead) http://45.55.195.193/viewtopic.php?f=73&t=46071 |
Page 1 of 1 |
Author: | Punisher [ Mon Jul 18, 2016 2:29 pm ] |
Post subject: | Need some lua to actor (LaserHead) |
I need lua for the actor, are follows: Actor would have a laser sight, as Techion nanorifle, where you look, there is laser, it better to be from the head and not from body. Experimental code: Code: dofile("Base.rte/Constants.lua") require("Actors/AI/NativeHumanAI") function Create(self) self.AI = NativeHumanAI:Create(self); self.laserTimer = Timer(); self.laserLength = 800; self.laserSpaceCheck = 5; -- For optimization purposes. Smaller value means a more accurate but slower check. self.laserDensity = math.ceil(self.laserLength/self.laserSpaceCheck); end function Update(self) if self.laserTimer:IsPastSimMS(50) then self.laserTimer:Reset(); if self:GetController():IsState(Controller.AIM_SHARP) and self:IsPlayerControlled() == true then local roughLandPos = self.EyePos + Vector(self.laserLength,0):RadRotate(self):GetAimAngle(true); for i = 0, self.laserDensity do local checkPos = self.EyePos + Vector(self.laserSpaceCheck*i,0):GetAimAngle(true); if SceneMan.SceneWrapsX == true then if checkPos.X > SceneMan.SceneWidth then checkPos = Vector(checkPos.X - SceneMan.SceneWidth,checkPos.Y); elseif checkPos.X < 0 then checkPos = Vector(SceneMan.SceneWidth + checkPos.X,checkPos.Y); end end local terrCheck = SceneMan:GetTerrMatter(checkPos.X,checkPos.Y); if terrCheck == 0 then local moCheck = SceneMan:GetMOIDPixel(checkPos.X,checkPos.Y); if moCheck ~= rte.NoMOID and MovableMan:GetMOFromID(moCheck).Team ~= self.Team then roughLandPos = checkPos; break; end else roughLandPos = checkPos; break; end end local checkRoughLandPos = roughLandPos + Vector(self.laserSpaceCheck*-1,0):RadRotate(self):GetAimAngle(true); for i = 0, self.laserSpaceCheck do local checkPos = checkRoughLandPos + Vector(i,0):GetAimAngle(true); if SceneMan.SceneWrapsX == true then if checkPos.X > SceneMan.SceneWidth then checkPos = Vector(checkPos.X - SceneMan.SceneWidth,checkPos.Y); elseif checkPos.X < 0 then checkPos = Vector(SceneMan.SceneWidth + checkPos.X,checkPos.Y); end end local terrCheck = SceneMan:GetTerrMatter(checkPos.X,checkPos.Y); if terrCheck == 0 then local moCheck = SceneMan:GetMOIDPixel(checkPos.X,checkPos.Y); if moCheck ~= 255 then break; end else break; end roughLandPos = checkPos; end local laserPar = CreateMOPixel("Nanorifle Laser Sight Glow"); laserPar.Pos = roughLandPos; MovableMan:AddParticle(laserPar); end end end function UpdateAI(self) self.AI:Update(self) end Does not work. In the console error: ERROR: no overload of 'Vector: RadRotate' matched the arguments (Vector, AHuman) candidates are: Vector: RadRotate (custom [float]) Is nothing said for me. |
Author: | Osek [ Mon Jul 18, 2016 11:05 pm ] |
Post subject: | Re: Need some lua to actor (LaserHead) |
Hi there. Look carefully at lines 14 and 36. Looks like you misplaced a parenthesis, instead of putting a ')' after last self, put it right at the end of the line before ';'. Otherwise you're trying to pass self (a reference to the actor and unexpected argument type) to the function RadRotate and then calling GetAimAngle on the return value. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |