View unanswered posts | View active topics It is currently Fri Jan 10, 2025 11:53 am



Reply to topic  [ 26 posts ]  Go to page 1, 2  Next
 Jeep - Need Lua help; Advanced module provided. 
Author Message

Joined: Sat Jan 13, 2007 11:04 pm
Posts: 2932
Reply with quote
Post Jeep - Need Lua help; Advanced module provided.
Jeep

I've made sprites, a ready module, full normal code and it works
and loads in CC and you can buy it ingame under actors.

Image

It has everything except one thing: Ability to drive.
And I need a Lua specialist for that.


Attachment:
File comment: Jeep. Everything else is DONE.
Just do the Lua as I described on OP.

Jeep v0.4.rar [20.95 KiB]
Downloaded 276 times


What I want the Jeep to do, Read carefully.:
-Able to drive on terrain and accelerate while on the ground on its wheels.
-Have the acceleration be stopped by friction and or air resistance or brakes. NOT by itself.
-Able to keep momentum so you can drive of a ramp and it will continue flying even if you release the throttle and NOT stop in midair.
-Able to scale slopes and adjust its rotations based on the angle of the surface.
-Able to accelerate better/worse when driving up a hill or down from it.
-Brakes that will only work if youre on the ground. NO AIRBRAKES.
-Nitro boost that will give a sudden boost of acceleration to the jeep that basically multiplies the acceleration rate by 3-5 times of normal for 1-2 seconds.
-Nitro boost can be used any time, but after usage it must recharge for 3 seconds.

Remember, everything else is READY. Sprites, normal code and the module.
All I need is the Lua part. There is also a Lua template with some basic stuff so check it out.


====================
FYI, I am making this topic because mail2345's humvee's driving Lua code fails badly
and it drives totally not like what I wanted and its rather buggy aswell overall.
The sprites were made by me, 100% from scratch and the base code aswell.

I allowed mail2345 to use the sprites and the whole mod for exchange for a working Lua code.

NOTE: This is not the same module from Lua scripting. It is MUCH more better and
updated and the jeep is now an AHuman.
So you dont need to worry about rotation.
====================


Thank you.


Last edited by numgun on Mon Jun 29, 2009 1:20 am, edited 1 time in total.



Wed Jun 24, 2009 12:28 am
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Jeep - Need LUA help; Advanced module provided.
I'm suprised no one has yelled about the capitalization of Lua.

Just a tip for Lua coders, to figure out the angle of the vehicle, subtract the positions of the two wheels ideal location after elevation, and set the angle of the vehicle to the angle of the vector.


Wed Jun 24, 2009 1:12 am
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Jeep - Need LUA help; Advanced module provided.
numgun wrote:
-Able to drive on terrain and accelerate while on the ground on its wheels.
-Have the acceleration be stopped by friction and or air resistance or brakes. NOT by itself.
-Able to keep momentum so you can drive of a ramp and it will continue flying even if you release the throttle and NOT stop in midair.
-Able to scale slopes and adjust its rotations based on the angle of the surface.
-Able to accelerate better/worse when driving up a hill or down from it.
-Brakes that will only work if youre on the ground. NO AIRBRAKES.
-Nitro boost that will give a sudden boost of acceleration to the jeep that basically multiplies the acceleration rate by 3-5 times of normal for 1-2 seconds.
-Nitro boost can be used any time, but after usage it must recharge for 3 seconds.

Notes on difficulty and practicality via modifying my code:
1,2,3- Moving the acceration code inside an if block that checks for a maxinum height will do the trick.
4. Can be extracted from my code, but tweaking is needed.
5. Is already in my code.
6. Will result as doing 1,2,3
7,8 - Easy. Just add a timer that is checked to multiply acc and is reset by nitro mode. Recharge is also easy, just have nitro reset the timer and nitro only activates when the timer is past.
Fixing the suspension bug via emulating attachables - Trig knowledge mandatory, ability to understand psedo-offsets needed.


Wed Jun 24, 2009 2:25 am
Profile
Moderator Hero

Joined: Sun Dec 24, 2006 11:28 pm
Posts: 868
Location: London Server
Reply with quote
Post Re: Jeep - Need LUA help; Advanced module provided.
How about if you don't want to help him you don't post? I know everybody and their mother hates Numgun, but really, you're just giving me more posts to junk.


Wed Jun 24, 2009 11:39 am
Profile
User avatar

Joined: Mon May 18, 2009 11:48 pm
Posts: 205
Location: The swamps of Stuporia!
Reply with quote
Post Re: Jeep - Need LUA help; Advanced module provided.
striker121 wrote:
....That made me laugh, seriously. This is what actually makes me spell it with capitols, people freak out so much. Well done post though. Anyway, I think the current jeep is awesome, but true, it doesn't really work like I'd imagine you'd want it to.
EDIT: WHAT IS THE BIG DEAL? I've never seen people get so annoyed about ANY WORD being miss-spelled like Lua.

YOU MISSPELLED 'MISSPELLED'! RAAARGH THAT MAKS ME MAD.

I'm kinda curious why everyone gets in a snit about it, too. I actually met someone who pronounced it like it's an acronym, too. He called it L-U-A. Haha... I had to think for a moment when I heard it.

Does anyone think the jeep should have some kind of turret on it, to help with defense versus guns? Running people over is swell and all, but when they're shooting back those hits will add up quick if they see you fast enough.


Wed Jun 24, 2009 1:13 pm
Profile YIM
User avatar

Joined: Fri May 11, 2007 4:30 pm
Posts: 1040
Location: England
Reply with quote
Post Re: Jeep - Need LUA help; Advanced module provided.
if I could be arsed I would give it a try but I can't. I think you should just wait until someone actually has the urge to do it themselves.

I assume you want people to make the lua file so that you can post it in mod releases, you will get 90% of the attention and praise, for doing the least important work, whereas the people who do the most important piece will only be credited.

also you could check if any actors are near the boot and pin them in the back of the truck, they will automatically shoot any enemies themselves. but ye sprite is not suited for carrying actors


Wed Jun 24, 2009 5:04 pm
Profile
User avatar

Joined: Mon Jul 16, 2007 9:50 am
Posts: 1512
Location: Tallahassee, FL
Reply with quote
Post Re: Jeep - Need LUA help; Advanced module provided.
Problem with friction: you can't really get materials or their attributes with Lua right now. Otherwise you could just determine the friction of the material that the wheels are setting on. My suggestion for now would be to just have a default friction, held internally within the jeep's script.

Applying breaks would just increase this friction.


Wed Jun 24, 2009 5:17 pm
Profile YIM

Joined: Sat Jan 13, 2007 11:04 pm
Posts: 2932
Reply with quote
Post Re: Jeep - Need LUA help; Advanced module provided.
AgentBaron wrote:
Does anyone think the jeep should have some kind of turret on it, to help with defense versus guns? Running people over is swell and all, but when they're shooting back those hits will add up quick if they see you fast enough.


I changed the base code to an AHuman. That means it can carry and wield guns like a normal soldier. A custom gun and a good place where the gun will be mounted and youre good to go.

That will be later though, the point is to make it drive.
Gibs, guns, custom wounds and any other extra stuff will come later. And they will.


Darlos9D wrote:
Problem with friction: you can't really get materials or their attributes with Lua right now. Otherwise you could just determine the friction of the material that the wheels are setting on. My suggestion for now would be to just have a default friction, held internally within the jeep's script.

Applying breaks would just increase this friction.


I never really thought of basing the driving/acceleration/decelration on terrain material frictions at all. I mostly just pretend its a solid surface or its air.
It will make it easier to code and more simple. Mainly the deceleration and braking will activate when the jeep is on the ground on its wheels and then if thats true, it will sort of auto-slow down at a slow rate. If you want to stop, then use the brakes, otherwise you can pretty much accelerate a bit and let the momentum carry it like real cars. And then you can either let it stop by itself after some time or do it immediatly by braking.


@robolee: Consider it as a template for everyone and anyone.
If this is pulled off, you can be the first to create a bike or a monster truck.


Wed Jun 24, 2009 7:31 pm
Profile
User avatar

Joined: Mon Apr 13, 2009 12:27 pm
Posts: 813
Location: Yogyakarta, Indonesia. A slice o' paradise.
Reply with quote
Post Re: Jeep - Need LUA help; Advanced module provided.
I have an idea... since it's an AHuman now that means it can HFlip right? So to put it in reverse, make it so a key toggles reverse gear and stuff... maybe press 1 to keep driving in reverse, and press 1 again to drive forward... yeah. This could be the start of a gear system, where 1 toggles reverse/neutral/1st gear, 2 - whatever be the next gears (make it so they're active only when reverse is not on)...


Thu Jun 25, 2009 4:08 am
Profile YIM WWW

Joined: Sat Jan 13, 2007 11:04 pm
Posts: 2932
Reply with quote
Post Re: Jeep - Need LUA help; Advanced module provided.
carriontrooper wrote:
I have an idea... since it's an AHuman now that means it can HFlip right? So to put it in reverse, make it so a key toggles reverse gear and stuff... maybe press 1 to keep driving in reverse, and press 1 again to drive forward... yeah. This could be the start of a gear system, where 1 toggles reverse/neutral/1st gear, 2 - whatever be the next gears (make it so they're active only when reverse is not on)...


I suppose if you want extra layer of complexity theres nothing wrong with that, but it would be certainly easier to code a single acceleration type that would work universally.

The thing is that CC's driving distances are usually going to be very small no matter how big your map will be and messing with the gears while youre trying to race with someone or trying to escape from enemy fire can get a little tedious.

Btw I'm got inspired to start a VTOL Fighter project after watching a few episodes of Swat kats. :P
Might do a similar topic with all the stuff ready like here soonish.
I also have a cool idea how it would work while remaining a VTOL ship and keeping the normal flying seemlessly. Something like the fighters from AirPower v3.2 mod by Monarch. That guy is amazing.
Also from a game called Angels20. It had some good flying mechanics.


Thu Jun 25, 2009 11:56 pm
Profile
User avatar

Joined: Mon Apr 13, 2009 12:27 pm
Posts: 813
Location: Yogyakarta, Indonesia. A slice o' paradise.
Reply with quote
Post Re: Jeep - Need LUA help; Advanced module provided.
Just implement the reverse toggler. The gear stuff is just for additional brain feed. But the reverse toggler is a must...


Fri Jun 26, 2009 3:24 am
Profile YIM WWW
Banned
User avatar

Joined: Tue Feb 27, 2007 4:05 pm
Posts: 2527
Reply with quote
Post Re: Jeep - Need LUA help; Advanced module provided.
numgun wrote:
Btw I'm got inspired to start a VTOL Fighter project after watching a few episodes of Swat kats. :P
Great, gank someone's idea again. I should start writing these down for reference.


Fri Jun 26, 2009 3:55 am
Profile YIM
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Jeep - Need LUA help; Advanced module provided.
I can't fix the suspension code or HFlipped issues.
Though, here are a bit more details, as I happen to have some other projects to work on at the moment:
leftalt and rightalt are useful variables. Check if they are less than something to enables brakes and acceleration.
This is the acceration code, moveing it into an if block should do the trick, kinda a mock up modif:
Code:
if leftalt < something and rightalt < something then
if self:GetController():IsState(Controller.HOLD_LEFT) then --Move left
--self.Vel.X = self.Vel.X - 0.5;
self.throttle = self.throttle - 0.5
--self.HFlipped = true; --Buggy.
elseif self:GetController():IsState(Controller.HOLD_RIGHT) then --Move right
--self.Vel.X = self.Vel.X + self.boost;
self.throttle = self.throttle + self.boost
--self.HFlipped = false;
elseif  self:GetController():IsState(Controller.HOLD_DOWN) then--Slow doen with brakes
self.throttle = self.throttle / 1.2;
if math.abs(self.throttle) < 2 then
self.throttle = 0;
end
else -- Land braking
self.throttle = self.throttle / 1.05
end
end

Finally, nitro is something like:
Code:
if not(nitro(IsPastSimMS(nitrotime)) then
self.thorttle

This goes infront of acc for nitro.
Code:
if not(nitrotimer:IsPastSimMS(nitroruntime)) then
self.boost = 1
else
self.boost = 0.5
end
if nitropresstimer:IsPastSimMS(nitrorun) and self:GetController():IsState(Controller.MOVE_UP) then
nitropresstimer:Reset()
nitrotimer:Reset()
end


Fri Jun 26, 2009 10:23 pm
Profile

Joined: Sat Jan 13, 2007 11:04 pm
Posts: 2932
Reply with quote
Post Re: Jeep - Need LUA help; Advanced module provided.
Thanks, I've started to write a plan on paper to figure out how the code would work so I can try building the script myself. Any explanation how your code works is great help.

Although one thing I dont get:

Quote:
HFlipped issues.


What do you mean by that?

This is no longer an Actor, but an AHuman that has the changing direction hardcoded.
Besides, an AHuman provides the ability to mount a weapon(s) and other systems like jetpacks.


Fri Jun 26, 2009 11:24 pm
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Jeep - Need LUA help; Advanced module provided.
Still has issues, loading my Lua into the Humvee results in it flipping upside down.
EDIT:
My code works by mesuinrg the altitude of the wheels, calculating an ideal locating for the wheels and then elevating the vehicle, followed by rotating the vehicle to the angle of the distance vector of the wheels.


Fri Jun 26, 2009 11:41 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 26 posts ]  Go to page 1, 2  Next

Who is online

Users browsing this forum: No registered users


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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.053s | 15 Queries | GZIP : Off ]