ehem. OMSI - Forum
Würden Sie gerne auf diese Nachricht reagieren? Erstellen Sie einen Account in wenigen Klicks oder loggen Sie sich ein, um fortzufahren.
ehem. OMSI - Forum

Dieses Forum wurde geschlossen. Das neue Forum befindet sich auf www.omnibussimulator.de/forum !
 
StartseiteStartseite  Neueste BilderNeueste Bilder  SuchenSuchen  AnmeldenAnmelden  LoginLogin  

 

 Rewrite function for OMSI script language

Nach unten 
3 verfasser
AutorNachricht
kosakkosak




Anzahl der Beiträge : 163
Anmeldedatum : 14.03.11

Rewrite function for OMSI script language Empty
BeitragThema: Rewrite function for OMSI script language   Rewrite function for OMSI script language Icon_minitimeDi 8 Nov - 16:45

Hello, can someone tall me how to rewrite for example this PHP function to OMSI sctipt language?

Code:
if(dog == 1)
 { make something }
else "when dog is not 1"
{ make another thing }

Concertly I have problem whith this one.

Code:
{trigger:bus_doorfront1}
   
   (L.L.elec_busbar_main) (L.L.bremse_halte_sw) (C.L.door_needs_stopbrake) ! && &&
   (L.L.elec_busbar_main) (L.L.bremse_halte) (C.L.door_needs_stopbrake) && && ||

   {if}
      (M.L.trg_bus_doorfront1)
   {endif}
   1 (S.L.cockpit_tuertaster2)
{end}

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

Nach oben Nach unten
krtz07




Anzahl der Beiträge : 413
Anmeldedatum : 10.09.09
Alter : 39
Ort : Philadelphia PA

Rewrite function for OMSI script language Empty
BeitragThema: Re: Rewrite function for OMSI script language   Rewrite function for OMSI script language Icon_minitimeMi 9 Nov - 2:48

kosakkosak schrieb:
Hello, can someone tall me how to rewrite for example this PHP function to OMSI sctipt language?


Concertly I have problem whith this one.

Code:
{trigger:bus_doorfront1}
   
   (L.L.elec_busbar_main) (L.L.bremse_halte_sw) (C.L.door_needs_stopbrake) ! && &&
   (L.L.elec_busbar_main) (L.L.bremse_halte) (C.L.door_needs_stopbrake) && && ||

   {if}
      (M.L.trg_bus_doorfront1)
   {endif}
   1 (S.L.cockpit_tuertaster2)
{end}

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?
Nach oben Nach unten
http://www.philadelphiatransitvehicles.info
kosakkosak




Anzahl der Beiträge : 163
Anmeldedatum : 14.03.11

Rewrite function for OMSI script language Empty
BeitragThema: Re: Rewrite function for OMSI script language   Rewrite function for OMSI script language Icon_minitimeMi 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..
Nach oben Nach unten
krtz07




Anzahl der Beiträge : 413
Anmeldedatum : 10.09.09
Alter : 39
Ort : Philadelphia PA

Rewrite function for OMSI script language Empty
BeitragThema: Re: Rewrite function for OMSI script language   Rewrite function for OMSI script language Icon_minitimeMi 9 Nov - 14:41

Ah ok, just want to make sure that we are on the right track. From the existing script,

Code:
{trigger:bus_doorfront1}
 
  (L.L.elec_busbar_main) (L.L.bremse_halte_sw) (C.L.door_needs_stopbrake) ! && &&
  (L.L.elec_busbar_main) (L.L.bremse_halte) (C.L.door_needs_stopbrake) && && ||

  {if}
      (M.L.trg_bus_doorfront1)
  {endif}
  1 (S.L.cockpit_tuertaster2)
{end}

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

(L.L.yourdesireaction) ! (L.L.elec_busbar_main) && (L.L.bremse_halte_sw) (C.L.door_needs_stopbrake) ! && &&
(L.L.yourdesireaction) (L.L.elec_busbar_main) && (L.L.bremse_halte) (C.L.door_needs_stopbrake) && && ||
Nach oben Nach unten
http://www.philadelphiatransitvehicles.info
kosakkosak




Anzahl der Beiträge : 163
Anmeldedatum : 14.03.11

Rewrite function for OMSI script language Empty
BeitragThema: Re: Rewrite function for OMSI script language   Rewrite function for OMSI script language Icon_minitimeMi 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 };
Nach oben Nach unten
krtz07




Anzahl der Beiträge : 413
Anmeldedatum : 10.09.09
Alter : 39
Ort : Philadelphia PA

Rewrite function for OMSI script language Empty
BeitragThema: Re: Rewrite function for OMSI script language   Rewrite function for OMSI script language Icon_minitimeDo 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.
Nach oben Nach unten
http://www.philadelphiatransitvehicles.info
kosakkosak




Anzahl der Beiträge : 163
Anmeldedatum : 14.03.11

Rewrite function for OMSI script language Empty
BeitragThema: Re: Rewrite function for OMSI script language   Rewrite function for OMSI script language Icon_minitimeDo 10 Nov - 12:36

That is the same result :-) you wrote

if ( myswitch == 1)

if ($elec_busbar_main == 1) && ($bremse_halte_sw == 1) && ($door_needs_stopbrake != 1)

{ do something };

I don't know how to describe it better... Maybe:

I need:

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...
Nach oben Nach unten
Marcel Kuhnt
Admin
Marcel Kuhnt


Anzahl der Beiträge : 3364
Anmeldedatum : 26.04.09
Alter : 40
Ort : Berlin-Spandau

Rewrite function for OMSI script language Empty
BeitragThema: Re: Rewrite function for OMSI script language   Rewrite function for OMSI script language Icon_minitimeDo 10 Nov - 17:35

I think your problem is a problem of logic, not a problem of scripting! Wink

It is not possible (neither in our language nor in other languages) to put an "if" "around" another "if" condition! Wink

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... Wink ):

Code:
{trigger:bus_doorfront1}
 
  (L.L.elec_busbar_main) (L.L.bremse_halte_sw) (C.L.door_needs_stopbrake) ! && &&
  (L.L.elec_busbar_main) (L.L.bremse_halte) (C.L.door_needs_stopbrake) && && ||
  (L.L.yourswitch) ||

  {if}
      (M.L.trg_bus_doorfront1)
  {endif}
  1 (S.L.cockpit_tuertaster2)
{end}
Nach oben Nach unten
kosakkosak




Anzahl der Beiträge : 163
Anmeldedatum : 14.03.11

Rewrite function for OMSI script language Empty
BeitragThema: Re: Rewrite function for OMSI script language   Rewrite function for OMSI script language Icon_minitimeDo 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 :-)
Nach oben Nach unten
Gesponserte Inhalte





Rewrite function for OMSI script language Empty
BeitragThema: Re: Rewrite function for OMSI script language   Rewrite function for OMSI script language Icon_minitime

Nach oben Nach unten
 
Rewrite function for OMSI script language
Nach oben 
Seite 1 von 1
 Ähnliche Themen
-
» Script-Language-Documentation
» OMSI - language
» Script SDK and Others ETA
» Working with Omsi Script
» Matrix Language

Befugnisse in diesem ForumSie können in diesem Forum nicht antworten
ehem. OMSI - Forum :: OMSI-Design (english) :: Script programming-
Gehe zu: