Home   Help Search Login Register  

Author Topic: Moving forward script?  (Read 1714 times)

0 Members and 1 Guest are viewing this topic.

Offline danturn

  • Members
  • *
Moving forward script?
« on: 20 Feb 2009, 13:12:45 »
Obviously in a vehicle you have to use W or an assigned key and press and hold it to move forward.
However in a boat or ship it gets quite tedious as there may not be much movement if you are travelling right around the coast of an island.

With aircraft, you can obviously use the throttle lever on a joystick to give different levels of movement.

Is it possible to use a script that will be activated by an addaction to 'activate' the forward movement at 100% of its power so that you dont have to hold the W key. Also a script to stop the forward power, and maybe one to give just 20-25% of the ships power so you can use it for going up rivers or ports and negotiate the boat better.

Thanks for any help.

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: Moving forward script?
« Reply #1 on: 20 Feb 2009, 14:40:30 »
What I do is use a penny for those long travels. I wedge it in between the 'e' and 's'. Its not scripted its manual but it works :D
Xbox Rocks

Offline danturn

  • Members
  • *
Re: Moving forward script?
« Reply #2 on: 20 Feb 2009, 16:58:58 »
Haha, excellent idea, one i may use just until i can get a direction to head with this script.  :good:

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Moving forward script?
« Reply #3 on: 20 Feb 2009, 17:34:34 »
I love Hoz's idea.  I put a brick on my gas pedal when I drive across Nevada...  ;)

A simple loop using setVelocity should work.

Code: [Select]
_vehicle = this select 0;

// Get current velocity of vehicle
_vel = velocity _vehicle;

CruiseControl = true;

// Loop until global variable CruiseControl is set to false.
while {CruiseControl and alive _vehicle} do
{
  _vehicle setvelocity _vel;
  sleep 1;
};

The above is untested, but is probably close to a working solution.  You would need an addaction to call the script.  The vehicle would then maintain the current speed until the global CruiseControl variable was set to false.  You could set it to false via another addAction.

The above would need more work to have it work for more than one vehicle.  You could create a global variable array that contained a list of vehicles for which CruiseControl was active.  And delete the vehicle from the list when CruiseControl inactive.

Anyway, lots of ways to do this...

Have fun!
« Last Edit: 20 Feb 2009, 17:36:09 by johnnyboy »
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Moving forward script?
« Reply #4 on: 20 Feb 2009, 17:44:13 »
Problem with that script is when you want to turn ;) Then your turn velocity will still be the same as your original one - so if cruise control has been set while flipping upside-down at 100 mph, then that's what the script will try to emulate :D

How about this (untested):

Code: [Select]
_speed = 70;
while {cruisecontrol and alive _vehicle} do
{
_vel = velocity _vehicle;
_vehicle setVelocity [(_vel select 0)+(sin _dir*_speed),(_vel select 1)+ (cos _dir*_speed),(_vel select 2) - 1];
sleep 1;
};

Note: this might also propel the vehicle to supersonic speed within a few seconds  :cool2: That's what experimentation is for! (_speed = speed of vehicle).

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline schuler

  • Contributing Member
  • **
Re: Moving forward script?
« Reply #5 on: 20 Feb 2009, 17:49:50 »
what about joy sticks, do they work with the thrust slide pad? i havent use it in years but it waz top of the line then ?!?!?!?
@hoz you got change for 5 cents AU? we ran out of penny's years ago. and the 2 cent piece wont work and its hard to get a hold of, because it went out years ago too! (every thing is rounded of to the 5 cent piece)
what country are you guys from hehe? :P
you scripters think of every thing and i mean every thing  :scratch:  ;) 
Semper Fi

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: Moving forward script?
« Reply #6 on: 20 Feb 2009, 17:56:33 »
Maybe you can reuse some code from Mando Move.
try { return true; } finally { return false; }

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Moving forward script?
« Reply #7 on: 20 Feb 2009, 20:24:16 »
Mando Move would be a good choice.  In the loop you could continually move the marker that the you are moving toward ahead some distance.  MandoMove would handle reduced speed for turning, flipovers, etc.
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline danturn

  • Members
  • *
Re: Moving forward script?
« Reply #8 on: 21 Feb 2009, 13:37:26 »
All sound like good ideas, I shall give them a try later on today, Thanks.