[No Limits 2] Tuto sur les scripts

Thrillrider119 a dit:
Ah bah en c'est bon en fait j'avais pas nommé le composant "test" en fait et maintenant ça marche ! C'est nickel ! Merci beaucoup!  :wink:

De rien, sinon il y a aussi celui ci... Je crois que c'est Benij qui l'avait posté...
import com.nolimitscoaster.*;
//import nlvm.math3d.*;

public class HeliceScript extends Script
{
  private SceneObject m_sco;
  private SceneObjectElement m_mainroue;
 

  private float m_angle;

public bool onInit()

    {

  m_sco = sim.getSceneObjectForEntityId(getParentEntityId());
 
  m_mainroue = m_sco.getElementForName("helice");

  return true;

  }

public void onNextFrame(float tick)
  {
 
  m_angle += tick * 2.0f;

  m_angle = m_angle % (float)(2*Math.PI);

  m_mainroue.setRotation(m_angle, 0, 0);

  }

}
 
Salut salut!

Je cherche un script qui me permettrait de créer un effet de fumigène du style vapeur sous pression qui fuit d'une canalisation et synchronisée avec le passage du train. J'ai aucune idée de comment faire ça...
Il y a déjà des effets de brume dans le jeu mais c'est clairement pas assez dynamique par rapport à ce que je souhaite  :-P
Quelqu'un aurait une idée?
 
Thrillrider119 a dit:
Salut salut!

Je cherche un script qui me permettrait de créer un effet de fumigène du style vapeur sous pression qui fuit d'une canalisation et synchronisée avec le passage du train. J'ai aucune idée de comment faire ça...
Il y a déjà des effets de brume dans le jeu mais c'est clairement pas assez dynamique par rapport à ce que je souhaite  :-P
Quelqu'un aurait une idée?

Toi, tu veux ça !  :wink:
http://www.youtube.com/embed/J3e7ij_MvSM?rel=0
 
Bonjour! J'ai trouvé le script SplineExport (je l'ai trouvé sur Youtube puis je l'ai recopié et mis le script dans le dossier de Nolimits, dans le parc que je fait, et quand je lance le script (dans l'éditeur), il me marque un message d'erreur:
1497789687-ptobleme.jpg

Code:
import com.nolimitscoaster.*;
import nlvm.math3d.*;

public class SplineExport extends Script {
    /////////////////////////////////////////////
    float heartline = 0.3f;
    float seperation = 0.25f;

    float beginDistance = 0.0f;
    int beginIndex = 0;
    /////////////////////////////////////////////

    public Coaster currentCoaster;
    Train fTrain;

    Vector3f last;
    bool first = true;
    float dis = 0.0f;
    bool breakScript = false;

    float totalDistance = 0.0f;
    
    int i=0;

    public bool onInit() {
        currentCoaster = sim.getCoasterForEntityId(getParentEntityId());
        fTrain = currentCoaster.getTrainAt(0);
        last = new Vector3f();

        return true;
    }
    
    public void onNextFrame(float tick) {
        if(breakScript) return;

        Vector3f fo = new Vector3f(0.0f, 0.0f, 0.0f);
        Vector3f to = new Vector3f(0.0f, 0.0f, 0.0f);
        Vector3f ro = new Vector3f(0.0f, 0.0f, 0.0f);
        Vector3f po = new Vector3f(0.0f, 0.0f, 0.0f);

        fTrain.getBogieOrientationAndPosition(0, fo, to, ro, po);

        Vector3f cross = new Vector3f(
            ro.y * fo.z - ro.z * fo.z,
            ro.z * fo.x - ro.x * fo.z,
            ro.z * fo.y - ro.y * fo.x
        );
        
        cross.normalize();
        cross.mul(heartline);
        cross.add(po);

        if(first && beginDistance == 0.0f) {
            System.out.println((i + beginIndex)+ "\t" + po.x + "m\t" + po.y + "m\t" + (po.z * -1.0f) + "m\t");
            System.out.println((i + beginIndex)+ "\t" + cross.x + "m\t" + cross.y + "m\t" + (cross.z * -1.0f) + "m\t");

            first = false;
            i++;
        } else {
            Vector3f v2 = po;
            Vector3f v1 = last;
            float distance = (float) Math.sqrt(Math.pow(v2.x, 2) + Math.pow(v2.y - v1.y, 2) + Math.pow(v2.z - v1.z, 2));
            if(first && beginDistance != 0.0f) {
                first = false;
                distance = 0.0f;
            }

            dis += distance;
            totalDistance += distance;

            if(dis > seperation) {
                if(beginDistance ==0.0f || (beginDistance != 0.0f && totalDistance > beginDistance)) {
                    System.out.println((i + beginIndex)+ "\t" + po.x + "m\t" + po.y + "m\t" + (po.z * -1.0f) + "m\t");
                    System.out.println((i + beginIndex)+ "\t" + cross.x + "m\t" + cross.y + "m\t" + (cross.z * -1.0f) + "m\t");

                    i++;
                }

                dis = 0.0f;
            }
        }
        
        last.x = po.x;
        last.y = po.y;
        last.z = po.z;

        if(i > 490) {
            System.out.println("Change beginDistance to " + totalDistance + "and beginIndex to " + (i + beginIndex));
            breakScript = true;
        }
    }

}
Je ne trouve pas la source de l'erreur
Quelqu'un aurait-il idée de ce qui bloque? Une erreur dans le script? Merci d'avance

