Upcoming Events

Weekly BMW races on Simracing.GP Other regular AC events on Simracing.GP Weekly GT3 Sprint Races on Simracing.GP Weekly GT4 Sprint Races on Simracing.GP Daily WTCR races on Simracing.GP

RSX / RCX & REX Files {Scripting}

Both the things you ask for are easy to implement in theory.

But on particles I don't think authors can define/place their own particle systems yet. They still seem to be hard coded.
Actually defining particle systems should be very easy though looking at what is already there in particles.ini

Water drops on glass is certainly possible too, but I think the primary concern is how the shader would know the current state of the 'rain' variable on a track.



Hopefully all the in-game things will be able to talk better to each other soon. Onyx may help, along with the rcx stuff, and other script capabilities we seem to have now.

My hope is for some clarity on these matters as we have about three scripting methods now and I have no idea what each one is best at doing or why, or even how to really properly use them efficiently (ie, minimum processor impact)


Hmmmmm

Dave
 
Ok, quick question to make sure I understand this right... if I open the console and type "doc scriptfuncs", and "system export" the two html files that are generated contain all the car variables I can access using the scripting system, right?

The reason I ask is because I'm trying to script the Unimog's 4wd system, and I've not been able to find a way to access differential.type or wheel.powered. I'd like to be able to switch between locked and open diffs, and i'd like to be able to turn off 4wd because while I do have low and high range working, the whole power_gearing 4wd hack does really weird things when 700nm is passed through the 578.66:1 gear reduction in low 1st reverse. :roflmao:


EDIT: In case anyone else was wondering the same thing, Cosmo answer my question in this thread: http://www.racedepartment.com/forum/threads/porsche-914-6-v0-9-0-update.53638/
 
I made a list of keyboard key codes that will help those that write scripts and those that want to modify a rsx script dile. Also included is the profile1.ini that I use to show the look left/right/up/down code and the head tracking code for those that can use it.
 

Attachments

  • key list.txt
    1.9 KB · Views: 413
  • profile list.txt
    3.8 KB · Views: 512
I think it might be a good idea at this stage to kinda formalise some controls as sensible defaults so there is at least some consistency.

Ie:

h - horn
w- wipers (cycle modes as you press it multiple times perhaps?)
{ } = left/right indicators

Not my recommendations by any means, just some logic so cars are consistent on the keyboard at least?

Even if we don't all agree right off the bat at least it's working towards a keyboard map that you learn once and it works everywhere, even if it changes a bit with time or gets changed per user if they have personal preferences!?


Hmmm

Dave
 

KS95

RACER Moderator
Is it possible to use wheel controls? IE the shift paddles on my G27 for indicators? Bar that I agree on standards for wipers and lights (fogs or w/e else).
 
I indicated in the key list I posted the keys that are normally used for various actions such as l ights, h orn, p ause etc., in racer.
 
