Author |
Message |
Pantera1993
Joined: Wed Jul 06, 2011 5:11 pm Posts: 226
|
Need the help of the lua gods!
I need a script that will hold a drop-ship a certain amount of pixels above the terrain. So if the terrain goes up, the craft goes up and the other way around. Maybe if it holds each engine above the terrain individually so if there's an incline the first side to hit it goes up, then the other side.
I'm not too sure if this is clear enough so if more information is needed ask me. Also, I very much appreciate any help that is given.
|
Thu Jan 12, 2012 3:30 am |
|
|
trystanr
Joined: Sat Oct 09, 2010 10:01 am Posts: 303 Location: Afrique d' Sud
|
Re: Need the help of the lua gods!
I'm not entirely sure what it is that you want. From that, I understood to make it so that crafts are impossible to touch the ground?
|
Thu Jan 12, 2012 10:42 am |
|
|
Pantera1993
Joined: Wed Jul 06, 2011 5:11 pm Posts: 226
|
Re: Need the help of the lua gods!
Yeah, just to stay at a certain level right above the ground, like hovering just a few pixels above the ground.
|
Thu Jan 12, 2012 8:41 pm |
|
|
Roast Veg
Data Realms Elite
Joined: Tue May 25, 2010 8:27 pm Posts: 4521 Location: Constant motion
|
Re: Need the help of the lua gods!
You need to cast a ray to the closest piece of terrain, and make sure your Y position is however much above that.
|
Fri Jan 13, 2012 12:08 am |
|
|
Pantera1993
Joined: Wed Jul 06, 2011 5:11 pm Posts: 226
|
Re: Need the help of the lua gods!
What would a script like that look like? I can't code in lua.
|
Fri Jan 13, 2012 1:17 am |
|
|
Roast Veg
Data Realms Elite
Joined: Tue May 25, 2010 8:27 pm Posts: 4521 Location: Constant motion
|
Re: Need the help of the lua gods!
Actually there's a better way to do that, MORays are a little more complicated than: Code: function Create(self) self.MaxHover = 15; --The maximum height above terrain the object will fly. self.MinHover = 10; --The minimum height it will fly. end
function Update(self) self.Altitude = SceneMan:FindAltitude(self.Pos, 0, 2); if self.Altitude <= self.MaxHover then if self.Vel.Y = self.Vel.Y + 1; elseif self.Altitude >= self.MinHover then self.Vel.Y = self.Vel.Y -1; end end Pretty sure that should be bug free.
|
Fri Jan 13, 2012 6:30 pm |
|
|
Pantera1993
Joined: Wed Jul 06, 2011 5:11 pm Posts: 226
|
Re: Need the help of the lua gods!
Thanks for the code Roast! Code: ERROR: Drop Ship Template.rte/hover.lua:9: 'then' expected near '=' Been attempting to fix this, but with no success... EDIT: Alright so, this seems to work well, perfectly actually.... Code: function Create(self) self.MaxHover = 4; --The maximum height above terrain the object will fly. self.MinHover = 1; --The minimum height it will fly. end
function Update(self) self.Altitude = SceneMan:FindAltitude(self.Pos, 0, 2); if self.Altitude < self.MaxHover then self.Vel.Y = self.Vel.Y + 1; elseif self.Altitude > self.MinHover then self.Vel.Y = self.Vel.Y -1; end end ...but only when the AI is in control of the ship.
|
Fri Jan 13, 2012 8:37 pm |
|
|
Roast Veg
Data Realms Elite
Joined: Tue May 25, 2010 8:27 pm Posts: 4521 Location: Constant motion
|
Re: Need the help of the lua gods!
Oh yeah that was crap copypasta by me there, sorry.
I can't explain why the code doesn't work without AI, it should all be the same.
|
Sun Jan 15, 2012 8:15 pm |
|
|
Pantera1993
Joined: Wed Jul 06, 2011 5:11 pm Posts: 226
|
Re: Need the help of the lua gods!
I've run into another problem. The ship's altitude doesn't adjust according to the min/max hover variables. It just chooses an altitude and stays there no matter what the variables are telling it to do.
|
Sun Jan 15, 2012 8:29 pm |
|
|
Skeggy
Joined: Mon Aug 22, 2011 3:12 am Posts: 102
|
Re: Need the help of the lua gods!
I believe there is some sort of tilt hover system in S.A.Ws script if you still need.
|
Sun Feb 12, 2012 11:04 am |
|
|
HoneyFox
Joined: Sat Dec 04, 2010 4:48 am Posts: 13
|
Re: Need the help of the lua gods!
Pantera1993 wrote: I've run into another problem. The ship's altitude doesn't adjust according to the min/max hover variables. It just chooses an altitude and stays there no matter what the variables are telling it to do. check the logic of that script... it seems that there is some problems. if self.Altitude < MaxHover then -- this "<" should be changed to ">" i think... and elseif self.Altitude > MinHover then -- this ">" should be changed to "<" ... in CC, the Pos.Y is bigger when the actual position is lower... it is based on screen coordinate system i think. and i'm not sure how is that Altitude calculated. will it always be a positive number?
|
Sun Feb 12, 2012 4:25 pm |
|
|
Pantera1993
Joined: Wed Jul 06, 2011 5:11 pm Posts: 226
|
Re: Need the help of the lua gods!
I'm pretty sure the altitude is measure in pixels, no?
Anyway, the code ended up working after applying it to the dropship itself instead of the engines.
|
Tue Feb 14, 2012 4:39 am |
|
|
|