Data Realms Fan Forums http://45.55.195.193/ |
|
Raining bombs via grenade http://45.55.195.193/viewtopic.php?f=73&t=21392 |
Page 1 of 1 |
Author: | Asklar [ Sat Feb 05, 2011 2:22 am ] |
Post subject: | Raining bombs via grenade |
I'm trying to create a flare which when destroyed makes bombs fall where it was. The code is not working, so I wanted to ask for help. Code: function Update(self) self.StoreX = self.Pos.X self.RotAngle = 0 self.bombVar = 1 end function Destroy(self) self.bombTime = Timer(); self.bombingTime = Timer(); if self.bombVar == 1 then if self.bombingTime:IsPastSimMS(500) then self.bomb = CreateTDExplosive("Anti-Bunker Bomb"); self.bomb:Activate() MovableMan:AddItem(self.bomb); self.bomb.Pos = Vector(self.StoreX,-20); self.bombingTime:Reset(); end end if self.bombTime:IsPastSimMS(5000) then self.bombVar = 0 end end I'm not good at lua, but I'm not bad either, but this code is kicking my ass. |
Author: | akblabla [ Sat Feb 05, 2011 10:55 am ] |
Post subject: | Re: Raining bombs via grenade |
Destroy self only runs once, so it can't spawn bombs after a couple of secs. The way you want to do is by making a new object with the bomb spawning script which you spawn when the flare is destroyed. Hope it helps. |
Author: | Dylanhutch [ Sat Feb 05, 2011 11:24 am ] |
Post subject: | Re: Raining bombs via grenade |
Asklar wrote: I'm trying to create a flare which when destroyed makes bombs fall where it was. The code is not working, so I wanted to ask for help. *Code* I'm not good at lua, but I'm not bad either, but this code is kicking my ass. Code: function Update(self) self.StoreX = self.Pos.X self.RotAngle = 0 self.bombVar = 1 if self.bombVar == 1 then if self.bombingTime:IsPastSimMS(500) then self.bomb = CreateTDExplosive("Anti-Bunker Bomb"); self.bomb:Activate() MovableMan:AddItem(self.bomb); self.bomb.Pos = Vector(self.StoreX,-20); self.bombingTime:Reset(); end end if self.bombTime:IsPastSimMS(5000) then self.bombVar = 0 end end function Destroy(self) self.bombTime = Timer(); self.bombingTime = Timer(); end ? |
Author: | Abdul Alhazred [ Sat Feb 05, 2011 2:58 pm ] |
Post subject: | Re: Raining bombs via grenade |
I recommend spawning an object with the grenade that in turn spawn the bombs. This code is attached to the grenade: Code: function Update(self) if self.ToDelete then local BombSpawn = CreateMOPixel("Bomb Spawn", "ModName.rte") BombSpawn.Pos = Vector(self.Pos.X, -50) MovableMan:AddParticle(BombSpawn) end end This to a MOPixel with GlobalAccScalar = 0 called "Bomb Spawn": Code: function Create(self) self.SpawnTime = Timer() end function Update(self) if self.SpawnTime:IsPastSimMS(500) then self.SpawnTime:Reset() local Bomb = CreateTDExplosive("Anti-Bunker Bomb", "ModName.rte") Bomb.Pos = self.Pos + Vector(RangeRand(-50, 50), 0) Bomb:Activate() MovableMan:AddParticle(Bomb) end end The number of bombs dropped is regulated by the MOPixel's life time. Note that this code has not been tested. |
Author: | 411570N3 [ Sat Feb 05, 2011 3:18 pm ] |
Post subject: | Re: Raining bombs via grenade |
Abdul Alhazred wrote: Note that this code has not been tested. |
Author: | Asklar [ Sat Feb 05, 2011 10:10 pm ] |
Post subject: | Re: Raining bombs via grenade |
Abdul Alhazred wrote: I recommend spawning an object with the grenade that in turn spawn the bombs. This code is attached to the grenade: Code: function Update(self) if self.ToDelete then local BombSpawn = CreateMOPixel("Bomb Spawn", "ModName.rte") BombSpawn.Pos = Vector(self.Pos.X, -50) MovableMan:AddParticle(BombSpawn) end end This to a MOPixel with GlobalAccScalar = 0 called "Bomb Spawn": Code: function Create(self) self.SpawnTime = Timer() end function Update(self) if self.SpawnTime:IsPastSimMS(500) then self.SpawnTime:Reset() local Bomb = CreateTDExplosive("Anti-Bunker Bomb", "ModName.rte") Bomb.Pos = self.Pos + Vector(RangeRand(-50, 50), 0) Bomb:Activate() MovableMan:AddParticle(Bomb) end end The number of bombs dropped is regulated by the MOPixel's life time. Note that this code has not been tested. And if instead of using 2 codes, I just use the second and attach it to a MOPixel gib with PinStrength = 9999? EDIT: Alright, what I said worked. I attached it to a MOPixel gib with PinStrength = 9999, and it works perfect. |
Author: | Coops [ Sat Feb 05, 2011 10:13 pm ] |
Post subject: | Re: Raining bombs via grenade |
We already went over this before. Its a different way of making them spawn, but same concept. viewtopic.php?f=73&t=20848 |
Author: | Asklar [ Sat Feb 05, 2011 10:18 pm ] |
Post subject: | Re: Raining bombs via grenade |
I know that, I saw that post before like any responsible forum user when I was searching on how to do it. That's why I made the new post. |
Author: | Asklar [ Sat Feb 05, 2011 10:47 pm ] |
Post subject: | Re: Raining bombs via grenade |
That would have been epic, but you know, modding everytime gets more complex and more sophisticated (if the word exists, and if I wrote it ok), so learning lua is really important right now. |
Author: | Asklar [ Sun Feb 06, 2011 2:50 am ] |
Post subject: | Re: Raining bombs via grenade |
Dude, I love metaphors. Yeah, you are right, I'm making an entire faction using as less lua as I can because: 1) I don't know much 2) Lua-filled mods sometimes make the game way to easy. |
Author: | mail2345 [ Sun Feb 06, 2011 3:09 am ] |
Post subject: | Re: Raining bombs via grenade |
However, don't forget that at Lua can be better even if ini can work. Take for an example an acid bath, which I have still yet to make. To do it in ini would require an emitter spawning a boatload of particles, which is very laggy(and crashy). However, with Lua, I can do it with much less lag. It's still good to know the ini way in those instances. |
Author: | Asklar [ Sun Feb 06, 2011 4:35 am ] |
Post subject: | Re: Raining bombs via grenade |
Ini is the basic way to mod complex things. Lua is the complex way to mod simple things ini's can't do (making a rocket gib in midair can only be done with luas and it's something quite simple, that is enough proof). |
Author: | none [ Sun Feb 06, 2011 8:01 pm ] |
Post subject: | Re: Raining bombs via grenade |
Learn to sail on a lake first then on the sea you have less chance of crashing once you know how to sail?? |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |