include "defaultlocomotivecabin.gs" //V100-Führerstandsskript von Partyman79 //Anleihen, Hilfen bzw. syntaktische Grundlagenerkenntnisse u.a. von Josef_Pav, coerni, Andi06, Phil_C und weitere //Vielen Dank für unverschlüsselte Skripte in der Trainz-Welt class V100CabinData isclass CabinData { // Statusvariablen definieren public bool wischer_links_vorn_started = false; public bool wischer_links_hinten_started = false; public bool wischer_rechts_vorn_started = false; public bool wischer_rechts_hinten_started = false; public ControlSettingsManager ctrlManager = new ControlSettingsManager(); }; class V100Cabin isclass DefaultLocomotiveCabin { float gametime = 0; float normalizedgametime; float cablight = 1; thread void Sifa(void); thread void Sifatastewait(void); thread void Sifatasteanim(void); thread void Huptaste(void); // thread void Huptasteanim(void); thread void DCC(void); thread void DCC2(void); thread void DCC3(void); thread void Animvariabel(void); thread void AutopilotBehavior(void); thread void AnimFrame(void); CabinControl regulator_lever; //!< Regulator/throttle lever. CabinControl reverser_lever; //!< Reverser lever. CabinControl speedometer; //!< Speed indicator. CabinControl motor; //!< Hauptschalter CabinControl sifataster; CabinControl horn; //!< Horn float Throttlestatus = 0; float Throttle = 0; bool Brakestatus = true; float Brake = true; float Sifatastewait = 0; float Speed = 0; bool Sifataste = false; int Drivermode = 0; bool SifaEin = false; bool usesifa = true; bool sifawarnung = false; float KISifa = 0; Browser SifaBrowser; int KIFahrt = false; bool cabanimstarted = false; int Hornstatus = 0; bool DCC = false; bool Cabin = false; bool Animlow = false; int AnimationFrameRandom; bool Keyfromscript = false; CabinControl wischer_links; CabinControl wischer_rechts; bool Direction = false; bool Hauptschalter = false; bool Hauptschalterinfo = false; bool wischer_links_vorn_started = false; bool wischer_links_hinten_started = false; bool wischer_rechts_vorn_started = false; bool wischer_rechts_hinten_started = false; bool wischer_links_vorn_waitonendofframe = false; bool wischer_links_hinten_waitonendofframe = false; bool wischer_rechts_vorn_waitonendofframe = false; bool wischer_rechts_hinten_waitonendofframe = false; object myLoco; //! Attach this cabin to a game object (i.e. a locomotive). // // Param: obj Game object to attach this cabin to (usually a Locomotive). // void Attach(GameObject obj) { inherited(obj); Hauptschalterinfo = false; // get cabin data CabinData cd = loco.GetCabinData(); if(cd) { // reset the controls from saved values V100CabinData ddcd = castcd; float value = 0.0; // Wischerschalter und Wischeranimation wieder herstellen - links if ((ddcd.wischer_links_vorn_started)and(loco.GetDirectionRelativeToTrain())) { value = 1.0; SetMeshAnimationSpeed("scheibenwischerlinks", 0.7); StartMeshAnimationLoop("scheibenwischerlinks"); } if ((ddcd.wischer_links_hinten_started)and(!loco.GetDirectionRelativeToTrain())) { value = 1.0; SetMeshAnimationSpeed("scheibenwischerlinks", 0.7); StartMeshAnimationLoop("scheibenwischerlinks"); } wischer_links.SetValue(value); // Wischerschalter und Wischeranimation wieder herstellen - rechts if ((ddcd.wischer_rechts_vorn_started)and(loco.GetDirectionRelativeToTrain())) { value = 1.0; SetMeshAnimationSpeed("scheibenwischerrechts", 0.7); StartMeshAnimationLoop("scheibenwischerrechts"); } if ((ddcd.wischer_rechts_hinten_started)and(!loco.GetDirectionRelativeToTrain())) { value = 1.0; SetMeshAnimationSpeed("scheibenwischerrechts", 0.7); StartMeshAnimationLoop("scheibenwischerrechts"); } wischer_rechts.SetValue(value); // Cabanimation wieder herstellen Speed = Math.Fabs(loco.GetVelocity()); StartMeshAnimationLoop("default"); if(!Animlow) { SetMeshAnimationSpeed("default", (Speed/74.565)/2); } else { SetMeshAnimationSpeed("default", (Speed/74.565)/3.5); } wischer_links_vorn_started = ddcd.wischer_links_vorn_started; wischer_links_hinten_started = ddcd.wischer_links_hinten_started; wischer_rechts_vorn_started = ddcd.wischer_rechts_vorn_started; wischer_rechts_hinten_started = ddcd.wischer_rechts_hinten_started; } else { V100CabinData ddcd = new V100CabinData(); loco.SetCabinData(ddcd); Speed = Math.Fabs(loco.GetVelocity()); StartMeshAnimationLoop("default"); SetMeshAnimationSpeed("default", (Speed/74.565)); } } public void Update(void) { inherited(); if((!Hauptschalter)and(Hauptschalterinfo)) { Train train = loco.GetMyTrain(); train.SetDCCThrottle(0); train.SetReverser(1); } if (horn) horn.SetValue(Hornstatus); Train train = loco.GetMyTrain(); Drivermode = train.GetAutopilotMode(); // Interface.Print("Drivermode "+Drivermode); // Wenn Schaltrad bedient - informiere die Lok, diese spielt Sound Throttle = Math.Fabs(train.GetDCCThrottle()); if((Throttlestatus != Throttle)and(Math.Fabs(Throttle-Throttlestatus) >= 0.125)) { PostMessage(loco,"Schaltrad","play",0.0f); Throttlestatus = Throttle; } Speed = Math.Fabs(loco.GetVelocity()); // Damit Tacho in beiden Führerständen in allen Fahrtrichtungen funktioniert, nimm gerade abgefragten // Absolutwert der Geschwindigkeit für den Tachometer (Variable Speed) if (speedometer) { speedometer.SetValue(Speed); } // Passe Cabanimation an Geschwindigkeit an StartMeshAnimationLoop("default"); if(!Animlow) { SetMeshAnimationSpeed("default", (Speed/74.565)/2); } else { SetMeshAnimationSpeed("default", (Speed/74.565)/3.5); } // wurde Bremse bedient, dann informiere Lok, diese spielt Sound Brake = train.GetTrainBrakes(); if((Brakestatus)and(Brake == 0)) { Brakestatus = false; PostMessage(loco,"BremseLoesen","play",0.0f); } if((!Brakestatus)and(Brake > 0)and(Brake != 5)) { Brakestatus = true; PostMessage(loco,"BremseAnlegen","play",0.0f); } } void UserSetControl(CabinControl p_control, float p_value) { if(((Drivermode == 1)or(Drivermode == 3))and(!Keyfromscript)) { Cabin = true; } V100CabinData cd = castloco.GetCabinData(); if (p_control == reverser_lever) { if(!Hauptschalter) { PostMessage(loco,"ThrottleNull","play",0.0f); } } if (p_control == horn) { PostMessage(me, "Huptasteanim", "on", 0.0f); } // Wischerschalter links bedient ? if (p_control == wischer_links) { // Wenn Animation links noch nicht gestartet if(p_value > 0.5) { // dann starten SetMeshAnimationSpeed("scheibenwischerlinks", 0.7); StartMeshAnimationLoop("scheibenwischerlinks"); // Richtung des Cabs bestimmen und in Variable speichern Direction = loco.GetDirectionRelativeToTrain(); if(Direction) { cd.wischer_links_vorn_started = true; wischer_links_vorn_started = true; } else { cd.wischer_links_hinten_started = true; wischer_links_hinten_started = true; } // informiere Lok über Start der Wischeranimation PostMessage(loco,"startwischerlinks","play",0.0f); } // Wenn Animation links vorn gestartet if(((cd.wischer_links_vorn_started)or(wischer_links_vorn_started))and(p_value < 0.5)and(loco.GetDirectionRelativeToTrain())) { // in Variable speichern cd.wischer_links_vorn_started = false; wischer_links_vorn_started = false; // informiere Lok über Stop der Wischeranimation if(!wischer_links_vorn_waitonendofframe) { PostMessage(loco,"stopwischerlinks","play",0.0f); } wischer_links_vorn_waitonendofframe = false; } // Wenn Animation links hinten gestartet if(((cd.wischer_links_hinten_started)or(wischer_links_hinten_started))and(p_value < 0.5)and(!loco.GetDirectionRelativeToTrain())) { // in Variable speichern cd.wischer_links_hinten_started = false; wischer_links_hinten_started = false; // informiere Lok über Stop der Wischeranimation if(!wischer_links_hinten_waitonendofframe) { PostMessage(loco,"stopwischerlinks","play",0.0f); } wischer_links_hinten_waitonendofframe = false; } } // Vorgehensweise für den Wischer rechts analog des linken if (p_control == wischer_rechts) { if(p_value > 0.5) { SetMeshAnimationSpeed("scheibenwischerrechts", 0.7); StartMeshAnimationLoop("scheibenwischerrechts"); Direction = loco.GetDirectionRelativeToTrain(); if(Direction) { cd.wischer_rechts_vorn_started = true; wischer_rechts_vorn_started = true; } else { cd.wischer_rechts_hinten_started = true; wischer_rechts_hinten_started = true; } PostMessage(loco,"startwischerrechts","play",0.0f); } if(((cd.wischer_rechts_vorn_started)or(wischer_rechts_vorn_started))and(p_value < 0.5)and(loco.GetDirectionRelativeToTrain())) { cd.wischer_rechts_vorn_started = false; wischer_rechts_vorn_started = false; if(!wischer_rechts_vorn_waitonendofframe) { PostMessage(loco,"stopwischerrechts","play",0.0f); } wischer_rechts_vorn_waitonendofframe = false; } if(((cd.wischer_rechts_hinten_started)or(wischer_rechts_hinten_started))and(p_value < 0.5)and(!loco.GetDirectionRelativeToTrain())) { cd.wischer_rechts_hinten_started = false; wischer_rechts_hinten_started = false; if(!wischer_rechts_hinten_waitonendofframe) { PostMessage(loco,"stopwischerrechts","play",0.0f); } wischer_rechts_hinten_waitonendofframe = false; } } if (p_control == motor) { // ... der Hauptschalter wurde bedient if(p_value > 0) { Hauptschalter = true; SetMeshVisible("motorlampe_aus", true, 0.1f); SetMeshVisible("motorlampe_ein", false, 0.15f); } else { Hauptschalter = false; SetMeshVisible("motorlampe_ein", true, 0.1f); SetMeshVisible("motorlampe_aus", false, 0.15f); } PostMessage(loco,"Hauptschaltertoloco","play",0.0f); } if (p_control == sifataster) { Sifataste = true; Sifatasteanim(); } inherited(p_control, p_value); Keyfromscript = false; } void UserPressKey(string s) { Cabin = true; Train train = loco.GetMyTrain(); // wenn Leertaste gedrückt ... if (s == "shovel-coal") { // ... dann wurde der Sifataster bedient Sifataste = true; sifataster.SetValue(1); Sifatasteanim(); } // wenn "Zahlenblock-1" gedrückt ... if (s == "firebox-door-toggle") { // ... dann wurde der Hauptschalter bedient if(motor.GetValue() == 0) { Hauptschalter = true; motor.SetValue(1); SetMeshVisible("motorlampe_aus", true, 0.1f); SetMeshVisible("motorlampe_ein", false, 0.15f); } else { Hauptschalter = false; motor.SetValue(0); SetMeshVisible("motorlampe_ein", true, 0.1f); SetMeshVisible("motorlampe_aus", false, 0.15f); } PostMessage(loco,"Hauptschaltertoloco","play",0.0f); } if (s == "steam-regulator-up") { if(!Hauptschalter) { PostMessage(loco,"ThrottleNull","play",0.0f); } } if (s == "steam-regulator-down") { if(!Hauptschalter) { PostMessage(loco,"ThrottleNull","play",0.0f); } } if (s == "train_cabin_aws_isolate") { Direction = loco.GetDirectionRelativeToTrain(); if(Direction) { if(!wischer_links_vorn_started) { UserSetControl(wischer_links, 1); wischer_links.SetValue(1); } else { UserSetControl(wischer_links, 0); wischer_links.SetValue(0); } } else { if(!wischer_links_hinten_started) { UserSetControl(wischer_links, 1); wischer_links.SetValue(1); } else { UserSetControl(wischer_links, 0); wischer_links.SetValue(0); } } } if (s == "train_cabin_aws_activate") { Direction = loco.GetDirectionRelativeToTrain(); if(Direction) { if(!wischer_rechts_vorn_started) { UserSetControl(wischer_rechts, 1); wischer_rechts.SetValue(1); } else { UserSetControl(wischer_rechts, 0); wischer_rechts.SetValue(0); } } else { if(!wischer_rechts_hinten_started) { UserSetControl(wischer_rechts, 1); wischer_rechts.SetValue(1); } else { UserSetControl(wischer_rechts, 0); wischer_rechts.SetValue(0); } } } inherited(s); } public void Init(void) { inherited(); Sifa(); Huptaste(); DCC(); DCC2(); DCC3(); AutopilotBehavior(); Animvariabel(); AnimFrame(); regulator_lever = GetNamedControl("regulator"); reverser_lever = GetNamedControl("reverser_lever"); speedometer = GetNamedControl("speedo_needle"); motor = GetNamedControl("motor"); horn = GetNamedControl("horn"); sifataster = GetNamedControl("sifataster"); wischer_links = GetNamedControl("wischer_links"); wischer_rechts = GetNamedControl("wischer_rechts"); StartMeshAnimationLoop("default"); SetMeshAnimationSpeed("default", 0); // Cab teilt der Lok mit, dass es da ist und welchen Namen es hat PostMessage(loco, "ichbins", "ichbins", 0.0f); // Cab erhält Info von der Lok ob sie eingeschaltet ist AddHandler(me,"Hauptschalter", null, "Hauptschalter"); // Cab empfängt aktuellen Frame der einzelnen Scheibenwischeranimation AddHandler(me,"scheibenwischerlinks_vorn", null, "scheibenwischerlinks_vorn"); AddHandler(me,"scheibenwischerlinks_vorn_anim", null, "scheibenwischerlinks_vorn_anim"); AddHandler(me,"scheibenwischerrechts_vorn", null, "scheibenwischerrechts_vorn"); AddHandler(me,"scheibenwischerrechts_vorn_anim", null, "scheibenwischerrechts_vorn_anim"); AddHandler(me,"scheibenwischerlinks_hinten", null, "scheibenwischerlinks_hinten"); AddHandler(me,"scheibenwischerlinks_hinten_anim", null, "scheibenwischerlinks_hinten_anim"); AddHandler(me,"scheibenwischerrechts_hinten", null, "scheibenwischerrechts_hinten"); AddHandler(me,"scheibenwischerrechts_hinten_anim", null, "scheibenwischerrechts_hinten_anim"); AddHandler(me,"scheibenwischerlinks_vorn_stop", null, "scheibenwischerlinks_vorn_stop"); AddHandler(me,"scheibenwischerrechts_vorn_stop", null, "scheibenwischerrechts_vorn_stop"); AddHandler(me,"scheibenwischerlinks_hinten_stop", null, "scheibenwischerlinks_hinten_stop"); AddHandler(me,"scheibenwischerrechts_hinten_stop", null, "scheibenwischerrechts_hinten_stop"); AddHandler(me, "Cablight", null, "Cablight"); AddHandler(me, "Huptasteanim", null, "Huptasteanim"); PostMessage(me, "Cablight", "", 0.1f); // Cab empfängt Info über DCC-/Kabinenmodus AddHandler(me,"DCC", null, "DCCvonLok"); // Cab empfängt Status der Sifanutzung des Spielers AddHandler(me,"usesifa", null, "usesifa"); // Cab empfängt Status, ob der Spieler eine optische Sifa-Hilfe wünscht AddHandler(me,"sifawarnung", null, "sifawarnung"); // Cab empfängt Status, ob der Spieler das Sanden eingeschaltet hat AddHandler(me,"sanding", null, "sandschalter"); } // Cab erhält Info von der Lok ob sie eingeschaltet ist void Hauptschalter(Message msg) { if(msg.minor == "an") { Hauptschalter = true; motor.SetValue(1); SetMeshVisible("motorlampe_aus", true, 0.1f); SetMeshVisible("motorlampe_ein", false, 0.15f); } else { Hauptschalter = false; motor.SetValue(0); SetMeshVisible("motorlampe_ein", true, 0.1f); SetMeshVisible("motorlampe_aus", false, 0.15f); } Hauptschalterinfo = true; } // Cab empfängt aktuellen Frame der einzelnen Scheibenwischeranimation void scheibenwischerlinks_vorn(Message msg) { Direction = loco.GetDirectionRelativeToTrain(); // Frame der Animation wird nur verarbeitet, wenn der Führerstand entsprechend der Fahrtrichtung aktiv ist if(Direction) SetMeshAnimationFrame("scheibenwischerlinks", Str.ToFloat(msg.minor)); } void scheibenwischerrechts_vorn(Message msg) { Direction = loco.GetDirectionRelativeToTrain(); if(Direction) SetMeshAnimationFrame("scheibenwischerrechts", Str.ToFloat(msg.minor)); } void scheibenwischerlinks_hinten(Message msg) { Direction = loco.GetDirectionRelativeToTrain(); if(!Direction) SetMeshAnimationFrame("scheibenwischerlinks", Str.ToFloat(msg.minor)); } void scheibenwischerrechts_hinten(Message msg) { Direction = loco.GetDirectionRelativeToTrain(); if(!Direction) SetMeshAnimationFrame("scheibenwischerrechts", Str.ToFloat(msg.minor)); } // Lok teilt mit, ob Scheibenwischer vorn links läuft void scheibenwischerlinks_vorn_anim(Message msg) { Direction = loco.GetDirectionRelativeToTrain(); // wenn das Cab "nach vorn schaut" und der Scheibenwischer an der Lok links vorn läuft, if(Direction) { if(msg.minor == "true") { // in Variable speichern und entsprechende Schalter bedienen, dort wird auch die Animation gestartet wischer_links_vorn_started = true; Keyfromscript = true; UserSetControl(wischer_links, 1); wischer_links.SetValue(1); } // wenn der Scheibenwischer an der Lok (!) links vorn NICHT läuft, if(msg.minor == "false") { // in Variable speichern und Schalter bedienen, dort auch Behandlung der Animation // in Zusammenarbeit mit der Lok wischer_links_vorn_started = false; Keyfromscript = true; UserSetControl(wischer_links, 0); wischer_links.SetValue(0); } // die Lok hat die Scheibenwischer punktgenau gestoppt und informiert das Cab if(msg.minor == "stop") { StopMeshAnimation("scheibenwischerlinks"); SetMeshAnimationFrame("scheibenwischerlinks", 0); SetMeshAnimationSpeed("scheibenwischerlinks", 0.0); wischer_links_vorn_waitonendofframe = true; wischer_links_vorn_started = true; Keyfromscript = true; UserSetControl(wischer_links, 0); wischer_links.SetValue(0); } } } void scheibenwischerlinks_hinten_anim(Message msg) { Direction = loco.GetDirectionRelativeToTrain(); if(!Direction) { if(msg.minor == "true") { wischer_links_hinten_started = true; Keyfromscript = true; UserSetControl(wischer_links, 1); wischer_links.SetValue(1); } if(msg.minor == "false") { wischer_links_hinten_started = false; Keyfromscript = true; UserSetControl(wischer_links, 0); wischer_links.SetValue(0); } if(msg.minor == "stop") { StopMeshAnimation("scheibenwischerlinks"); SetMeshAnimationFrame("scheibenwischerlinks", 0); SetMeshAnimationSpeed("scheibenwischerlinks", 0.0); wischer_links_hinten_waitonendofframe = true; wischer_links_hinten_started = true; Keyfromscript = true; UserSetControl(wischer_links, 0); wischer_links.SetValue(0); } } } void scheibenwischerrechts_vorn_anim(Message msg) { Direction = loco.GetDirectionRelativeToTrain(); if(Direction) { if(msg.minor == "true") { wischer_rechts_vorn_started = true; Keyfromscript = true; UserSetControl(wischer_rechts, 1); wischer_rechts.SetValue(1); } if(msg.minor == "false") { wischer_rechts_vorn_started = false; Keyfromscript = true; UserSetControl(wischer_rechts, 0); wischer_rechts.SetValue(0); } if(msg.minor == "stop") { StopMeshAnimation("scheibenwischerrechts"); SetMeshAnimationFrame("scheibenwischerrechts", 0); SetMeshAnimationSpeed("scheibenwischerrechts", 0.0); wischer_rechts_vorn_waitonendofframe = true; wischer_rechts_vorn_started = true; Keyfromscript = true; UserSetControl(wischer_rechts, 0); wischer_rechts.SetValue(0); } } } void scheibenwischerrechts_hinten_anim(Message msg) { Direction = loco.GetDirectionRelativeToTrain(); if(!Direction) { if(msg.minor == "true") { wischer_rechts_hinten_started = true; Keyfromscript = true; UserSetControl(wischer_rechts, 1); wischer_rechts.SetValue(1); } if(msg.minor == "false") { wischer_rechts_hinten_started = false; Keyfromscript = true; UserSetControl(wischer_rechts, 0); wischer_rechts.SetValue(0); } if(msg.minor == "stop") { StopMeshAnimation("scheibenwischerrechts"); SetMeshAnimationFrame("scheibenwischerrechts", 0); SetMeshAnimationSpeed("scheibenwischerrechts", 0.0); wischer_rechts_hinten_waitonendofframe = true; wischer_rechts_hinten_started = true; Keyfromscript = true; UserSetControl(wischer_rechts, 0); wischer_rechts.SetValue(0); } } } void scheibenwischerlinks_vorn_stop(Message msg) { Direction = loco.GetDirectionRelativeToTrain(); if(Direction) { StopMeshAnimation("scheibenwischerlinks"); SetMeshAnimationFrame("scheibenwischerlinks", 0); SetMeshAnimationSpeed("scheibenwischerlinks", 0.0); } } void scheibenwischerlinks_hinten_stop(Message msg) { Direction = loco.GetDirectionRelativeToTrain(); if(!Direction) { StopMeshAnimation("scheibenwischerlinks"); SetMeshAnimationFrame("scheibenwischerlinks", 0); SetMeshAnimationSpeed("scheibenwischerlinks", 0.0); } } void scheibenwischerrechts_vorn_stop(Message msg) { Direction = loco.GetDirectionRelativeToTrain(); if(Direction) { StopMeshAnimation("scheibenwischerrechts"); SetMeshAnimationFrame("scheibenwischerrechts", 0); SetMeshAnimationSpeed("scheibenwischerrechts", 0.0); } } void scheibenwischerrechts_hinten_stop(Message msg) { Direction = loco.GetDirectionRelativeToTrain(); if(!Direction) { StopMeshAnimation("scheibenwischerrechts"); SetMeshAnimationFrame("scheibenwischerrechts", 0); SetMeshAnimationSpeed("scheibenwischerrechts", 0.0); } } void DCCvonLok(Message msg) { if(msg.minor == "true") { DCC = true; } } void usesifa(Message msg) { if(msg.minor == "false") { usesifa = false; } if(msg.minor == "true") { usesifa = true; } } void sifawarnung(Message msg) { if(msg.minor == "false") { sifawarnung = false; } if(msg.minor == "true") { sifawarnung = true; } } void sandschalter(Message msg) { if(msg.minor == "false") { SetMeshAnimationState("sand", false); } if(msg.minor == "true") { SetMeshAnimationState("sand", true); } } thread void Sifatastewait(void) { if(SifaEin) { SetMeshVisible("sifalampe_ein", true, 0.1f); SetMeshVisible("sifalampe_aus", false, 0.15f); PostMessage(loco,"Sifastart","play",0.0f); SifaEin = false; } while(Sifatastewait < 40) { if((((Drivermode == 2)or(Drivermode == 4))and(Sifatastewait >= KISifa))or((DCC)and((Sifatastewait/KISifa)*2 >= 1)and((Drivermode == 1)or(Drivermode == 3)))) { Sifataste = true; sifataster.SetValue(1); Sifatasteanim(); } if((Sifatastewait == 19)and(sifawarnung)) { SifaBrowser = Constructors.NewBrowser(); SifaBrowser.SetWindowRect(200, 200, 370, 300); string paramOutput = ""; paramOutput = paramOutput + "SIFA !
"; paramOutput = paramOutput + "(Leertaste)"; paramOutput = paramOutput + ""; SifaBrowser.LoadHTMLString(paramOutput); } Sifatastewait = Sifatastewait + 1; Train train = loco.GetMyTrain(); Speed = Math.Fabs(train.GetVelocity()); if((Sifataste)or(Speed < 0.1)) { Sifataste = true; SifaBrowser = null; break; } Sleep(0.2); } if(Sifataste) { PostMessage(loco,"Sifastop","play",0.0f); SetMeshVisible("sifalampe_aus", true, 0.1f); SetMeshVisible("sifalampe_ein", false, 0.15f); Sifataste = false; Sifatastewait = 0; } else { while(!Sifataste) { PostMessage(loco,"Sifaemergency","play",0.0f); Sleep(1); } PostMessage(loco,"Sifastop","play",0.0f); PostMessage(loco,"Sifaemergencystop","play",0.0f); SetMeshVisible("sifalampe_aus", true, 0.1f); SetMeshVisible("sifalampe_ein", false, 0.15f); SifaBrowser = null; Sifataste = false; Sifatastewait = 0; } Sifa(); } thread void Sifa(void) { int WaitSifa = 0; WaitSifa = Math.Rand(30,90); Sleep(WaitSifa); Sifataste = false; Train train = loco.GetMyTrain(); Drivermode = train.GetAutopilotMode(); Speed = Math.Fabs(train.GetVelocity()); if(Speed > 0.1) { SifaEin = true; } else { Sifataste = true; } if(usesifa) { SifaEin = true; } else { Sifataste = true; } KISifa = Math.Rand(10,18); Sifatastewait(); } thread void Sifatasteanim(void) { Sleep(0.7); sifataster.SetValue(0); } void Huptasteanim(Message msg) { if(msg.minor == "on" and Hornstatus == 0) { if(horn.GetValue() == 0) { horn.SetValue(1); } Hornstatus = 1; loco.SetEngineSetting("horn", Hornstatus); PostMessage(me, "Huptasteanim", "off", 1.0f); } if(msg.minor == "off" and Hornstatus == 1) { horn.SetValue(0); Hornstatus = 0; loco.SetEngineSetting("horn", Hornstatus); } } thread void Huptaste(void) { wait() { on "Train", "NotifyHorn": PostMessage(me, "Huptasteanim", "on", 0.0f); continue; } } thread void DCC(void) { wait() { on "Browser-URL", "live://button/pants": if(!DCC) { PostMessage(loco,"DCCtoloco","play",0.0f); DCC = true; } PostMessage(loco,"Hauptschaltertoloco","play",0.0f); if(!Hauptschalter) { Hauptschalter = true; SetMeshVisible("motorlampe_aus", true, 0.1f); SetMeshVisible("motorlampe_ein", false, 0.15f); motor.SetValue(1); } else { Hauptschalter = false; SetMeshVisible("motorlampe_ein", true, 0.1f); SetMeshVisible("motorlampe_aus", false, 0.15f); motor.SetValue(0); Train train = loco.GetMyTrain(); } continue; } } thread void DCC2(void) { wait() { on "Train", "NotifyPantographs": if(!Cabin) { Sleep(0.2); if(!Cabin) { if(!DCC) { DCC = true; PostMessage(loco,"DCCtoloco","play",0.0f); } PostMessage(loco,"Hauptschaltertoloco","play",0.0f); if(!Hauptschalter) { Hauptschalter = true; motor.SetValue(1); motor.SetValue(1); motor.SetValue(1); SetMeshVisible("motorlampe_aus", true, 0.1f); SetMeshVisible("motorlampe_ein", false, 0.15f); motor.SetValue(1); } else { Hauptschalter = false; motor.SetValue(0); motor.SetValue(0); motor.SetValue(0); SetMeshVisible("motorlampe_ein", true, 0.1f); SetMeshVisible("motorlampe_aus", false, 0.15f); motor.SetValue(0); Train train = loco.GetMyTrain(); train.SetPantographState(0); } } } if(!Cabin) { continue; } else { break; } } } thread void DCC3(void) { wait() { on "Browser-URL", "live://DCC": DCC = true; PostMessage(loco,"DCCtoloco","play",0.0f); break; } } thread void AutopilotBehavior(void) { wait() { on "AutopilotBehavior", "": Sleep(0.5); Cabin = false; continue; } } thread void Animvariabel(void) { Sleep(Math.Rand(0,2)); Animlow = true; Sleep(Math.Rand(5,30)); Animlow = false; Animvariabel(); } thread void AnimFrame(void) { AnimationFrameRandom = Math.Rand(0,4); switch(AnimationFrameRandom) { case 0: SetMeshAnimationFrame("Default", 0, 0); break; case 1: SetMeshAnimationFrame("Default", 11, 0); break; case 2: SetMeshAnimationFrame("Default", 21, 0); break; case 3: SetMeshAnimationFrame("Default", 27, 0); break; case 4: SetMeshAnimationFrame("Default", 33, 0); break; default: SetMeshAnimationFrame("Default", 0, 0); } wait() { on "Animation-Event", "cab": AnimationFrameRandom = Math.Rand(0,4); switch(AnimationFrameRandom) { case 0: SetMeshAnimationFrame("Default", 0, 0); break; case 1: SetMeshAnimationFrame("Default", 11, 0); break; case 2: SetMeshAnimationFrame("Default", 21, 0); break; case 3: SetMeshAnimationFrame("Default", 27, 0); break; case 4: SetMeshAnimationFrame("Default", 33, 0); break; default: SetMeshAnimationFrame("Default", 0, 0); } continue; } } // Passe Cabhelligkeit an Tageszeit an void Cablight(Message msg) { gametime = World.GetGameTime(); if (gametime < 0.5) { normalizedgametime = (1 - gametime - 0.5) * 2; } else { normalizedgametime = (gametime - 0.5) *2; } if (normalizedgametime < 0.4) SetCabLightIntensity (0.2); if (normalizedgametime > 0.55) SetCabLightIntensity (1); if (normalizedgametime > 0.4 and normalizedgametime < 0.55) SetCabLightIntensity (0.2 + ( normalizedgametime - 0.4 ) * ( normalizedgametime / 0.103125 ) ); PostMessage(me, "Cablight", "", 5.0f); } };