Data Realms Fan Forums http://45.55.195.193/ |
|
Requesting Team Lua Script for Deployable Turret http://45.55.195.193/viewtopic.php?f=73&t=16504 |
Page 1 of 2 |
Author: | CombatMedic02 [ Fri Sep 11, 2009 1:36 pm ] |
Post subject: | Requesting Team Lua Script for Deployable Turret |
Hey guys I need a script for a new weapon that I am planning to add to the weapons pack that I am going to release. I have made a cool hovering pinned turret and I am working on a deployer for it. The problem I have come across is that when the deployer creates a Turret the turret turns on the user and kills them. I'm guessing this is because I don't know how to set the team of it or something? I would also like to make it selectable if possible, that'd be a real bonus. But yeah it's coming along nicely but it just needs this small script to finish it off. I'd be super grateful to whoever helps me out. [I really have to stop thinking up weapons I can't script. Unless you guys don't mind? ] Thanks in advance, CBM02 |
Author: | CaveCricket48 [ Fri Sep 11, 2009 10:35 pm ] |
Post subject: | Re: Requesting Team Lua Script for Deployable Turret |
It needs to be an actor to be controllable (without andy fancy Lua tricks, anyways.) To set the Team, either put "self.Team = <team#>" or do an area check, and the turret makes the closest actor its team. Like the following: Code: local curdist = 70; for actor in MovableMan.Actors do local dist = SceneMan:ShortestDistance(self.Pos,actor.Pos,true); if dist.Magnitude < curdist then self.Team = actor.Team; end end EDIT: Oh, and to keep it from firing on its team: Code: local curdist = 200; if self.hastarget == false then for actor in MovableMan.Actors do local avgx = actor.Pos.X - self.Pos.X; local avgy = actor.Pos.Y - self.Pos.Y; local dist = math.sqrt(avgx ^ 2 + avgy ^ 2); if dist < curdist and actor.Team ~= self.Team then curdist = dist; self.target = actor; end end |
Author: | CombatMedic02 [ Sat Sep 12, 2009 1:08 pm ] |
Post subject: | Re: Requesting Team Lua Script for Deployable Turret |
So like... Code: function Update(self) local curdist = 70; for actor in MovableMan.Actors do local dist = SceneMan:ShortestDistance(self.Pos,actor.Pos,true); if dist.Magnitude < curdist then self.Team = actor.Team; end end local curdist = 200; if self.hastarget == false then for actor in MovableMan.Actors do local avgx = actor.Pos.X - self.Pos.X; local avgy = actor.Pos.Y - self.Pos.Y; local dist = math.sqrt(avgx ^ 2 + avgy ^ 2); if dist < curdist and actor.Team ~= self.Team then curdist = dist; self.target = actor; end end end that? And my turret is a crab... Code: AddActor = ACrab CopyOf = Dep Turret InstanceName = Turret ScriptPath = DepTurret.rte/Actors/MiniDepTurret/Red.lua Buyable = 0 AddAmmo = Round PresetName = Round Turret ParticleCount = 1 Particle = ACrab CopyOf = Turret Shell = None FireVelocity = 2 Separation = 0 But I can't control it. Is it because I fire it out as a particle? How else could I deploy it? Edit: The Lua isn't working, probably my fault as I'm totally clueless about Lua structure and stuff. I seem to notice if there is a tiny error in a Lua script the whole thing doesn't function. |
Author: | CaveCricket48 [ Sat Sep 12, 2009 3:38 pm ] |
Post subject: | Re: Requesting Team Lua Script for Deployable Turret |
Hmm, didn't know your turret was a crab. In that case, you don't need that second chunk of Lua. Just change the first Lua chunk to this: Code: local curdist = 70; for actor in MovableMan.Actors do local dist = SceneMan:ShortestDistance(self.Pos,actor.Pos,true); if dist.Magnitude < curdist and actor.ID ~= self.ID then self.Team = actor.Team; end end Change the "local curdist" for the range you want the turret to look for an actor to change its Team to. And all that needs to be in "function Create(self)". |
Author: | CombatMedic02 [ Sat Sep 12, 2009 6:41 pm ] |
Post subject: | Re: Requesting Team Lua Script for Deployable Turret |
Code: function Create(self) local curdist = 70; for actor in MovableMan.Actors do local dist = SceneMan:ShortestDistance(self.Pos,actor.Pos,true); if dist.Magnitude < curdist and actor.ID ~= self.ID then self.Team = actor.Team; end end end Still refusing to work. Any other ideas? |
Author: | CaveCricket48 [ Sat Sep 12, 2009 7:08 pm ] |
Post subject: | Re: Requesting Team Lua Script for Deployable Turret |
Check for ini problems, like the "ScriptPath" line. Other than that, I don't see why it's not working. |
Author: | Mind [ Sat Sep 12, 2009 7:11 pm ] |
Post subject: | Re: Requesting Team Lua Script for Deployable Turret |
I'm sorry, but I'm confused as to what this is. Is the turret a.) Mannable b.) start with a team So you want it to not fire on the team of whoever's manning it? Sorry, read to OP, just not getting it as a whole. |
Author: | CaveCricket48 [ Sat Sep 12, 2009 7:18 pm ] |
Post subject: | Re: Requesting Team Lua Script for Deployable Turret |
The turret is an ACrab that can be placed in bunker building phase and deployed from a gun. The problem is the the turret is not on the correct Team when deployed from the gun. |
Author: | CombatMedic02 [ Sat Sep 12, 2009 8:10 pm ] |
Post subject: | Re: Requesting Team Lua Script for Deployable Turret |
CaveCricket48 wrote: The turret is an ACrab that can be placed in bunker building phase and deployed from a gun. The problem is the the turret is not on the correct Team when deployed from the gun. Correct. I really don't get why it's not working then. I checked the .ini and added it to the crab that gets fired out. Or should I add it to the gun? o.O Also the turret is killing everything at the moment. It doesn't seem to assign it's self to any team... it's like it's not even using the Lua script. |
Author: | CrazyMLC [ Sat Sep 12, 2009 11:25 pm ] |
Post subject: | Re: Requesting Team Lua Script for Deployable Turret |
When it is fired is it just a ball or is it the turret? I don't think it will work if it gets fired out any other way than a turret. |
Author: | CombatMedic02 [ Sat Sep 12, 2009 11:44 pm ] |
Post subject: | Re: Requesting Team Lua Script for Deployable Turret |
It gets fired out as the turret. [ACrab] But it doesn't figure out what team it is on then it kills everyone in the area. It doesn't seem like the Lua script is working but I've checked the .ini and everything seems to be fine. So I'm not sure what's wrong with it... Uh got this come up... Code: function Create(self) local curdist = 20; for actor in MovableMan.Actors do local dist = SceneMan:ShortestDistance(self.Pos,actor.Pos,true); if dist.Magnitude < curdist and actor.ID ~= self.ID then self.Team = actor.Team; end end end That is Red.Lua... But the only 0 in there is okay? o.O |
Author: | CrazyMLC [ Sun Sep 13, 2009 12:20 am ] |
Post subject: | Re: Requesting Team Lua Script for Deployable Turret |
Code: function Create(self) local curdist = 20 for actor in MovableMan.Actors do local dist = SceneMan:ShortestDistance(self.Pos,actor.Pos,true); if dist.Magnitude < curdist and actor.ID ~= self.ID then self.Team = actor.Team; end end end If I am correct the curdist = 20 isn't in a loop and therefore doesn't need a semi-colon. |
Author: | CombatMedic02 [ Sun Sep 13, 2009 12:21 am ] |
Post subject: | Re: Requesting Team Lua Script for Deployable Turret |
There wasn't ment to be a ";" there? I wouldn't have known that. Thanks, lets try that. xP |
Author: | Grif [ Sun Sep 13, 2009 12:25 am ] |
Post subject: | Re: Requesting Team Lua Script for Deployable Turret |
That's not the problem, ;'s are basically optional, and just part of correct syntax. |
Author: | CombatMedic02 [ Sun Sep 13, 2009 12:27 am ] |
Post subject: | Re: Requesting Team Lua Script for Deployable Turret |
Nope, still not working, same error. Grif ish right... Well what other "unexpected symbol" is there... I mean... I looks like any other Lua i've seen... This sucks, if I got it teaming right I could tune it up and relese it. This is the only thing holding me back. |
Page 1 of 2 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |