Alexander Knoll
NEVER GIVE UP!!
THX Stereo, works verry well!
I got with the lambo @30 km/h 7,7m.....hmm....
I got with the lambo @30 km/h 7,7m.....hmm....
rcar $car = get scriptowner car
float $maxspeed = 180.0
float $curspeed = 0.0
float $unthrottle = 1.0
float $throttle = 0.0
float $throttlerate = 0.001 // 100% unthrottle in 1 second is 0.001, 50%/sec is 0.0005 etc.
float $unitconv = 3600.0/1000.0 // tacho reads in m/s, this converts to km/h
while 1
{
$curspeed = (get $car tachovelocity)*$unitconv
$throttle = get $car throttle
if $curspeed > $maxspeed
{
$unthrottle = $unthrottle - $throttlerate
}
else if $unthrottle < 1.0
{
$unthrottle = $unthrottle + $throttlerate
}
set $car throttle $throttle*$unthrottle
interrupt
}
rcar $car = get scriptowner car
float $maxspeed = 180.0
float $curspeed = 0.0
float $unthrottle = 1.0
float $throttle = 0.0
float $throttlerate = 100 // lock up throttle for this many ms (ie. 1000 = 1 second)
float $unitconv = 3600.0/1000.0 // tacho reads in m/s, this converts to km/h
while 1
{
$curspeed = (get $car tachovelocity)*$unitconv
$throttle = get $car throttle
if $curspeed > $maxspeed
{
if $unthrottle < 100
{
$unthrottle = $throttlerate
}
}
if $unthrottle > 0
{
$unthrottle = $unthrottle - 1
set $car throttle 0
}
interrupt
}
Well, I've never driven a car with a speed limiter at the limited top speed so I don't know exactly how it actually performs.They are kinda how I would have done it.
I guess in 1st script does it kinda find a balance point where the throttle is around the value needed to sustain that speed...
Might be good to run it once every quarter second perhaps, and so it kicks in over several seconds, which might feel more realistic.
It will be amazing to have car's pitch/roll to make some thing like automatic handbrake, or improve automatic gearbox script.. i hope i'll remember all of my request soonI will take a new fresh look at scripts shortly, since i have been discussing things with Ruud.
Meanwhile, you can give some feature requests concerning scripts, so I can add some new things while im at it.
Bascily, you mean to write an "source code" in .rsx format, (do it with notepad and change the extansion ^^)dont forget my folding mirror request, exhaust smoke (black for diesel trucks and gray smooth for gas cars), and a general command to open all windows, sun roof.. I didnt undestand yet how script works.. I downloaded stereo car and john the lemon car, but I cant see how can I set up the parts.. rsx files I opened with notepad, but how to config rcx files?
open (file) at (string)
Comment:
Open file at location.
write (string) in (file)
Comment:
Write string to file.
sqrt (float)
Returns:
float
Comment:
Returns square root of x.
pow (float) to (float)
Returns:
float
Comment:
Returns the result of x to the power of y.
substring (string) from (int) to (int)
Returns:
string
Comment:
Returns substring of string (1st parameter) from 2nd to 3rd parameter
length (string)
Returns:
int
Comment:
Returns length of given string.
find (string) in (string)
Returns:
int
Comment:
Finds key (2nd parameter) in given string (1st parameter) and returns index.
read (file) line
Returns:
string
Comment:
Read line of file.
flush (file)
Comment:
Flushes file.
abs (float)
Returns:
float
Comment:
Returns abs of x.
acos (float)
Returns:
float
Comment:
Returns acos of x.
asin (float)
Returns:
float
Comment:
Returns asin of x.
atan (float)
Returns:
float
Comment:
Returns atan of x.
atan2 (float[2])
Returns:
float
Comment:
Returns atan2 of x and y.
ceil (float)
Returns:
float
Comment:
Returns ceil of x.
cos (float)
Returns:
float
Comment:
Returns cos of x.
cosh (float)
Returns:
float
Comment:
Returns cosh of x.
exp (float)
Returns:
float
Comment:
Returns exp of x.
fabs (float)
Returns:
float
Comment:
Returns fabs of x.
floor (float)
Returns:
float
Comment:
Returns floor of x.
log (float)
Returns:
float
Comment:
Returns log of x.
log10 (float)
Returns:
float
Comment:
Returns log10 of x.
sin (float)
Returns:
float
Comment:
Returns sin of x.
sinh (float)
Returns:
float
Comment:
Returns sinh of x.
tan (float)
Returns:
float
Comment:
Returns tan of x.
tanh (float)
Returns:
float
Comment:
Returns tanh of x.
get pbody id (int)
Returns:
pbody
Comment:
Returns physics body with given unique ID'
get (pbody) pos
Returns:
float[3]
Comment:
Returns current coordinates of physics-body
get (pbody) rot
Returns:
float[4]
Comment:
Returns current rotation of physics-body
get (pbody) vel
Returns:
float[3]
Comment:
Returns current velocity of physics-body
get (pbody) rotvel
Returns:
float[3]
Comment:
Returns current rotational velocity of physics-body
set (pbody) pos (float[3])
Comment:
Sets position of physics-body
set (pbody) rot (float[4])
Comment:
Sets rotation of physics-body
set (pbody) vel (float[3])
Comment:
Sets velocity of physics-body
set (pbody) rotvel (float[3])
Comment:
Sets rotational velocity of physics-body
remove joint (pbody)
Comment:
Removes associated joint
add (pbody) bodyforce (float[3]) at (float[3])
Comment:
Adds bodyforce of physics-body at body position
add (pbody) bodyforce (float[3]) at cg
Comment:
Adds bodyforce of physics-body at cg
add (pbody) bodytorque (float[3])
Comment:
Adds bodytorque of physics-body
add (pbody) worldforce (float[3]) at (float[3])
Comment:
Adds worldforce of physics-body at body position
add (pbody) bodyforce (float[3]) at cg
Comment:
Adds worldforce of physics-body at cg
add (pbody) worldtorque (float[3])
Comment:
Adds worldtorque of physics-body
set (pbody) jointlimit (float[2])
Comment:
Set limits of joints (Radians).
create joint (pbody) with parent (pbody) with offset (float[3])
Comment:
Creates joint between 2 given physics bodys. joint offset is relative to child.
get (pbody) has joint
Returns:
int
Comment:
Does this physics body have a joint?.
get (pbody) joint parent id
Returns:
int
Comment:
Receive physics body ID of parent joint.
get (pbody) freeze
Returns:
int
Comment:
Get if body is frozen.
set (pbody) freeze (int)
Comment:
Set if body is frozen.
set (pbody) jointdir (float[3])
Comment:
Set direction of joints (normalized).
get local car
Returns:
rcar
Comment:
Returns the local car.
get carcount
Returns:
int
Comment:
Returns total carcount.
get car (int)
Returns:
rcar
Comment:
Returns car by given index.
get scriptowner car
Returns:
rcar
Comment:
Returns the car that owns this script.
get (rcar) pos
Returns:
float[3]
Comment:
Returns position for given car.
get (rcar) rot
Returns:
float[4]
Comment:
Returns rotation for given car.
get (rcar) velocity
Returns:
float[3]
Comment:
Returns velocity for given car.
get (rcar) rotvelocity
Returns:
float[4]
Comment:
Returns rotvelocity for given car.
get (rcar) rpm
Returns:
float
Comment:
Returns RPM for given car.
get (rcar) tachovelocity
Returns:
float
Comment:
Returns tacho velocity for given car. in KM/H.
get (rcar) gear
Returns:
int
Comment:
Returns current gear for given car. 0=Neutral, 1=Reverse, 2=1st,...
get (rcar) tc enabled
Returns:
int
Comment:
Returns if traction control is enabled for given car.
get (rcar) asl enabled
Returns:
int
Comment:
Returns if asl is enabled for given car.
get (rcar) abs enabled
Returns:
int
Comment:
Returns if abs is enabled for given car.
set (rcar) tc (int)
Comment:
Set traction control for given car (0 or 1).
set (rcar) asl (int)
Comment:
Set asl for given car (0 or 1).
set (rcar) abs (int)
Comment:
Set abs for given car (0 or 1).
get (rcar) tc active
Returns:
int
Comment:
Returns if traction control is active for given car.
get (rcar) asl active
Returns:
int
Comment:
Returns if asl is active for given car.
get (rcar) abs active
Returns:
int
Comment:
Returns if abs is active for given car.
get (rcar) throttle
Returns:
float
Comment:
Get Throttle for given car (0 -> 1).
set (rcar) throttle (float)
Comment:
Set Throttle for given car (0 -> 1).
get (rcar) brake
Returns:
float
Comment:
Get brake for given car (0 -> 1).
set (rcar) brake (float)
Comment:
Set brake for given car (0 -> 1).
get (rcar) clutch
Returns:
float
Comment:
Get clutch for given car (0 -> 1).
get (rcar) steerangle
Returns:
float
Comment:
Get steerangle for given car (radians).
get (rcar) max steerangle
Returns:
float
Comment:
Get msx steerangle for given car (radians).
get generic model (int) of (rcar)
Returns:
rcarmodel
Comment:
Get generic model of car.
set (rcarmodel) position (float[3])
Comment:
Set generic model position offset.
set (rcarmodel) rotation (float[3])
Comment:
Set generic model rotation offset in radians.
set (rcarmodel) scriptcontrolled (int)
Comment:
Set if this model is controlled by the script (pos/rot).
get (rcar) drivername
Returns:
string
Comment:
Get drivername of car.
get (rcar) bestlap
Returns:
int
Comment:
Get best laptime in milliseconds.
get (rcar) id
Returns:
int
Comment:
Get ID of car, these ID's are reliable over network, so use this to address cars over network.
get car by id (int)
Returns:
rcar
Comment:
Get car by ID, these ID's are reliable over network, so use this to address cars over network.
get (rcar) pbody id
Returns:
int
Comment:
Get car physics body ID.
get (rcar) maxtorque factor
Returns:
float
Comment:
Get engine max torque factor.
set (rcar) maxtorque factor (float)
Comment:
Set engine max torque factor.
set (rcar) gear (int)
Comment:
Set current gear for given car. 0=Neutral, 1=Reverse, 2=1st,...
get (rcar) movables
Returns:
int
Comment:
Get car movablecount.
get (rcar) movable (int)
Returns:
rmovable
Comment:
Get car movable by index.
get (rcar) route destination waypoint
Returns:
int
Comment:
Get car waypoint-destination.
set (rcar) route (int)
Returns:
int
Comment:
Set route for given car. Returns 1 if succeeded
set (rcar) fastest route (int)
Returns:
int
Comment:
Set fastest route for given car. Returns 1 if succeeded
get (rcar) route from waypoint
Returns:
int
Comment:
Get car's route 'from' waypoint. This is the waypoint where we were last.
get (rcar) route to waypoint
Returns:
int
Comment:
Get car's route 'to' waypoint. This is the waypoint where we should be heading at.
get (rcar) route progress from to
Returns:
float
Comment:
Get car's route progress between waypoint 'from' (0.0) and 'to' (1.0f).
get (rcar) route autorecalc
Returns:
int
Comment:
Get if route is recalculated when the car is not following the specified route.
set (rcar) route autorecalc (int)
Comment:
Set if route is recalculated when the car is not following the specified route.
get (rcar) route arrived
Returns:
int
Comment:
Get if car is arrived at destination.
get (rcar) route ideal distance
Returns:
float
Comment:
Get car's route distance from the ideal route position.
get (rcar) route list current index
Returns:
int
Comment:
Get car routelist's current index. The routelist is a list of waypoints that make out a route.
get (rcar) route list size
Returns:
int
Comment:
Get car routelist size. The routelist is a list of waypoints that make out a route.
get (rcar) route list element (int)
Returns:
int
Comment:
Get car routelist's waypoint by index. The routelist is a list of waypoints that make out a route.
get (rcar) traffic
Returns:
int
Comment:
Get if car is traffic enabled.
set (rcar) randomroute (int)
Comment:
Set if car drives random routes.
get (rcar) randomroute
Returns:
int
Comment:
Get if car drives random routes.
get traffic cars
Returns:
int
Comment:
Get number of traffic cars.
get traffic car (int)
Returns:
rcar
Comment:
Get car is traffic.
set (rcar) traffic (int)
Comment:
Sets traffic flag of given car.
set (rcar) traffic velocityfactor (float)
Comment:
Sets velocity factor of given traffic car.
get (rcar) traffic velocityfactor
Returns:
float
Comment:
Gets velocity factor of given traffic car.
get (rcar) steerpos
Returns:
float
Comment:
Returns steer-position for given car.
get (rcar) nm
Returns:
float
Comment:
Returns nm for given car.
get (rcar) gforce
Returns:
float[3]
Comment:
Returns gforce for given car.
get (rcar) ai
Returns:
int
Comment:
Returns whether giver car is controlled by AI.
set (rcar) ai (int)
Comment:
Sets AI of given car.
get (rcar) alive
Returns:
int
Comment:
Returns whether given car is still alive.
get (rcar) size
Returns:
float[3]
Comment:
Returns size of car.
get (rcar) wheel (int) velocity
Returns:
float[3]
Comment:
Returns velocity of indexed wheel of given car.
get (rcar) wheel (int) contactwc
Returns:
float[3]
Comment:
Returns contactwc of indexed wheel of given car.
get (rcar) wheel (int) load
Returns:
float
Comment:
Returns load of indexed wheel of given car.
get (rcar) wheel (int) slipangle
Returns:
float
Comment:
Returns slipangle of indexed wheel of given car.
get (rcar) wheel (int) slipratio
Returns:
float
Comment:
Returns slipratio of indexed wheel of given car.
get (rcar) wheel (int) optimal slipangle
Returns:
float
Comment:
Returns optimal slipangle of indexed wheel of given car.
get (rcar) wheel (int) optimal slipratio
Returns:
float
Comment:
Returns optimal slipratio of indexed wheel of given car.
get (rcar) wheel (int) surfacetype
Returns:
int
Comment:
Returns surfacetype under indexed wheel of given car.
get (rcar) wheel (int) powergearing
Returns:
float
Comment:
Returns powergearing of indexed wheel of given car.
set (rcar) wheel (int) powergearing (float)
Comment:
Sets powergearing of indexed wheel of given car.
set (rcar) wheel (int) brakefactor (float)
Comment:
Sets brakefactor of indexed wheel of given car.
get (rcar) wheel (int) brakefactor
Returns:
float
Comment:
Returns brakefactor of indexed wheel of given car.
set (rcar) wheel (int) gripfactor (float)
Comment:
Sets gripfactor of indexed wheel of given car.
get (rcar) wheel (int) gripfactor
Returns:
float
Comment:
Returns gripfactor of indexed wheel of given car.
get (rcar) wheel (int) surfaceindex
Returns:
int
Comment:
Returns surface index (from special.ini surf_* order) under indexed wheel of given car.
get surface count
Returns:
int
Comment:
Returns number of defined surfaces.
get surface (int) name
Returns:
string
Comment:
Returns name of indexed surface.
get movable (string)
Returns:
rmovable
Comment:
Returns movable with given name.
command (rmovable) do (string)
Comment:
Sends command to give movable.
get (rmovable) pbody count
Returns:
int
Comment:
Get number of physics bodys in movable.
get (rmovable) pbody (int)
Returns:
pbody
Comment:
Get indexed physics bodys of movable.
wait (int)
Comment:
Script waits for a given amount of time (milliseconds).
resolution
Returns:
int[2]
Comment:
Returns resolution.
paint (string) at (int[2])
Comment:
Paints text at given xy coordinates. Be sure that you use this function ONLY in the paint-tick.
set color (float[4])
Comment:
Set paint-color (for painting text for example).
set font (string)
Comment:
Set your own custom font by referencing a font file.
set fontsize x (float) y (float)
Comment:
Set current font size. (only applies to active font)
interval
Returns:
int
Comment:
Returns interval between the current tick and the previous tick of active script (milliseconds).
random
Returns:
int
Comment:
Returns random integer number.
pause
Comment:
Pauses racer.
unpause
Comment:
Unpauses racer.
paused
Returns:
int
Comment:
Returns whether racer is paused or not.
reset
Comment:
Resets active session.
exit
Comment:
Exits active session.
simtime
Returns:
int
Comment:
Returns current simulation time (milliseconds).
multiview
Returns:
int
Comment:
Returns whether racer is configured as multiview client.
spectator
Returns:
int
Comment:
Returns whether racer is configured as spectator.
trackdir
Returns:
string
Comment:
Returns current track directory.
qdbg (string)
Comment:
Prints a debug message.
timeline (int) pos
Returns:
float[3]
Comment:
Returns coordinates of given time-line ("from" coordinates).
set paint racestats (int)
Comment:
Enables or disables painting of the race-stats.
send (string) to console
Comment:
Send string to console.
is key (int) pressed
Returns:
int
Comment:
Is key pressed (range 0 to 255).
paint rect at (int[2]) size (int[2])
Comment:
Draws a filled rectangle with x and y of parameter 1, and wid and height of parameter 2.
paint (rtex) at (int[2]) size (int[2])
Comment:
Draws a bitmap texture with x and y of parameter 1, and wid and height of parameter 2.
create tex (string)
Returns:
rtex
Comment:
Creates texture from string and returns texture object.
set kill after run (int)
Comment:
Set if we want this script to be terminated after it has ended it's run. (some scripts will restart)
get kill after run
Returns:
int
Comment:
Get if we want this script to be terminated after it has ended it's run. (some scripts will restart)
laptime (int) to string
Returns:
string
Comment:
Converts laptime (ms) to a string
server
Returns:
int
Comment:
Returns whether racer is configured as server.
publicserver
Returns:
int
Comment:
Returns whether racer is configured as public server.
servertime
Returns:
int
Comment:
Get estimated time on server.
print (string) to console
Comment:
Prints a message to the console.
get heat
Returns:
int
Comment:
Returns current heat.
paint (rtex) at (int[2]) alpha (float) size (int[2])
Comment:
Draws a bitmap texture with x and y of parameter 1, alpha of parameter 2, and wid and height of parameter 3.
waypointcount
Returns:
int
Comment:
Get number of waypoints
set waypoint (int) can pass dynamic (int)
Comment:
Set if waypoint is blocked for passing cars (cars will stop at this waypoint).
get waypoint (int) can pass dynamic
Returns:
int
Comment:
Get if waypoint is blocked for passing cars (cars will stop at this waypoint).
set waypoint (int) can pass randomroute (int)
Comment:
Set if waypoint is blocked when calculating routes.
get waypoint (int) can pass randomroute
Returns:
int
Comment:
Get if waypoint is blocked when calculating routes.
get waypoint (int) velocity
Returns:
float
Comment:
Get velocity of waypoint.
get waypoint (int) pos
Returns:
float[3]
Comment:
Get position of waypoint.
get waypoint (int) forward
Returns:
int
Comment:
Get forward waypoint of waypoint.
get waypoint (int) left
Returns:
int
Comment:
Get left waypoint of waypoint.
get waypoint (int) right
Returns:
int
Comment:
Get right waypoint of waypoint.
warp (rcar) to waypoint (int)
Returns:
int
Comment:
Warp indexed car to waypoint. Returns 1 on succes.
warp (rcar) on waypoint (int) dir (int)
Returns:
int
Comment:
Warp indexed car to waypoint with heading to another waypoint. Returns 1 on succes.
warp (rcar) on waypoint (int) posoffset (float[3])
Returns:
int
Comment:
Warp indexed car to waypoint with offset of pos. Returns 1 on succes.
get node (string)
Returns:
rnode
Comment:
Get node with given name (is usually trackdir+"/"+doffilename).
hide (rnode)
Comment:
Hide given node.
show (rnode)
Comment:
Show given node.
scale motion (float)
Comment:
Scale motion.
Maybe it could be possible by using offsetshey guys! A question here:
Does the script allow to only rotate objects, or we can slide by an axle, like windows at the doors?