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  SuchenSuchen  AnmeldenAnmelden  LoginLogin  

 

 Working with Omsi Script

Nach unten 
+4
peterZZD
Marcel Kuhnt
Rüdiger Hülsmann
BlackSpider
8 verfasser
AutorNachricht
BlackSpider




Anzahl der Beiträge : 36
Anmeldedatum : 16.02.11

Working with Omsi Script Empty
BeitragThema: Working with Omsi Script   Working with Omsi Script Icon_minitimeSa 19 Feb - 13:22

I have a question about Omsi Script.

Because I'm scripting now in Unity's C# Script. How is this compared to the OMSI Language, and can you give some more information on the scripting language.
For example : Is it object based? Etc.

Thanks again

BlackSpider
Nach oben Nach unten
Rüdiger Hülsmann
Admin
Rüdiger Hülsmann


Anzahl der Beiträge : 1204
Anmeldedatum : 25.04.09
Alter : 38
Ort : Potsdam-West, Berlin-Mariendorf

Working with Omsi Script Empty
BeitragThema: Re: Working with Omsi Script   Working with Omsi Script Icon_minitimeSa 19 Feb - 13:49

OMSI uses a non-object-orientated, line-based, RPN-style scripting language.
Here is a screenshot of a typical OMSI script file:
Working with Omsi Script Script
Nach oben Nach unten
BlackSpider




Anzahl der Beiträge : 36
Anmeldedatum : 16.02.11

Working with Omsi Script Empty
BeitragThema: Re: Working with Omsi Script   Working with Omsi Script Icon_minitimeSa 19 Feb - 16:11

Rüdiger Hülsmann schrieb:
OMSI uses a non-object-orientated, line-based, RPN-style scripting language.
Here is a screenshot of a typical OMSI script file:
Image

Thank you for your quick answer. It looks difficult because of the German Language.
But i get a little bit whats going on in the script.

BlackSpider


Zuletzt von BlackSpider am Sa 19 Feb - 16:13 bearbeitet; insgesamt 1-mal bearbeitet
Nach oben Nach unten
Rüdiger Hülsmann
Admin
Rüdiger Hülsmann


Anzahl der Beiträge : 1204
Anmeldedatum : 25.04.09
Alter : 38
Ort : Potsdam-West, Berlin-Mariendorf

Working with Omsi Script Empty
BeitragThema: Re: Working with Omsi Script   Working with Omsi Script Icon_minitimeSa 19 Feb - 16:12

Well, you can name your variables in any language you want ;-)
Nach oben Nach unten
BlackSpider




Anzahl der Beiträge : 36
Anmeldedatum : 16.02.11

Working with Omsi Script Empty
BeitragThema: Re: Working with Omsi Script   Working with Omsi Script Icon_minitimeSa 19 Feb - 16:15

Rüdiger Hülsmann schrieb:
Well, you can name your variables in any language you want ;-)

So what does this mean for instance.
S.L.antrieb_neutral_Requested.
S = variable.
L = variable.
antrieb_neutral_Requested = variable.

Something like this.
Nach oben Nach unten
Marcel Kuhnt
Admin
Marcel Kuhnt


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

Working with Omsi Script Empty
BeitragThema: Re: Working with Omsi Script   Working with Omsi Script Icon_minitimeSa 19 Feb - 18:45

We will create a full documentated SDK for you! But we will need some time! Wink

Ok, just one big basic for our script:

if you want to do "1 + 1", you have to type "1 1 +" !

So you set the first operator, then the next and then the operation.

The result is again the first operator: 1 1 + (S.L.Var) means, that he will store 1+1, that means 2 in the variable Var.

(L.L.Var) 1 + is now the opposite: he loads Var (L!) and then adds 1!

Subtract or divide: 50 2 / is the same like 25! Or 10 4 - is the same like 6!



That was a VERY VERY VERY short description of the basic concept of the OMSI script language. As I said above: There will come more later! But first we just have to translate the main and the editor manual! Wink
Nach oben Nach unten
BlackSpider




Anzahl der Beiträge : 36
Anmeldedatum : 16.02.11

Working with Omsi Script Empty
BeitragThema: Re: Working with Omsi Script   Working with Omsi Script Icon_minitimeSa 19 Feb - 18:53