[Fichier joint supprimé par l'administrateur]
 
Salut
J'ai une question, j'ai tenté de faire un programme qui permet d'avoir différent musique dans chaque train (dans mon coaster j'en ai 4), mais lorsque j'ai essayer de lancer le programme il m'indique qu'il y a une erreur (Syntax error: Unexpected character detected), mais je n'arrive pas à voir ou se trouve l'erreur, donc es ce que vous pouvez m'aider s'il vous plaît ?  :cry:

PS: (j'ai fait mon programme à partir du programme MultiTriggerMusic de Meletou  :wink: )

Code:
import com.nolimitscoaster.*;
import nlvm.math3d.*;

 public class MultiTriggerMusic extends Script implements TrackTriggerListener{

    private static final String scriptName = "MultiTriggerMusic"; 

// .................................definition des 2 triggers et des trains..................................
    private TrackTrigger Trigger1; 
    private TrackTrigger Trigger2;
	Train fTrain;
	private int NbTrain;

//*********************************definition des 4 musiques**********************************

 private static final String sSoundFile1 = "Squeezie.ogg";
 StaticSound sSound1;
 private static final String sSoundFile2 = "AlexSkrindo.ogg";
 StaticSound sSound2;
 private static final String sSoundFile3 = "CartoonOnOn.ogg";
 StaticSound sSound3;
 private static final String sSoundFile4 = "CatoonWhyWeLose.ogg";
 StaticSound sSound4;
//***************************************************************************************************
    public bool onInit(){ 
     
       Coaster coaster = sim.getCoasterForEntityId(getParentEntityId()); 

//...................................recherche des triggers sur les rails.................................

       Trigger1 = coaster.getTrackTrigger("startmuisic"); 
       Trigger1.addTrackTriggerListener(this); 
       Trigger2 = coaster.getTrackTrigger("stopmusic");
       Trigger2.addTrackTriggerListener(this);
//============================================On charge les 2 musiques =======================================

       sSound1 = StaticSound.loadFromFile(sSoundFile1, StaticSound.E_ENVMODE_LOCAL);
       sSound2 = StaticSound.loadFromFile(sSoundFile2, StaticSound.E_ENVMODE_LOCAL);
	   sSound3 = StaticSound.loadFromFile(sSoundFile3, StaticSound.E_ENVMODE_LOCAL);
       sSound4 = StaticSound.loadFromFile(sSoundFile4, StaticSound.E_ENVMODE_LOCAL);


       return true;
     
    } 
//-----------------------------------------------------------------------------------------
    fTrain = coaster.getTrackAt(0);
	
	NbTrain = coaster.getTrackCount();
	System.out.println(NbTrain);
	
	
	public void onNextFrame(float fTickTime)
    {
    }

    public void onTrainEntering(TrackTrigger trigger, Train train)
  {
	if (fTrain = coaster.getTrackAt(0))
	{
       if (trigger == Trigger1)
       {
          if (train.getSpeed() > 0){ 

             Sound1outAction1();
          } 
       } 

        if (trigger == Trigger2){
          if (train.getSpeed() > 0)
          {
             Sound1outAction2();

          }
      }
    }
	
	if (fTrain = coaster.getTrackAt(1))
	{
       if (trigger == Trigger1)
       {
          if (train.getSpeed() > 0){ 

             Sound2outAction1();
          } 
       } 

        if (trigger == Trigger2){
          if (train.getSpeed() > 0)
          {
             Sound2outAction2();

          }
      }
    }
	
	if (fTrain = coaster.getTrackAt(2))
	{
       if (trigger == Trigger1)
       {
          if (train.getSpeed() > 0){ 

             Sound3outAction1();
          } 
       } 

        if (trigger == Trigger2){
          if (train.getSpeed() > 0)
          {
             Sound3outAction2();

          }
      }
    }
	
	if (fTrain = coaster.getTrackAt(3))
	{
       if (trigger == Trigger1)
       {
          if (train.getSpeed() > 0){ 

             Sound4outAction1();
          } 
       } 

        if (trigger == Trigger2){
          if (train.getSpeed() > 0)
          {
             Sound4outAction2();

          }
      }
    }
 } 
//-------------------------------------------------------------------------------------------
    public void onTrainLeaving(TrackTrigger trigger, Train train)
    {
    }
//------------------------------------------------------------------------------------------
    public void Sound1outAction1()
    {
         System.out.println("Entré: Trigger1");
         soundTrigger1();                                                               
         sSound1.play();                                                                 // play musique 1
    }
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     public void Sound1outAction2()
    {
         System.out.println("Entré: Trigger2");
         sSound1.stop();                                                                   // stop musique 1
    }
//------------------------------------------------------------------------------------------
    public void Sound2outAction1()
    {
         System.out.println("Entré: Trigger1");
         soundTrigger2();                                                              
         sSound2.play();                                                                  // play musique 2
    }
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     public void Sound2outAction2()
    {
         System.out.println("Entré: Trigger2");
         sSound2.stop();                                                                 // stop musique 2
    }
	
//------------------------------------------------------------------------------------------
    public void Sound3outAction1()
    {
         System.out.println("Entré: Trigger1");
         soundTrigger3();                                                            
         sSound3.play();                                                                  // play musique 3
    }
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     public void Sound3outAction2()
    {
         System.out.println("Entré: Trigger2");
         sSound3.stop();                                                                // stop musique 3
    }
	
//------------------------------------------------------------------------------------------
    public void Sound4outAction1()
    {
         System.out.println("Entré: Trigger1");
         soundTrigger4();                                                           
         sSound4.play();                                                                   // play musique 4
    }
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     public void Sound4outAction2()
    {
         System.out.println("Entré: Trigger2");
         sSound4.stop();                                                                 // stop musique 4
    }
//+++++++++++++++++++++++++++++++++++++++Position de la 1 musique ++++++++++++++++++++++++++++++++++++++
     public void soundTrigger1()
        {

  if(sSound1 == null)
                 {
   System.err.println("Sound file 1 not found");
   return;
   }

  sSound1.setPosition(new Vector3f(0.0f,0.0f,0.0f));
  sSound1.setGain(20.0f);

 }
//.........................................Position de la 2 musique...................................
  public void soundTrigger2()
        {

  if(sSound2 == null)
                 {
   System.err.println("Sound file 2 not found");
   return;
   }

  sSound2.setPosition(new Vector3f(0.0f,1.0f,0.0f));
  sSound2.setGain(20.0f);

 }
//..................................Position de la musique 3...................................
  public void soundTrigger3()
        {

  if(sSound3 == null)
                 {
   System.err.println("Sound file 3 not found");
   return;
   }

  sSound3.setPosition(new Vector3f(0.0f,1.0f,0.0f));
  sSound3.setGain(20.0f);
  }
//................................Position de la muisique 4...................................
  public void soundTrigger4()
        {

  if(sSound4 == null)
                 {
   System.err.println("Sound file 4 not found");
   return;
   }

  sSound4.setPosition(new Vector3f(0.0f,1.0f,0.0f));
  sSound4.setGain(20.0f);
  }

 }
 
Thesosonani a dit:
public bool onInit(){
   
      Coaster coaster = sim.getCoasterForEntityId(getParentEntityId());

//...................................recherche des triggers sur les rails.................................

      Trigger1 = coaster.getTrackTrigger("startmuisic");

Est ce normal ?
Est ce qu'il te donne le numéro de la ligne en question?
 
Bonjour à tous,

Je suis actuellement dans une impasse vis à vis d'une fonction que je veux mettre en place et qui est en théorie simple mais qui est devenue ingérable ensuite.
J'ai basicalement voulu intégrer un (et un seul) switch de voie scripté dans un layout, de manière à obtenir un launch en avant, puis en arrière puis en avant pour continuer le trajet.

Problème est : Le script generator requiert deux changements de directions, car selon le script je suis entré par la fin du bloc (alors que non je suis entré dans le sens normal) et je repars dans cette même direction (qui est la vrai fin du bloc). soit basiquement sous cette forme (oubliez les deux stocks, c'est à partir de là que ça déconne) :
6dnHDgZ.png


Sauf que voilà comment ça se passe en réalité :
heunsyW.jpg


Question : Mon layout se déroulant intégralement en avant, comment je peux faire comprendre au script qu'il n'y a qu'un et un seul switch et que le track finit bel et bien dans le bon sens ? (Je n'ai aucune connaissances en java ou autre langage).

Le script est très simple à imiter sans le fichier avec le generator.

Merci d'avance  :mrgreen:
 
Il doit bien y avoir une quelconque manière de réaliser cette action qui est sur le papier ultra basique. Je n'ai malheureusement aucune connaissances en la matière pour scripter la chose moi-même.

16549165313.PNG


Si un train se trouve sur le block noir, jaune ou bleu, alors le switch est en position 2. Dans le cas contraire le switch peut repasser en position 1. Cela peut se régler via un "Fake Block" plus loin sur la voie qui définie le point à partir duquel le switch peut changer à nouveau.

Je pense même qu'on peut le faire via des triggers à même la voie, dans le genre :
Si un train se trouve sur le trigger 1, alors le switch passe en position 2, Si un train passe le trigger 2, alors le switch repasse en position 1.

Quelqu'un a une idée ?
 
Bon je viens aux nouvelles.

On a tenté plusieurs choses mais il semblerait qu'il y ai une erreur.

D'abord on a chargé le track et le switch avec ça :

Coaster coaster = sim.getCoasterForEntityId(getParentEntityId());
SpecialTrack switch = coaster.getSpecialTrack("monSwitch");

Puis on a tenté de d'effectuer le switch comme expliqué dans la doc de NL2 via :

switch.setSwitchDirection(1);

mais peu importe la valeur, rien ne se passe et ça renvoie "false" qu'on log dans la console, ce qui signifie que le déplacement a échoué.

Je précise que cette tentative est effectuée en utilisant des triggers sur la voie.

Des idées ?
 
We did it !! Un ami a réussi à prog le script et tout fonctionne ! Je le partagerais si il le veut bien. Mais pour le moment le problème est résolut !  :rire:
 
Il ne marche pas via le Script generator. Le generator est uniquement pensé pour faire fonctionner des aiguillages par pair, de manière à avoir une section en avant, puis en arrière, puis en avant et retour station pour faire court.

Sur mon ride l'idée était de quitter la station, passer un aiguillage pour se retrouver sur une section de launch sur laquelle le train s'engage en marche avant, avant de revenir en arrière, de passer l'aiguillage sur la seconde voie vers une tour, puis de repartir en avant.

En gros si l'on suivait le générateur de scripts, après le premier passage de l'aiguillage Nolimits 2 considère que le train passe en mode Backward et ce peu importe si il est en fait en marche avant. Donc il y a un paradoxe qui empêche le track de fonctionner.

Notre script (qui, sans retouches ne fonctionne probablement pas sur un autre track) fonctionne via un système de triggers. Le Trigger A se situe juste après l'aiguillage et exige un passage de l'aiguillage sur voie 2. Ensuite plus loin sur le layout un Trigger B force le retour de l'aiguillage en voie 1 à départ de station, lorsque le launch a été effectué.

Code:
import com.nolimitscoaster.*;

public class SwitchScript extends Script implements BlockSystemController {

    private static final String _script = "SwitchScript";
    private static final int STATE_BLOCK_FREE = 0;
    private static final int STATE_BLOCK_APPROACHING = 1;
    private static final int STATE_BLOCK_LEAVING = 2;
    private static final int STATE_BLOCK_BEFORE_TRIGGER = 3;
    private static final int STATE_BLOCK_BEHIND_TRIGGER = 4;
    private static final int STATE_BLOCK_WAITING = 5;
    private static final int STATE_BLOCK_WAIT_FOR_CLEAR = 6;
    private static final int STATE_BLOCK_WAIT_FOR_ADVANCE = 7;
    private static final int STATE_BLOCK_IN_STATION = 8;
    private static final int AUTO_MODE = 0;
    private static final int MANUAL_BLOCK_MODE = 1;
    private static final int FULL_MANUAL_MODE = 2;

    private Coaster _coaster;
    private Block _station;
    private SpecialTrack _switch;
    private Block _preLaunch;
    private float _preLaunchTime;
    private Block _trimBrakes;
    private float _trimBrakesTime;
    private Block _stock;
    private float _stockTime;
    private Block _tableStock;
    private float _tableStockTime;

    private int _mode;

    //<editor-fold desc="Initiation">
    public bool onInit() {
        System.out.println(_script + " started !");

        String blockName;
        _coaster = sim.getCoasterForEntityId(getParentEntityId());

        if (_coaster == null) {
            System.err.println(_script + " : Error loading Coaster.");
            return false;
        }
        _coaster.setBlockSystemController(this);
        blockName = "Station";
        _station = _coaster.getBlock(blockName);
        if (!checkAndSetInitialBlockState(_station, blockName)) {
            return false;
        }
        _station.setAdvanceFwdVisible(true);
        blockName = "Switch";
        _switch = _coaster.getSpecialTrack(blockName);
        if (_switch == null) {
            System.err.println(_script + ": SpecialTrack '" + blockName + "' not found.");
            return false;
        }
        blockName = "PreLaunch";
        _preLaunch = _coaster.getBlock(blockName);
        if (!checkAndSetInitialBlockState(_preLaunch, blockName)) {
            return false;
        }
        _preLaunch.setAdvanceFwdVisible(true);
        blockName = "TrimBrakes";
        _trimBrakes = _coaster.getBlock(blockName);
        if (!checkAndSetInitialBlockState(_trimBrakes, blockName)) {
            return false;
        }
        _trimBrakes.setAdvanceFwdVisible(true);
        blockName = "Stock";
        _stock = _coaster.getBlock(blockName);
        if (!checkAndSetInitialBlockState(_stock, blockName)) {
            return false;
        }
        _stock.setAdvanceFwdVisible(true);
        blockName = "TableBlock";
        _tableStock = _coaster.getBlock(blockName);
        if (!checkAndSetInitialBlockState(_tableStock, blockName)) {
            return false;
        }
        _tableStock.setAdvanceFwdVisible(true);
        _mode = AUTO_MODE;
        return true;
    }
    //</editor-fold>

    //<editor-fold desc="Trains Stages">
    public void onNextFrame(float tick) {
        if (_mode != FULL_MANUAL_MODE) {
            processStation();
            processPreLaunch();
            processTrimBrakes();
            processStock();
            processTableStock();
            if (_mode == MANUAL_BLOCK_MODE) {
                updateControlPanel();
            }
        }
    }

    public void onAutoMode(Coaster c) {
        if (_mode == FULL_MANUAL_MODE) {
            setInitialBlockState(_station);
            setInitialBlockState(_preLaunch);
            setInitialBlockState(_trimBrakes);
            setInitialBlockState(_stock);
            setInitialBlockState(_tableStock);
        }
        _mode = AUTO_MODE;
        updateControlPanel();
    }

    public void onManualBlockMode(Coaster c) {
        if (_mode == FULL_MANUAL_MODE) {
            setInitialBlockState(_station);
            setInitialBlockState(_preLaunch);
            setInitialBlockState(_trimBrakes);
            setInitialBlockState(_stock);
            setInitialBlockState(_tableStock);
        }
        _mode = MANUAL_BLOCK_MODE;
        updateControlPanel();
    }

    public void onFullManualMode(Coaster c) {
        _mode = FULL_MANUAL_MODE;
        updateControlPanel();
    }

    public void onAdvanceFWDButton(Block block) {
        if (block == _station) {
            _preLaunch.setState(STATE_BLOCK_APPROACHING);
            _station.setState(STATE_BLOCK_LEAVING);
            _station.getSection().setStationLeaving();
        }
        if (block == _preLaunch) {
            _trimBrakes.setState(STATE_BLOCK_APPROACHING);
            _preLaunch.setState(STATE_BLOCK_LEAVING);
        }
        if (block == _trimBrakes) {
            _stock.setState(STATE_BLOCK_APPROACHING);
            _trimBrakes.setState(STATE_BLOCK_LEAVING);
        }
        if (block == _stock) {
            _tableStock.setState(STATE_BLOCK_APPROACHING);
            _stock.setState(STATE_BLOCK_LEAVING);
        }
        if (block == _tableStock) {
            _station.setState(STATE_BLOCK_APPROACHING);
            _tableStock.setState(STATE_BLOCK_LEAVING);
        }
    }

    public void onAdvanceBWDButton(Block block) {
    }

    private void updateControlPanel() {
        _station.setAdvanceFwdEnabled(_station.getState() == STATE_BLOCK_WAIT_FOR_ADVANCE && preparePreLaunchEntering());
        _switch.setCanManualSwitchDirection((_preLaunch.getState() == STATE_BLOCK_FREE) || (_preLaunch.getState() == STATE_BLOCK_WAIT_FOR_ADVANCE) || (_preLaunch.getState() == STATE_BLOCK_WAIT_FOR_CLEAR));
        _preLaunch.setAdvanceFwdEnabled(_preLaunch.getState() == STATE_BLOCK_WAIT_FOR_ADVANCE && prepareTrimBrakesEntering());
        _trimBrakes.setAdvanceFwdEnabled(_trimBrakes.getState() == STATE_BLOCK_WAIT_FOR_ADVANCE && prepareStockEntering());
        _stock.setAdvanceFwdEnabled(_stock.getState() == STATE_BLOCK_WAIT_FOR_ADVANCE && prepareTableStockEntering());
        _tableStock.setAdvanceFwdEnabled(_tableStock.getState() == STATE_BLOCK_WAIT_FOR_ADVANCE && prepareStationEntering());
    }
    //</editor-fold>

    //<editor-fold desc="Blocks Entering Preparation">
    private bool preparePreLaunchEntering() {
        if (_preLaunch.getState() == STATE_BLOCK_FREE && _trimBrakes.getState() != STATE_BLOCK_APPROACHING) {
            if (_switch.getVisibleSwitchState() == 1) {
                return true;
            } else {
                if (_mode == AUTO_MODE) {
                    _switch.setSwitchDirection(1);
                }
            }
        }
        return false;
    }

    private bool prepareTrimBrakesEntering() {
        if (_trimBrakes.getState() == STATE_BLOCK_FREE) {
            return true;
        }
        return false;
    }

    private bool prepareStockEntering() {
        if (_stock.getState() == STATE_BLOCK_FREE) {
            return true;
        }
        return false;
    }

    private bool prepareTableStockEntering() {
        if (_tableStock.getState() == STATE_BLOCK_FREE) {
            return true;
        }
        return false;
    }

    private bool prepareStationEntering() {
        if (_station.getState() == STATE_BLOCK_FREE) {
            return true;
        }
        return false;
    }
    //</editor-fold>

    //<editor-fold desc="Blocks Processing">
    private void processStation() {
        Block stationBlock = _station;
        Block nextBlock = _preLaunch;
        switch (stationBlock.getState()) {
            case STATE_BLOCK_IN_STATION:
                if (stationBlock.getSection().isStationWaitingForClearBlock()) {
                    if (nextBlock.getState() == STATE_BLOCK_FREE) {
                        stationBlock.getSection().setStationNextBlockClear();
                    }
                } else if (stationBlock.getSection().isStationWaitingForAdvance()) {
                    if (_mode == MANUAL_BLOCK_MODE) {
                        if (nextBlock.getState() == STATE_BLOCK_FREE) {
                            stationBlock.setState(STATE_BLOCK_WAIT_FOR_ADVANCE);
                        } else {
                            stationBlock.getSection().setStationNextBlockOccupied();
                        }
                    } else {
                        if (nextBlock.getState() == STATE_BLOCK_FREE) {
                            if (preparePreLaunchEntering()) {
                                nextBlock.setState(STATE_BLOCK_APPROACHING);
                                stationBlock.setState(STATE_BLOCK_LEAVING);
                                stationBlock.getSection().setStationLeaving();
                            }
                        } else {
                            stationBlock.getSection().setStationNextBlockOccupied();
                        }
                    }
                }
                break;
            case STATE_BLOCK_WAIT_FOR_ADVANCE:
                if ((_mode != MANUAL_BLOCK_MODE) || !stationBlock.getSection().isStationWaitingForAdvance() || (nextBlock.getState() != STATE_BLOCK_FREE)) {
                    stationBlock.setState(STATE_BLOCK_IN_STATION);
                }
                break;
            case STATE_BLOCK_LEAVING:
                if (stationBlock.getNumberOfTrainsOnBlock() != 0) {
                    stationBlock.getSection().setBrakesOff();
                    stationBlock.getSection().setTransportsStandardFwdOn();
                    stationBlock.getSection().setTransportsLaunchFwdOn();
                } else {
                    stationBlock.setState(STATE_BLOCK_FREE);
                }
                break;
            case STATE_BLOCK_FREE:
                stationBlock.getSection().setTransportsOff();
                stationBlock.getSection().setBrakesOn();
                break;
            case STATE_BLOCK_APPROACHING:
                if (stationBlock.getSection().isTrainOnSection()) {
                    stationBlock.getSection().setStationEntering();
                    stationBlock.setState(STATE_BLOCK_IN_STATION);
                } else {
                    stationBlock.getSection().setBrakesOff();
                    stationBlock.getSection().setTransportsOff();
                }
                break;
        }
    }

    private void processPreLaunch() {
        switch (_preLaunch.getState()) {
            case STATE_BLOCK_APPROACHING:
                _preLaunch.getSection().setBrakesOff();
                _preLaunch.getSection().setTransportsOff();
                if (_preLaunch.getSection().isTrainOnSection()) {
                    _preLaunch.setState(STATE_BLOCK_BEFORE_TRIGGER);
                }
                break;
            case STATE_BLOCK_BEFORE_TRIGGER:
                _preLaunch.getSection().setBrakesTrim();
                _preLaunch.getSection().setTransportsStandardBwdDependingOnBrake();
                if (!_preLaunch.getSection().isTrainBehindBrakeTrigger()) {
                    _preLaunch.setState(STATE_BLOCK_BEHIND_TRIGGER);
                }
                break;
            case STATE_BLOCK_BEHIND_TRIGGER:
                _preLaunch.getSection().setBrakesOn();
                _preLaunch.getSection().setTransportsOff();
            {
                Train train = _preLaunch.getSection().getTrainOnSection();
                if (train.getSpeed() == 0) {
                    _preLaunchTime = 0;
                    _preLaunch.setState(STATE_BLOCK_WAITING);
                }
            }
            break;
            case STATE_BLOCK_WAITING:
                _preLaunch.getSection().setBrakesOn();
                _preLaunch.getSection().setTransportsOff();
                _preLaunchTime += sim.getCurSimulationTickSec();
                preparePreLaunchLeaving();
                if (_preLaunchTime >= _preLaunch.getSection().getBrakeWaitTime()) {
                    _preLaunch.setState(STATE_BLOCK_WAIT_FOR_CLEAR);
                }
                break;
            case STATE_BLOCK_WAIT_FOR_CLEAR:
                _preLaunch.getSection().setBrakesOn();
                _preLaunch.getSection().setTransportsOff();
                if (preparePreLaunchLeaving()) {
                    if (_mode == MANUAL_BLOCK_MODE) {
                        _preLaunch.setState(STATE_BLOCK_WAIT_FOR_ADVANCE);
                    } else {
                        if (prepareTrimBrakesEntering()) {
                            _trimBrakes.setState(STATE_BLOCK_APPROACHING);
                            _preLaunch.setState(STATE_BLOCK_LEAVING);
                        }
                    }
                }
                break;
            case STATE_BLOCK_WAIT_FOR_ADVANCE:
                _preLaunch.getSection().setBrakesOn();
                _preLaunch.getSection().setTransportsOff();
                if (!preparePreLaunchLeaving()) {
                    _preLaunch.setState(STATE_BLOCK_WAIT_FOR_CLEAR);
                }
                break;
            case STATE_BLOCK_LEAVING:
                if (_preLaunch.getSection().isTrainOnSection()) {
                    _preLaunch.getSection().setBrakesOff();
                    _preLaunch.getSection().setTransportsStandardFwdOn();
                    _preLaunch.getSection().setTransportsLaunchFwdOn();
                } else {
                    _preLaunch.getSection().setBrakesOn();
                    _preLaunch.getSection().setTransportsOff();
                }
                if (_preLaunch.getNumberOfTrainsOnBlock() == 0) {
                    _preLaunch.setState(STATE_BLOCK_FREE);
                }
                break;
            case STATE_BLOCK_FREE:
                _preLaunch.getSection().setBrakesOn();
                _preLaunch.getSection().setTransportsOff();
                break;
        }
    }

    private void processTrimBrakes() {
        switch (_trimBrakes.getState()) {
            case STATE_BLOCK_FREE:
                _trimBrakes.getSection().setTransportsOff();
                _trimBrakes.getSection().setBrakesOn();
                break;
            case STATE_BLOCK_APPROACHING:
                if (_trimBrakes.getSection().isTrainOnSection()) {
                    _trimBrakes.setState(STATE_BLOCK_BEFORE_TRIGGER);
                } else {
                    if (prepareStockEntering()) {
                        _trimBrakes.getSection().setBrakesOff();
                    } else {
                        _trimBrakes.getSection().setBrakesOn();
                    }
                    _trimBrakes.getSection().setTransportsOff();
                }
                break;
            case STATE_BLOCK_BEFORE_TRIGGER:
                prepareStockEntering();
                _trimBrakes.getSection().setBrakesTrim();
                _trimBrakes.getSection().setTransportsStandardFwdDependingOnBrake();
                if (_trimBrakes.getSection().isTrainBehindBrakeTrigger()) {
                    _trimBrakes.setState(STATE_BLOCK_BEHIND_TRIGGER);
                    _trimBrakesTime = 0;
                }
                break;
            case STATE_BLOCK_BEHIND_TRIGGER:
                if (_mode == MANUAL_BLOCK_MODE) {
                    if (prepareStockEntering()) {
                        _trimBrakes.setState(STATE_BLOCK_WAIT_FOR_ADVANCE);
                    } else {
                        _trimBrakes.getSection().setTransportsOff();
                        _trimBrakes.getSection().setBrakesOn();
                    }
                } else {
                    if (prepareStockEntering() && (_mode == AUTO_MODE) && (!_trimBrakes.getSection().isBrakeCompleteStop() || _trimBrakesTime > _trimBrakes.getSection().getBrakeWaitTime())) {
                        _stock.setState(STATE_BLOCK_APPROACHING);
                        _trimBrakes.setState(STATE_BLOCK_LEAVING);
                    } else {
                        if (_trimBrakes.getSection().getTrainOnSection().getSpeed() == 0)
                            _trimBrakesTime += sim.getCurSimulationTickSec();

                        _trimBrakes.getSection().setTransportsOff();
                        _trimBrakes.getSection().setBrakesOn();
                    }
                }
                break;
            case STATE_BLOCK_WAIT_FOR_ADVANCE:
                if (_mode == AUTO_MODE) {
                    _trimBrakes.setState(STATE_BLOCK_BEHIND_TRIGGER);
                } else {
                    if (!prepareStockEntering()) {
                        _trimBrakes.setState(STATE_BLOCK_BEHIND_TRIGGER);
                    } else {
                        _trimBrakes.getSection().setTransportsOff();
                        _trimBrakes.getSection().setBrakesOn();
                    }
                }
                break;
            case STATE_BLOCK_LEAVING:
                _trimBrakes.getSection().setBrakesOff();
                _trimBrakes.getSection().setTransportsStandardFwdOn();
                _trimBrakes.getSection().setTransportsLaunchFwdOn();
                preparePreLaunchEntering();
                if (_trimBrakes.getNumberOfTrainsOnBlock() == 0) {
                    _trimBrakes.setState(STATE_BLOCK_FREE);
                }
                break;
            case STATE_BLOCK_WAIT_FOR_CLEAR:
                if (_trimBrakes.getSection().isTrainBehindBrakeTrigger()) {
                    _trimBrakes.setState(STATE_BLOCK_BEHIND_TRIGGER);
                } else {
                    _trimBrakes.setState(STATE_BLOCK_BEFORE_TRIGGER);
                }
                break;
        }
    }

    private void processStock() {
        switch (_stock.getState()) {
            case STATE_BLOCK_FREE:
                _stock.getSection().setTransportsOff();
                _stock.getSection().setBrakesOn();
                break;
            case STATE_BLOCK_APPROACHING:
                if (_stock.getSection().isTrainOnSection()) {
                    _stock.setState(STATE_BLOCK_BEFORE_TRIGGER);
                } else {
                    if (prepareTableStockEntering()) {
                        _stock.getSection().setBrakesOff();
                    } else {
                        _stock.getSection().setBrakesOn();
                    }
                    _stock.getSection().setTransportsOff();
                }
                break;
            case STATE_BLOCK_BEFORE_TRIGGER:
                prepareTableStockEntering();
                _stock.getSection().setBrakesTrim();
                _stock.getSection().setTransportsStandardFwdDependingOnBrake();
                if (_stock.getSection().isTrainBehindBrakeTrigger()) {
                    _stock.setState(STATE_BLOCK_BEHIND_TRIGGER);
                    _stockTime = 0;
                }
                break;
            case STATE_BLOCK_BEHIND_TRIGGER:
                if (_mode == MANUAL_BLOCK_MODE) {
                    if (prepareTableStockEntering()) {
                        _stock.setState(STATE_BLOCK_WAIT_FOR_ADVANCE);
                    } else {
                        _stock.getSection().setTransportsOff();
                        _stock.getSection().setBrakesOn();
                    }
                } else {
                    if (prepareTableStockEntering() && (_mode == AUTO_MODE) && (!_stock.getSection().isBrakeCompleteStop() || _stockTime > _stock.getSection().getBrakeWaitTime())) {
                        _tableStock.setState(STATE_BLOCK_APPROACHING);
                        _stock.setState(STATE_BLOCK_LEAVING);
                    } else {
                        if (_stock.getSection().getTrainOnSection().getSpeed() == 0)
                            _stockTime += sim.getCurSimulationTickSec();

                        _stock.getSection().setTransportsOff();
                        _stock.getSection().setBrakesOn();
                    }
                }
                break;
            case STATE_BLOCK_WAIT_FOR_ADVANCE:
                if (_mode == AUTO_MODE) {
                    _stock.setState(STATE_BLOCK_BEHIND_TRIGGER);
                } else {
                    if (!prepareTableStockEntering()) {
                        _stock.setState(STATE_BLOCK_BEHIND_TRIGGER);
                    } else {
                        _stock.getSection().setTransportsOff();
                        _stock.getSection().setBrakesOn();
                    }
                }
                break;
            case STATE_BLOCK_LEAVING:
                _stock.getSection().setBrakesOff();
                _stock.getSection().setTransportsStandardFwdOn();
                _stock.getSection().setTransportsLaunchFwdOn();
                if (_stock.getNumberOfTrainsOnBlock() == 0) {
                    _stock.setState(STATE_BLOCK_FREE);
                }
                break;
            case STATE_BLOCK_WAIT_FOR_CLEAR:
                if (_stock.getSection().isTrainBehindBrakeTrigger()) {
                    _stock.setState(STATE_BLOCK_BEHIND_TRIGGER);
                } else {
                    _stock.setState(STATE_BLOCK_BEFORE_TRIGGER);
                }
                break;
        }
    }

    private void processTableStock() {
        switch (_tableStock.getState()) {
            case STATE_BLOCK_FREE:
                _tableStock.getSection().setTransportsOff();
                _tableStock.getSection().setBrakesOn();
                break;
            case STATE_BLOCK_APPROACHING:
                if (_tableStock.getSection().isTrainOnSection()) {
                    _tableStock.setState(STATE_BLOCK_BEFORE_TRIGGER);
                } else {
                    if (prepareStationEntering()) {
                        _tableStock.getSection().setBrakesOff();
                    } else {
                        _tableStock.getSection().setBrakesOn();
                    }
                    _tableStock.getSection().setTransportsOff();
                }
                break;
            case STATE_BLOCK_BEFORE_TRIGGER:
                prepareStationEntering();
                _tableStock.getSection().setBrakesTrim();
                _tableStock.getSection().setTransportsStandardFwdDependingOnBrake();
                if (_tableStock.getSection().isTrainBehindBrakeTrigger()) {
                    _tableStock.setState(STATE_BLOCK_BEHIND_TRIGGER);
                    _tableStockTime = 0;
                }
                break;
            case STATE_BLOCK_BEHIND_TRIGGER:
                if (_mode == MANUAL_BLOCK_MODE) {
                    if (prepareStationEntering()) {
                        _tableStock.setState(STATE_BLOCK_WAIT_FOR_ADVANCE);
                    } else {
                        _tableStock.getSection().setTransportsOff();
                        _tableStock.getSection().setBrakesOn();
                    }
                } else {
                    if (prepareStationEntering() && (_mode == AUTO_MODE) && (!_tableStock.getSection().isBrakeCompleteStop() || _tableStockTime > _tableStock.getSection().getBrakeWaitTime())) {
                        _station.setState(STATE_BLOCK_APPROACHING);
                        _tableStock.setState(STATE_BLOCK_LEAVING);
                    } else {
                        if (_tableStock.getSection().getTrainOnSection().getSpeed() == 0)
                            _tableStockTime += sim.getCurSimulationTickSec();

                        _tableStock.getSection().setTransportsOff();
                        _tableStock.getSection().setBrakesOn();
                    }
                }
                break;
            case STATE_BLOCK_WAIT_FOR_ADVANCE:
                if (_mode == AUTO_MODE) {
                    _tableStock.setState(STATE_BLOCK_BEHIND_TRIGGER);
                } else {
                    if (!prepareStationEntering()) {
                        _tableStock.setState(STATE_BLOCK_BEHIND_TRIGGER);
                    } else {
                        _tableStock.getSection().setTransportsOff();
                        _tableStock.getSection().setBrakesOn();
                    }
                }
                break;
            case STATE_BLOCK_LEAVING:
                _tableStock.getSection().setBrakesOff();
                _tableStock.getSection().setTransportsStandardFwdOn();
                _tableStock.getSection().setTransportsLaunchFwdOn();
                if (_tableStock.getNumberOfTrainsOnBlock() == 0) {
                    _tableStock.setState(STATE_BLOCK_FREE);
                }
                break;
            case STATE_BLOCK_WAIT_FOR_CLEAR:
                if (_tableStock.getSection().isTrainBehindBrakeTrigger()) {
                    _tableStock.setState(STATE_BLOCK_BEHIND_TRIGGER);
                } else {
                    _tableStock.setState(STATE_BLOCK_BEFORE_TRIGGER);
                }
                break;
        }
    }
    //</editor-fold>

    //<editor-fold desc="Blocks Leaving Preparation">
    private bool preparePreLaunchLeaving() {
        if (_switch.getVisibleSwitchState() == 0) {
            return true;
        } else {
            if (_mode == AUTO_MODE) {
                _switch.setSwitchDirection(0);
            }
        }
        return false;
    }
    //</editor-fold>

    //<editor-fold desc="Blocks States Management">
    private static bool checkAndSetInitialBlockState(Block block, String name) {
        if (block == null) {
            System.err.println(_script + ": '" + name + "' not found.");
            return false;
        }
        registerBlockStates(block);
        setInitialBlockState(block);
        return true;
    }

    private static void registerBlockStates(Block block) {
        block.registerState(STATE_BLOCK_FREE, "Free", Block.LAMP_OFF);
        block.registerState(STATE_BLOCK_APPROACHING, "Approaching", Block.LAMP_FLASHING);
        block.registerState(STATE_BLOCK_LEAVING, "Leaving", Block.LAMP_ON);
        block.registerState(STATE_BLOCK_BEFORE_TRIGGER, "Before Trigger", Block.LAMP_ON);
        block.registerState(STATE_BLOCK_BEHIND_TRIGGER, "Behind Trigger", Block.LAMP_ON);
        block.registerState(STATE_BLOCK_WAITING, "Waiting", Block.LAMP_ON);
        block.registerState(STATE_BLOCK_WAIT_FOR_CLEAR, "Waiting for Clear Block", Block.LAMP_ON);
        block.registerState(STATE_BLOCK_WAIT_FOR_ADVANCE, "Waiting for Advance", Block.LAMP_ON);
        block.registerState(STATE_BLOCK_IN_STATION, "In Station", Block.LAMP_ON);
    }

    private static void setInitialBlockState(Block block) {
        if (block.getNumberOfTrainsOnBlock() > 0) {
            if (block.getSection().iStation()) {
                block.setState(STATE_BLOCK_IN_STATION);
            } else {
                block.setState(STATE_BLOCK_WAIT_FOR_CLEAR);
            }
        } else {
            block.setState(STATE_BLOCK_FREE);
        }
    }
    //</editor-fold>
}

On est parti du Script Generator, mais ensuite je suis bien incapable d'expliquer ce que mon collègue a fait pour que ça fonctionne.
 
Ok. Parce qu'en gros j'ai a peu près la même volonté donc le même problème, je m'explique :

Le train part de la station en avant sur une section launch, celle ci le fait accéléré, il repasse sur cette section en arrière, puis sur la station, toujours en arrière, puis aiguillage et monte sur une fleche. Il repart ainsi en marche avant sur l'aguillage, station et launch puis fait le parcours en marche avant. Arrivé sur les final brake, l'aguillage doit changer de position pour remettre le train en station.

Et c'est la merde.



Voici une image sur paint.