Hi guys,
here is a new version of the automatic script :
Put this in "scripts/physics"
Code:
func void shift(float $mindownrpm,float $maxdownrpm,float $minuprpm,float $maxuprpm,float $factor)
{
    rcar $car = get scriptowner car
    int $i
    float $rpm = get $car rpm
    float $tc = get $car tc active
    float $gear = get $car gear
    float $brake = get $car brake
      float $throttle = get $car throttle
    float $unthrottle = 1-$throttle
    float $shiftdown = $unthrottle*$mindownrpm+$throttle*$throttle*$maxdownrpm
        float $shiftup = $unthrottle*$minuprpm+$throttle*$maxuprpm*$factor //Used variables
    if ($shiftdown < $mindownrpm) //Avoid to low downshift...
    {
        $shiftdown=$mindownrpm
    }
    if $rpm < 500 //Put neutral when stall
    {
        set $car gear 0
        wait(250)
    }
    if $rpm < $shiftdown //Downshift
    {
        if $throttle > 0.8 
        {
            set $car gear ($gear-1)
            
            wait(150)
        }
        else if $brake > 0
        {
            set $car gear ($gear-1)
                    wait(700)
        }
        else
        {
            set $car gear ($gear-1)
            wait(1000*$unthrottle)
            if $unthrottle < 0.1
            {
                $unthrottle = 0.1
            }
        }
    }
    if $rpm < 1700 and $throttle == 0 and $gear>2 //Downshift when braking
    {
        if $brake > 0
        {
            set $car gear ($gear-1)
            wait(1000)
        }
        else
        {
            set $car gear ($gear+0)
        }
    }
    if $rpm > $shiftup //Up shift
    {
        if $tc == 0 and $brake == 0 and $throttle > 0.30
        {
            set $car gear ($gear +1)
            if $unthrottle < 0.1
            {
                $unthrottle = 0.1
            }
                    wait(750*$unthrottle)
        }
        else if $tc==0 and $rpm > 6000
        {
            set $car gear ($gear +1)
                    wait(1)
        }
    }
}
func void impulsionel(float $shiftdown,float $shiftup)
{
    rcar $car = get scriptowner car
    float $rpm = get $car rpm
    float $gear = get $car gear
    if $rpm < $shiftdown //Downshift
    {
        set $car gear ($gear-1)
    }
    if $rpm > $shiftup //Up shift
    {
        set $car gear ($gear +1)
    }
}
rcar $car = get scriptowner car
float $gear
shared int $shiftup = 0
shared int $shiftdown = 0
float $tc = 0
float $brake = 0
shared int $mode = 2
shared string $gmode = "drive"
float $speed
while 1
{
      $tc = get $car tc active
      $brake = get $car brake
      $speed = get $car tachovelocity
      $speed = $speed * 3.71
    $gear = get $car gear
      if is key (90) pressed
      {
        if $mode <3
        {
            $mode += 1
            wait (250)
        }
        else
        {
            $mode = 2
            wait (250)
        }
      }
      if is key 78 pressed
      {
        $mode = 0
        set $car gear 0
            $gmode = "N"
      }
      if is key 82 pressed
      {
        if $speed < 5 and $brake > 0
        {    
            $mode = 1
            set $car gear 1
            wait (250)
                $gmode ="R"
        }
      }
    if $mode == 2
    {
            $gmode ="Drive"
        if $gear < 2
        {
            set $car gear (2)
        }
        if $gear== 2 //Gear 1
        {
            shift(0,0,1800,5800,1.00) //0 and 0 first argument to avoid downshift in 1st :D
        }
        if $gear == 3 //Gear 2
        {
            shift(850,3000,1050,5800,1.00)
        }
        if $gear == 4 //Gear 3
        {
            shift(1000,3000,1050,5850,1.00)
        }
        if $gear == 5 //Gear 4
        {
            shift(1200,3600,2400,5500,1.00)
        }
        if $gear == 6 //Gear 5
        {
            shift(1200,3500,2000,6000,1.00)
        }
        if $gear == 7 // Gear 6
        {
            shift(1200,4000,2000,6000,1.00)
        }
    }
    else if $mode == 3
    {
        if $speed < 5 and $gear < 2
        {
            set $car gear 2
            wait(250)
        }
            $gmode ="Impulsionel"
        if $gear > 1
        {
            impulsionel(1100,6000)
        }
      }
interrupt
}
I think this script if more realistic for the modern automatics gearbox (after 98 i think).
To fit it with the car you want, just change parameters for each gear :)
The semi auto mode was not aviable in all auto? (i know for "proactives" gearboxes of renault yes, but other?)
Also i don't (for the moment, can be easyly done) the gear lock
and of course the code for the "scripts/paint" section
Code:
shared int $mode = 2
shared string $gmode = "drive"
while 1
{
  paint "Mode :" at float[2]{20,60}
  paint $gmode at float[2]{70,60}
interrupt
}
 
Your welcome,
here is another script , the cruise control :
http://speedy.sh/4Ddf7/scripts.rar
Keys :
T to enable
Y to disable
J to increase target speed
K to decrease target speed

The script was based (and inspirated) from stereo's speed limiter, by him i discovered that the throttle value can be modified (i tested without any sucess before) so thanks to him :)

You need to enter "reload scripts" in console to get him working.

Don't work nicely in automatic gearbox, it always keep higher gear the the clutch slips :/

You can look in the .rsx file for more comments :D

I hope you'll like it :)
 
Does anyone remember the example script that let us shoot a ball from the front of the car (as in Viper Racing)? I would like a copy if it still exists.

Alex Forbin
 
Hi, sorry for bump this topic but i've made something that should be interessting..
I've spent my last hours on it, it is a script (made for track) that calculate and display several statistics
  • Top speed (mph/km/h)
  • Elasticity on different gears
  • 0-100 time
I've also made a function for calculate 0-1000m and 0-400m but don't know why the mesured distance seems to be wrong : 100 real meter are shown as 100,5 for the script, but 1000 real shown as ~845 by the script, so gives weird time.

For the top speed, it works only in speedtest3, just turn arround the track at full throttle, by your bestlap time (in the loop) the script will calculate the average speed during the lap, I think most of reviews does like that (at least in france)

About the keys :
  • H for acceleration tests
  • U for elasticity

For acceleration, stop the car, press H and go !
For elasticity, you have to be at a greather speed than the "start" speed, exemple 85km/h for a 80-120, then you press U, the script will relase the throttle until the car goes at 80, then gives full throttle until 120 ;)