Thank you so much. for the explanation

I get it and Ii will wait for the SDK documentation.
Nach oben Nach unten
peterZZD

peterZZD


Anzahl der Beiträge : 270
Anmeldedatum : 20.12.10
Alter : 24
Ort : Depending on the time of the year, middle of nowhere or middle of nowhere

Working with Omsi Script Empty
BeitragThema: Re: Working with Omsi Script   Working with Omsi Script Icon_minitimeSa 19 Feb - 21:09

Marcel Kuhnt schrieb:

if you want to do "1 + 1", you have to type "1 1 +" !
Couldn't do any wierder? Razz OK, I prefer C++ operations (z is an integer variable, it's right now 6, and I want to add on 1 - I do that: z++. Done :p )

EOT.
Nach oben Nach unten
Marcel Kuhnt
Admin
Marcel Kuhnt


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

Working with Omsi Script Empty
BeitragThema: Re: Working with Omsi Script   Working with Omsi Script Icon_minitimeSa 19 Feb - 21:47

I really, really can understand you! But I was really a greenhorn in such things like parsing etc.! And that way we did it, it is now a little bit confusing Wink but was much easier for me to implement in OMSI!
Nach oben Nach unten
Emil




Anzahl der Beiträge : 596
Anmeldedatum : 14.02.11

Working with Omsi Script Empty
BeitragThema: Re: Working with Omsi Script   Working with Omsi Script Icon_minitimeFr 25 März - 19:14

Marcel Kuhnt schrieb:
I really, really can understand you! But I was really a greenhorn in such things like parsing etc.! And that way we did it, it is now a little bit confusing Wink but was much easier for me to implement in OMSI!

It's done like this Wink and called reverse polish notation
Nach oben Nach unten
krtz07




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

Working with Omsi Script Empty
BeitragThema: Re: Working with Omsi Script   Working with Omsi Script Icon_minitimeDo 31 März - 0:03

I know from my very very limited knewledge with Marcel script and correct me if I am wrong,


Code:
(L.L.n_Wheel) (C.L.antrieb_i_achse) * (S.L.antrieb_getr_n_ab) (L.L.engine_n) / (S.L.antrieb_wandler_ny)

The S.L.antrieb_wandler_ny is the end result variable which that variable could be used somewhere else... I guess

(C.L.antrieb_i_achse), the C is the constant value that can be find in any of the consist.txt files that is linked to the bus...
Nach oben Nach unten
http://www.philadelphiatransitvehicles.info
Rüdiger Hülsmann
Admin
Rüdiger Hülsmann


Anzahl der Beiträge : 1204
Anmeldedatum : 25.04.09
Alter : 38
Ort : Potsdam-West, Berlin-Mariendorf

Working with Omsi Script Empty
BeitragThema: Re: Working with Omsi Script   Working with Omsi Script Icon_minitimeDo 31 März - 10:14

Yes, that's correct.

In clear words:

1) Load n_Wheel, multiply it with the constant antrieb_i_achse and save the result into antrieb_getr_n_ab
2) Divide this result by engine_n and save the new result into antrieb_wandler_ny.
Nach oben Nach unten
Janniboy

Janniboy


Anzahl der Beiträge : 2837
Anmeldedatum : 09.02.10
Alter : 27
Ort : Koblenz

Working with Omsi Script Empty
BeitragThema: Re: Working with Omsi Script   Working with Omsi Script Icon_minitimeDo 31 März - 14:19

I feel my brain twisting Very Happy
Nach oben Nach unten
http://www.jan-kiesewalter.de
krtz07




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

Working with Omsi Script Empty
BeitragThema: Re: Working with Omsi Script   Working with Omsi Script Icon_minitimeDo 31 März - 14:30

That was going to be my second half of the post but was not going to go into details on something which may or may not be (at that time) correct. It is good to know I am starting to understand the basic markup of the script...

Nach oben Nach unten
http://www.philadelphiatransitvehicles.info
disc




Anzahl der Beiträge : 18
Anmeldedatum : 24.02.11

Working with Omsi Script Empty
BeitragThema: Re: Working with Omsi Script   Working with Omsi Script Icon_minitimeDi 5 Apr - 15:02

