View unanswered posts | View active topics It is currently Sat Dec 28, 2024 3:29 pm



Reply to topic  [ 12 posts ] 
 Need the help of the lua gods! 
Author Message
User avatar

Joined: Wed Jul 06, 2011 5:11 pm
Posts: 226
Reply with quote
Post 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
Profile
User avatar

Joined: Sat Oct 09, 2010 10:01 am
Posts: 303
Location: Afrique d' Sud
Reply with quote
Post 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
Profile YIM WWW
User avatar

Joined: Wed Jul 06, 2011 5:11 pm
Posts: 226
Reply with quote
Post 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
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Tue May 25, 2010 8:27 pm
Posts: 4521
Location: Constant motion
Reply with quote
Post 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
Profile
User avatar

Joined: Wed Jul 06, 2011 5:11 pm
Posts: 226
Reply with quote
Post Re: Need the help of the lua gods!
What would a script like that look like? I can't code in lua. :oops:


Fri Jan 13, 2012 1:17 am
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Tue May 25, 2010 8:27 pm
Posts: 4521
Location: Constant motion
Reply with quote
Post 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
Profile
User avatar

Joined: Wed Jul 06, 2011 5:11 pm
Posts: 226
Reply with quote
Post 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
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Tue May 25, 2010 8:27 pm
Posts: 4521
Location: Constant motion
Reply with quote
Post 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
Profile
User avatar

Joined: Wed Jul 06, 2011 5:11 pm
Posts: 226
Reply with quote
Post 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
Profile

Joined: Mon Aug 22, 2011 3:12 am
Posts: 102
Reply with quote
Post 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
Profile

Joined: Sat Dec 04, 2010 4:48 am
Posts: 13
Reply with quote
Post 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
Profile
User avatar

Joined: Wed Jul 06, 2011 5:11 pm
Posts: 226
Reply with quote
Post 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
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 12 posts ] 

Who is online

Users browsing this forum: Google [Bot]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.038s | 15 Queries | GZIP : Off ]