I hope you will like, and you will find it usefull for your tests ;)

data/trackname/scripts/physics
Code:
[U][B][/B][/U]
rcar $car = get local car
float $bestlap
float $topspeed = 0.0
float $topmph = 0.0
float $distance = 3.18
shared int $finalspeed
shared int $mphspeed

int $test_en_cours = 0
int $test = 0

int $test_acceleration = 0
int $test_en_cours_acceleration = 0
int $test_distance = 0
int $test_en_cours_distance = 0
float $timer_start
float $start_position[3]

func float reprise(float $speed,float $speed_start,float $speed_stop)
{
   float $resultat
   float $throttle_correction
   float $throttle = get $car throttle
   if $test == 1
   {
     if $speed > $speed_start and $test_en_cours == 0
     {
       //On relache l'accelerateur jusqu'a la vitesse de debut
       $throttle_correction =  0.00
       $test_en_cours = 0
     }
     if $speed <= $speed_start and $test_en_cours == 0
     {
       echo "Debut du test, reprise de "+$speed_start
       $timer_start=simtime
       $test_en_cours = 1
     }
     if $speed < $speed_stop and $test_en_cours == 1
     {
       $throttle_correction = 1.00
     }
     if $speed >= $speed_stop and $test_en_cours == 1
     {
       echo "Fin du test de reprise"
       $throttle_correction = $throttle
       $resultat = (1.0*simtime -1.0*$timer_start)
       $test_en_cours = 0
       $test = 0
     }
   }
   if $test == 0
   {
     $throttle_correction = $throttle
   }
   set $car throttle $throttle_correction
   return $resultat
}

func float acceleration_func(float $speed,float $speed_acceleration)
{
   float $resultat
   if $test_acceleration == 1
   {
     if $speed > 0.05 and $test_en_cours_acceleration == 0
     {
       //Depart
       echo "Depart test acceleration"
       $timer_start=simtime
       $test_en_cours_acceleration = 1
     }
     if $speed >= $speed_acceleration and $test_en_cours_acceleration == 1
     {
       echo "Fin test acceleration"
       $resultat=(1.0*simtime - 1.0*$timer_start)
       $test_acceleration = 0
       $test_en_cours_acceleration = 0
     }
   }
   return $resultat
}

func float[2] acceleration_dist(float $speed,float $max_distance1,float $max_distance2,float $pos[3])
{
   float $resultat
   float $resultat2
   float $current_position[3]
   float $distance_parcourue[3]
   float $distance_parcourue_m = 0.0
   if $test_distance == 1
   {
     if $speed > 0.05 and $test_en_cours_distance == 0
     {
       //Depart
       echo "Depart test distance"
       $start_position.x = $pos.x
       $start_position.y = $pos.y
       $start_position.z = $pos.z
       $timer_start=simtime
       $test_en_cours_distance = 1
     }
     
     if $test_en_cours_distance == 1
     {
       $distance_parcourue = (get $car pos)-$start_position
       $distance_parcourue_m = sqrt ((pow $distance_parcourue[0] to 2) + (pow $distance_parcourue[1] to 2) + (pow $distance_parcourue[2] to 2))
     }
     if $distance_parcourue_m >$max_distance2 and $test_en_cours_distance == 1
     {
       //Distance la plus longue
       $resultat=(1.0*simtime- 1.0*$timer_start)
       echo "Fin test distance"
       $test_en_cours_distance = 0
       $test_distance = 0
     }
   }
   echo $distance_parcourue_m
   float $array[2] = float[2]{$resultat,$resultat2}
   return $array
}

//Les parametres de tests

float $speed_start = 80.00
float $speed_stop = 120.00
float $speed_acceleration = 100.00
float $dist1=400.0
float $dist2=1000.0

//Les resultats
shared float $reprise_4
shared float $reprise_5
shared float $reprise_6
shared float $acceleration_speed
shared float $acceleration_dist1
shared float $acceleration_dist2

