I undestand that there is written: When elec and station brake is 1 then can be made next script... I need to add one more term for opening the door... Concertly, like if one button is pressed you have not to have elec and station brake ON... But when this button os off you have to have your elec and station brake ON :-)
I hope that you undestond me
krtz07
Anzahl der Beiträge : 413 Anmeldedatum : 10.09.09 Alter : 39 Ort : Philadelphia PA
Thema: Re: Rewrite function for OMSI script language Mi 9 Nov - 2:48
kosakkosak schrieb:
Hello, can someone tall me how to rewrite for example this PHP function to OMSI sctipt language?
I undestand that there is written: When elec and station brake is 1 then can be made next script... I need to add one more term for opening the door... Concertly, like if one button is pressed you have not to have elec and station brake ON... But when this button os off you have to have your elec and station brake ON :-)
I hope that you undestond me
So what new button are you trying to create? also did you map it to the bus already?
kosakkosak
Anzahl der Beiträge : 163 Anmeldedatum : 14.03.11
Thema: Re: Rewrite function for OMSI script language Mi 9 Nov - 8:15
I have ready my new button yet. Only thing what I need is that I have to add new requirement. Look, now you can open the door only with station brake ON... I need to add my new button to this script which means, when my new button is ON, you can open the door without station brake ( BREMSE_HALTE). But if my new button is OFF, you have to use station brake..
krtz07
Anzahl der Beiträge : 413 Anmeldedatum : 10.09.09 Alter : 39 Ort : Philadelphia PA
Thema: Re: Rewrite function for OMSI script language Mi 9 Nov - 14:41
Ah ok, just want to make sure that we are on the right track. From the existing script,
The code uses something which is called reversed polished notation, every operator goes behind the numbers or variables. If you see two operators conjured, like shown above, this means, stop brake is not activated. The "!" donates the is not, if the variable is not on, then it would return an is not. The two && donates, well you need to read it backwards. So in PHP terms this statement would be more like
if ($elec_busbar_main == 1) && ($bremse_halte_sw == 1) && ($door_needs_stopbrake != 1) { your desire object };
Back in the case of M&R script if you want to add an button, it would be somewhere along the lines of
Thema: Re: Rewrite function for OMSI script language Mi 9 Nov - 15:30
You don't understond me
Look, now you write
if ($newbutton == 1) && ($elec_busbar_main == 1) && ($bremse_halte_sw == 1) && ($door_needs_stopbrake != 1) { open the doort };
But I need a fuction like this
If new button is 1 open the door... If the new button is 0 make it like a normal system like
if ($elec_busbar_main == 1) && ($bremse_halte_sw == 1) && ($door_needs_stopbrake != 1) { open the doort };
I have not write any PHP code for a long time, but I think that I need it like:
Code:
if ($newbutton == 1) { open the doort }; elseif ($elec_busbar_main == 1) && ($bremse_halte_sw == 1) && ($door_needs_stopbrake != 1) { open the doort };
krtz07
Anzahl der Beiträge : 413 Anmeldedatum : 10.09.09 Alter : 39 Ort : Philadelphia PA
Thema: Re: Rewrite function for OMSI script language Do 10 Nov - 2:31
Ah ok so an override switch of sort... (L.Lyouroverrideswitch) {if} (L.L.elec_busbar_main) (L.L.bremse_halte) (C.L.door_needs_stopbrake) && && {if} (M.L.trg_bus_doorfront1) {endif}
{endif} 1 (S.L.cockpit_tuertaster2)
I still do not understand completely but thats how you do this switch must be set in order for the other switches to work. If you need an else switch, just do just that.
kosakkosak
Anzahl der Beiträge : 163 Anmeldedatum : 14.03.11
Thema: Re: Rewrite function for OMSI script language Do 10 Nov - 12:36
if ( myswitch == 1) -> don't check this if ($elec_busbar_main == 1) && ($bremse_halte_sw == 1) && ($door_needs_stopbrake != 1) and open straight the door
but
if ( myswitch == 0) -> check also these variables if ($elec_busbar_main == 1) && ($bremse_halte_sw == 1) && ($door_needs_stopbrake != 1) , then open the door...
Marcel Kuhnt Admin
Anzahl der Beiträge : 3364 Anmeldedatum : 26.04.09 Alter : 40 Ort : Berlin-Spandau
Thema: Re: Rewrite function for OMSI script language Do 10 Nov - 17:35
I think your problem is a problem of logic, not a problem of scripting!
It is not possible (neither in our language nor in other languages) to put an "if" "around" another "if" condition!
So you have to use the rules of boolean logic - in this case you should use an "or":
C++ code:
Code:
if(( myswitch) || (otherconditions))
In this case the resulting logic will be: "If myswitch is switched on, the event will be triggered. Else the event will be triggered only, if "othercondition" is true."
Your result in OMSI script would be like this (just adding the new switch with an or-condition (not to be mixed up with an air-condition... ):
Thema: Re: Rewrite function for OMSI script language Do 10 Nov - 18:06
Thank you very much, it's working fine.
There's problem that I don't know, where I have to write each function and how the variavels work. There is not to much people who kno know how the OMSI script language use :-)
Gesponserte Inhalte
Thema: Re: Rewrite function for OMSI script language