Author |
Message |
CrazyMLC
Joined: Fri Dec 22, 2006 4:20 am Posts: 4772 Location: Good news everyone!
|
Re: Requesting Team Lua Script for Deployable Turret
Code: function Create(self) local curdist = 20 end
function Update() 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
Code: function Update() 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 < 100 then self.Team = actor.Team; end end end These are probably wrong but it's my best guess at the moment.
|
Sun Sep 13, 2009 12:30 am |
|
|
CombatMedic02
Joined: Wed Dec 17, 2008 11:35 am Posts: 122 Location: London
|
Re: Requesting Team Lua Script for Deployable Turret
First one gave me the same error, I'll try the second one. And you're trying, thanks for helping out. Edit: Nope, same error every time... wtf is with that...
|
Sun Sep 13, 2009 12:38 am |
|
|
CrazyMLC
Joined: Fri Dec 22, 2006 4:20 am Posts: 4772 Location: Good news everyone!
|
Re: Requesting Team Lua Script for Deployable Turret
Are you coping from the post? My next best guess is that the spaces are making it angry. >_> Delete all the spaces, it won't look pretty but it should still work.
|
Sun Sep 13, 2009 12:43 am |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
Re: Requesting Team Lua Script for Deployable Turret
function Update(self)
not function Update()
function Update() would be trying to define a function called update
but the create self is already ended
|
Sun Sep 13, 2009 12:58 am |
|
|
CombatMedic02
Joined: Wed Dec 17, 2008 11:35 am Posts: 122 Location: London
|
Re: Requesting Team Lua Script for Deployable Turret
Aha! Got it! Code: function Create(self) 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 < 100 then self.Team = actor.Team; end end end Doesn't work with spaces but otherwise it seems to be working now! Thank you for all your help gentlemen! I have to work on it's armour, how it breaks away and such now. At the moment it is a block with a gun. A good looking block with a gun. It runs on a core of plasma so I'm going to make it so you expose the core then it looses health and explodes. On to my second question. This is for bonus points. Can I make it make it controllable? It has a hover effect and stuff... needs adjusting but I wanted to get it working then I can make it look pretty. Also quick gif is quick.
Last edited by CombatMedic02 on Sun Sep 13, 2009 2:17 am, edited 2 times in total.
|
Sun Sep 13, 2009 1:08 am |
|
|
Mind
Joined: Thu Mar 06, 2008 10:54 pm Posts: 1360 Location: USA
|
Re: Requesting Team Lua Script for Deployable Turret
Well, you would have to make it some type of actor to make it truly controllable. (i.e. ACraft, ACDropship, AHuman, ACrab). So, unless you do that, I don't think it will be able to be controlled
But I thought you said that it is an ACrab, so I'd imagine, you should be able to control it. :/
|
Sun Sep 13, 2009 1:50 am |
|
|
CombatMedic02
Joined: Wed Dec 17, 2008 11:35 am Posts: 122 Location: London
|
Re: Requesting Team Lua Script for Deployable Turret
Tis ACrab... But to deploy it I've have to make it a particle. So I can put into a round>magazine>firearm etc etc. I just wondered if there was anyway of re-gaining control of it. Just an extra I wanted to do, it's perfectly capable of holding its own if I can’t make it controllable. CombatMedic02 wrote: 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
|
Sun Sep 13, 2009 1:58 am |
|
|
Mind
Joined: Thu Mar 06, 2008 10:54 pm Posts: 1360 Location: USA
|
Re: Requesting Team Lua Script for Deployable Turret
Red2.lua Code: function Create(self) myself = CreateACrab("Turret2") myself.Pos = self.Pos myself.Vel = self.Vel MovableMan:AddParticle(myself); end
function Update(self) myself.Pos = self.Pos myself.Vel = self.Vel self.ToDelete = true; end Code: AddActor = ACrab CopyOf = Dep Turret InstanceName = Turret2 ScriptPath = DepTurret.rte/Actors/MiniDepTurret/Red2.lua Buyable = 0 Ok well I guess this should work. But save/copypaste your current folder to the desktop un case this doesn't work. Ok 1.) Make a new lua file called "Red2.lua" 2.)Put the code i gave you in Red.lua and put the other lua file you have in Red2.lua 3.)Add the .ini code I gave you somewhere in uh the ini. Hope it works.
|
Sun Sep 13, 2009 2:31 am |
|
|
|