while 1
{
   $bestlap = get $car bestlap
   float $lap_hours = ($bestlap/1000.0)/ 3600.0
   $topspeed = ($distance/$lap_hours)
   $topmph = $topspeed / 1.6094
   float $speed = get system "car0.telemetry.vel_length"
   $speed*=3.60
   int $gear = get $car gear
   float $reprise_temp
   float $acceleration_temp
   float $acceleration_temp_dist[2]
   float $pos[3]=get $car pos
   if ($topspeed % 1 > 0.50)
   {
     $finalspeed=$topspeed +1 -($topspeed % 1)
   }
   if ($topspeed % 1 < 0.50)
   {
     $finalspeed=$topspeed-($topspeed % 1)-1
   }
   if ($topmph % 1 > 0.50)
   {
     $mphspeed=$topmph + 1 - ($topmph % 1)
   }
   if ($topmph % 1 < 0.50)
   {
     $mphspeed=$topmph-($topmph % 1)-1
   }
   
   
   //Mise en route du test acceleration
   if is key 72 pressed
   {
     //Touche H pour test 0 a 100
     if $test_acceleration == 0 and $speed < 0.05
     {
       $test_distance = 1
       echo "test distance demande"
       $test_acceleration = 1
       echo "test d'acceleration demande"
       wait(200)
     }
     else
     {
       $test_acceleration = 0
       $test_acceleration = 0
       wait(200)
     }
   }
   
   //Test acceleration
   if $test_acceleration == 1
   {
     $acceleration_temp=acceleration_func($speed,$speed_acceleration)
   }
   if $acceleration_temp > 0.0
   {
     $acceleration_speed = $acceleration_temp/1000.0
   }
   
   //Test distance
   if $test_distance == 1
   {
     //$acceleration_temp_dist=acceleration_dist($speed,$dist1,$dist2,$pos)
   }
   if $acceleration_temp_dist[1] > 0.0
   {
     //$acceleration_dist1 = ($acceleration_temp_dist[1])/1000.0
   }
   
   //Mise en route du test de reprise
   if is key 85 pressed
   {
     //Touche U pour commencer le test de reprise
     if $speed > $speed_start
     {
       $test = 1
       echo "test de reprise demande"
     }
     wait(250)
   }
   
   
   //Test reprise
   if $gear == 5
   {
     //Reprise en 4
     $reprise_temp=reprise($speed,$speed_start,$speed_stop)
     if $reprise_temp > 0
     {
       $reprise_4=$reprise_temp/1000.0
     }
   }
   if $gear == 6
   {
     //Reprise en 5
     $reprise_temp=reprise($speed,$speed_start,$speed_stop)
     if $reprise_temp > 0
     {
       $reprise_5=$reprise_temp/1000.0
     }
   }
   if $gear == 7
   {
     //Reprise en 6
     $reprise_temp=reprise($speed,$speed_start,$speed_stop)
     if $reprise_temp > 0
     {
       $reprise_6=$reprise_temp/1000.0
     }
   }
   interrupt
}

In data/trackname/scripts/paint

Code:
shared int $finalspeed
shared int $mphspeed
shared float $reprise_4
shared float $reprise_5
shared float $reprise_6
shared int $test
shared float $acceleration_speed
shared float $acceleration_dist1
shared float $acceleration_dist2
//Display
int $x_pos = 1600

while 1
{
   paint "Acceleration 400m DA : " + $acceleration_dist1 at float[2]{$x_pos,270}
   paint "Acceleration 1000m DA : " + $acceleration_dist2 at float[2]{$x_pos,290}
   paint "Acceleration de 0 a 100 : " + $acceleration_speed at float[2]{$x_pos,310}
   paint "Top speed (km/h) : " + $finalspeed at float[2]{$x_pos,330}
   paint "Top speed (mph) : " + ($mphspeed) at float[2]{$x_pos,350}
   paint "Temps de reprise en 4 : " + ($reprise_4) at float[2]{$x_pos,370}
   paint "Temps de reprise en 5 : " + ($reprise_5) at float[2]{$x_pos,390}
   paint "Temps de reprise en 6 : " + ($reprise_6) at float[2]{$x_pos,410}
   interrupt
}
 
That looks interesting, I'll have to grab it later to try out.

I've been messing with track scripts too, mainly making a road that gets wet over time and becomes covered in puddles, and then dries out.

Also I've been playing with ESP style scripts a bit more for yaw control with brakes. Currently thinking about writing a small curve import script, or maybe just a data matrix loader/interpolating script so we can do some slightly smarter stuff.

Ie, steering angle vs yaw rate vs slip angle difference 'curve' to control the ESP on/off state.


Hmmmm

Dave
 
Scratch that on the rain/puddles.

I can kinda fudge a rain.crv and night.crv (to drive the shader change for wet looking road) but really this isn't what I wanted to do.

For some reason I thought I could 'set' night variable too, just like I can with sunny, rain, and loads of other variables.
That way I could control the rain/wetness randomly, along with another clouds overlay texture, sunny value tweaks etc, rather than a pre-determined system which kinda is a bit boring really.


My biggest single wish for Racer is still for the scripting to be fully matured and featured so all these kinds of things we can just set up and enjoy :D


Hmmm

Dave
 
Top