I'm programmer, with java, php, javascript, lua knowledge and pascal from school, but i can't understand these weird variable naming(maybe mostly because i don't speak german), and where these variables come from. No any call to game engine, just there is a variable from nowhere.
Why didn't you just plugged in a lua script engine? It's free, and it's pretty usable, i've programmed a some complex things for railworks which using lua script (engine simulation, cab and body sway, warning system, etc) . And the limits of it are only the things what can be called from lua script (which is depends only on game programmers).
Nach oben Nach unten
Rüdiger Hülsmann
Admin
Rüdiger Hülsmann


Anzahl der Beiträge : 1204
Anmeldedatum : 25.04.09
Alter : 38
Ort : Potsdam-West, Berlin-Mariendorf

Working with Omsi Script Empty
BeitragThema: Re: Working with Omsi Script   Working with Omsi Script Icon_minitimeDi 5 Apr - 16:22

"Just plug in a script engine" sounds a bit optimistic. As we were unfamiliar with external script engines, we have developed our own.

The variables and constants used in our script files are defined for each vehicle. So a usual script set includes the following three files:
script_varlist.txt => list of variables for this vehicle
script_constfile.txt => list of constants and their values for this vehicle
script.osc => script file where the real programming happens.

As we've said, the OMSI script engine uses RPN (reverse polish notation), like some older pocket calculators do. This notation is faster and easier to implement, though it's a bit confusing at first sight.

When you're working with a variable, you'll need to add a prefix to tell OMSI what to do with the variable.
"L.L." means: load value of the given local variable (local means: for that particular vehicle)
"S.L." means: save value into given local variable
"C.L." means: load value of the given local constant.

Basic example: We want to multiply the local variable "test" by 2, add the constant "summand" and save the result into the variable "result":

(L.L.test) 2 * (C.L.summand) + (S.L.result)
Nach oben Nach unten
disc




Anzahl der Beiträge : 18
Anmeldedatum : 24.02.11

Working with Omsi Script Empty
BeitragThema: Re: Working with Omsi Script   Working with Omsi Script Icon_minitimeDi 5 Apr - 17:59

Rüdiger Hülsmann schrieb:
"Just plug in a script engine" sounds a bit optimistic. As we were unfamiliar with external script engines, we have developed our own.

I don't think it's easier to develop a script engine than learn about external engines, and use it. Moreover it was surely harder(because you've worked with something that is already made by others).
This script engine makes a lot of addon developers to stop/ or don't even try to develop for omsi. The RPN is just a little problem, that's easy to get used to it, but the syntax and other formalitlies of the script needs too much time and fatigue to get used to it.
There are very few games that have own script engine (i know just ofp and it's successors (arma,arma2) but those also using a c++ like script language because that time when OFP released there wasn other script engines, which is is easy to use), but now there is lua, which is used in huge amount of games.
Nach oben Nach unten
Rüdiger Hülsmann
Admin
Rüdiger Hülsmann


Anzahl der Beiträge : 1204
Anmeldedatum : 25.04.09
Alter : 38
Ort : Potsdam-West, Berlin-Mariendorf

Working with Omsi Script Empty
BeitragThema: Re: Working with Omsi Script   Working with Omsi Script Icon_minitimeDi 5 Apr - 18:16

I don't think that our script language will prevent people from making addons. In fact, there are some already, despite the lack of an SDK. Once the complete SDK is out, there will be a profound explanation of the script engine and thus more comprehension and thus again, more developers and addons. After all, these differences, apart from the RPN style, only concern the notation, just like in other programming languages. BEGIN...END in Delphi, {...} in C. Every programming language needs some time getting used to it and so does OMSI script too, of course. The only real difference I see (yet again apart from the RPN style) is that the variables and constants are defined in an external file and that the prefix types must match when using them. Nothing that cannot be taken in within a few days working with it.
Nach oben Nach unten
krtz07




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

Working with Omsi Script Empty
BeitragThema: Re: Working with Omsi Script   Working with Omsi Script Icon_minitimeDi 5 Apr - 20:37

Rüdiger Hülsmann schrieb:
I don't think that our script language will prevent people from making addons. In fact, there are some already, despite the lack of an SDK. Once the complete SDK is out, there will be a profound explanation of the script engine and thus more comprehension and thus again, more developers and addons. After all, these differences, apart from the RPN style, only concern the notation, just like in other programming languages. BEGIN...END in Delphi, {...} in C. Every programming language needs some time getting used to it and so does OMSI script too, of course. The only real difference I see (yet again apart from the RPN style) is that the variables and constants are defined in an external file and that the prefix types must match when using them. Nothing that cannot be taken in within a few days working with it.
Vbus helped kicked off my very beginnings in programming in Delphi, have not used Borland Delphi since 2005! These days it is mainly PHP since I run a website which I have made using php scripting routines. This scripting engine (MR script) is interesting to say the least with the reverse polish notation. I have seen scripts in MR scripts with two "++", no idea what the double "++" means.

On one of my working add ons for the ZF transmsision I did managed to expanded torque converter coverage to gear 3, sans 2C. It seems all that is required is || to be placed after the script. Apparently || is used as "OR". In my case, " (L.L.antrieb_getr_aktugang) 1 = || (L.L.antrieb_getr_aktugang) 3 = || ". I think the script is actually easy, yet between the German and Reverse Notation of the script, it can look complicated at first.

Still have no idea how to script out a turbocharger though...

It seems as if MR script uses the same operators as found in PHP though.

http://www.w3schools.com/PHP/php_operators.asp
Nach oben Nach unten
http://www.philadelphiatransitvehicles.info
Janniboy

Janniboy


Anzahl der Beiträge : 2837
Anmeldedatum : 09.02.10
Alter : 27
Ort : Koblenz

Working with Omsi Script Empty
BeitragThema: Re: Working with Omsi Script   Working with Omsi Script Icon_minitimeDi 5 Apr - 20:46

krtz07 schrieb:
It seems as if MR script uses the same operators as found in PHP though.

Not always, look for example at the "equal" comparision operator, in OMSI script it's "=", but in PHP it's "==", because "=" would set a new value to the variable and thus return true Wink

But I see your point, in some parts it seems quite similar.
Nach oben Nach unten
http://www.jan-kiesewalter.de
disc




Anzahl der Beiträge : 18
Anmeldedatum : 24.02.11

Working with Omsi Script Empty
BeitragThema: Re: Working with Omsi Script   Working with Omsi Script Icon_minitimeFr 22 Apr - 12:28

Rüdiger Hülsmann schrieb:
I don't think that our script language will prevent people from making addons. In fact, there are some already, despite the lack of an SDK. Once the complete SDK is out, there will be a profound explanation of the script engine and thus more comprehension and thus again, more developers and addons. After all, these differences, apart from the RPN style, only concern the notation, just like in other programming languages. BEGIN...END in Delphi, {...} in C. Every programming language needs some time getting used to it and so does OMSI script too, of course. The only real difference I see (yet again apart from the RPN style) is that the variables and constants are defined in an external file and that the prefix types must match when using them. Nothing that cannot be taken in within a few days working with it.

I know about 2 projects that are stalled because of scripting. Everything is ready including the 3d model.
Not just the rpn style is the difference. There are no languages that needing those {} and () at the instructions, these symbols make the code hard to understand, since in other languages these have different meanings. Also these load constant/variable, save variable things are confusing, that syntax looks like to access an object's variable who worked with object oriented programming, and also on other languages, the operators say what is needed to do with the variables, constants, and no needed to seperately tell that you want to load or save the variable.A lua language script is more easier to understand(even if the code not formatted well like this), since it's very similar to other popular languages. And have a parser to quickly check your script syntax. omsi script needs much time to get used to it(more than other languages), which isn't too inviting.
Nach oben Nach unten
Gesponserte Inhalte





Working with Omsi Script Empty
BeitragThema: Re: Working with Omsi Script   Working with Omsi Script Icon_minitime

Nach oben Nach unten
 
Working with Omsi Script
Nach oben 
Seite 1 von 1
 Ähnliche Themen
-
» Rewrite function for OMSI script language
» Karosa B732 - v0.2 Released, but it is not finished, because this project is stopped.
» New bus route not working!
» Mercedes Benz O 405 N2 [Download]
» Route 92E + 13N not working??

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