<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://www.wiki.omnibussimulator.de/omsiwikineu/index.php?action=history&amp;feed=atom&amp;title=Plug-In_Interface</id>
	<title>Plug-In Interface - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://www.wiki.omnibussimulator.de/omsiwikineu/index.php?action=history&amp;feed=atom&amp;title=Plug-In_Interface"/>
	<link rel="alternate" type="text/html" href="http://www.wiki.omnibussimulator.de/omsiwikineu/index.php?title=Plug-In_Interface&amp;action=history"/>
	<updated>2026-04-12T12:16:20Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.0</generator>
	<entry>
		<id>http://www.wiki.omnibussimulator.de/omsiwikineu/index.php?title=Plug-In_Interface&amp;diff=53&amp;oldid=prev</id>
		<title>Marcel Kuhnt: Translated from German OMSIWiki</title>
		<link rel="alternate" type="text/html" href="http://www.wiki.omnibussimulator.de/omsiwikineu/index.php?title=Plug-In_Interface&amp;diff=53&amp;oldid=prev"/>
		<updated>2011-11-18T17:11:14Z</updated>

		<summary type="html">&lt;p&gt;Translated from German OMSIWiki&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Main Principle =&lt;br /&gt;
&lt;br /&gt;
You can program plug-in DLLs which have reading and writing access to the vehicle variables and which can activate triggers.&lt;br /&gt;
&lt;br /&gt;
Each plugin consists of a [[Configuration File]] with the extension *.opl and a corresponding DLL. Both files have to be in the directory &amp;quot;OMSI\plugins&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
= Description of the Example Plug-In =&lt;br /&gt;
&lt;br /&gt;
OMSI contains already an example plug-in. You can activate it in renaming the file &amp;quot;test.txt&amp;quot; into &amp;quot;test.opl&amp;quot; (you will find it in the directory &amp;quot;OMSI\plugins&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
== Functional Range ==&lt;br /&gt;
&lt;br /&gt;
This plug-in has three functions: A speedometer (analog and digital) on top, a track bar to set the red heater handle (even if it calls it &amp;quot;Rollband-Sollwert&amp;quot;) and a door button named &amp;quot;Button1&amp;quot; (with the same function like the [Num /] key).&lt;br /&gt;
&lt;br /&gt;
[[File:Beispiel-Plugin.jpg|600px|thumb|right|User interface of the example plug-in]]&lt;br /&gt;
&lt;br /&gt;
== Format of the *.opt File ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
To activate, rename this file to &amp;quot;test.opl&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[dll]&lt;br /&gt;
Test.dll&lt;br /&gt;
&lt;br /&gt;
[varlist]&lt;br /&gt;
2&lt;br /&gt;
Velocity&lt;br /&gt;
cockpit_heizregler_temp&lt;br /&gt;
&lt;br /&gt;
[triggers]&lt;br /&gt;
1&lt;br /&gt;
bus_doorfront0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first line is just a comment line. The command [dll] indicates the file name of the corresponding DLL.&lt;br /&gt;
&lt;br /&gt;
The [varlist] command starts with the expected number of (only local!) vehicle variables. You can also use user variables of a special bus type. Of course this won't have any effect, if the driven bus has not these user variables.&lt;br /&gt;
&lt;br /&gt;
In this example, the variable with index 0 is &amp;quot;Velocity&amp;quot;, the variable with index 1 is &amp;quot;cockpit_heizregler_temp&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The [triggers] command starts with the number of the expected triggers. In this case, there is only one trigger: &amp;quot;bus_doorfront0&amp;quot; with index 0.&lt;br /&gt;
&lt;br /&gt;
== Format of the DLL ==&lt;br /&gt;
&lt;br /&gt;
With the shown example, I give you the corresponding Delphi Code. In general it should be possible to create DLLs with other programming languages, but I never tested that.&lt;br /&gt;
&lt;br /&gt;
The DLL contains of two units, but I present you only the main unit (the second unit does not contain any important implementations):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
library Test;&lt;br /&gt;
&lt;br /&gt;
uses&lt;br /&gt;
  SysUtils,&lt;br /&gt;
  Dialogs,&lt;br /&gt;
  Classes,&lt;br /&gt;
  TestU in 'TestU.pas' {Form1};&lt;br /&gt;
&lt;br /&gt;
{$R *.res}&lt;br /&gt;
&lt;br /&gt;
procedure Start( AOwner: TComponent ); stdcall;&lt;br /&gt;
begin&lt;br /&gt;
        form1 := TForm1.Create( AOwner );&lt;br /&gt;
        form1.Show;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
procedure Finalize; stdcall;&lt;br /&gt;
begin&lt;br /&gt;
        form1.Free;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
procedure AccessVariable( varindex: word; var value: single; var write: boolean ); stdcall;&lt;br /&gt;
begin&lt;br /&gt;
        case varindex of&lt;br /&gt;
                0:&lt;br /&gt;
                begin&lt;br /&gt;
                        form1.Label2.Caption := floattostrF( value, ffFixed, 5, 1 ) + ' km/h';&lt;br /&gt;
                        form1.Gauge1.Progress := round( value );&lt;br /&gt;
                        write := false;                        &lt;br /&gt;
                end;&lt;br /&gt;
                1:&lt;br /&gt;
                begin&lt;br /&gt;
                        value := form1.TrackBar1.Position / 30;&lt;br /&gt;
                        write := true;&lt;br /&gt;
                end;&lt;br /&gt;
        end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
procedure AccessTrigger( triggerindex: word; var active: boolean ); stdcall;&lt;br /&gt;
begin&lt;br /&gt;
        case triggerindex of&lt;br /&gt;
                0:&lt;br /&gt;
                begin&lt;br /&gt;
                        active := form1.button1_pressed;&lt;br /&gt;
                end;&lt;br /&gt;
        end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
exports&lt;br /&gt;
        AccessVariable,&lt;br /&gt;
        AccessTrigger,        &lt;br /&gt;
        Start,&lt;br /&gt;
        Finalize;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
begin&lt;br /&gt;
end.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all note the last section &amp;quot;exports&amp;quot;: It contains the four needed procedures of the DLL: ''AccessVariable'', ''AccessTrigger'', ''Start'' und ''Finalize''.&lt;br /&gt;
&lt;br /&gt;
These four procedures have the following functions:&lt;br /&gt;
&lt;br /&gt;
=== ''Start'' ===&lt;br /&gt;
&lt;br /&gt;
''Start( AOwner: TComponent )'' will be called at the beginning and allows the DLL to initialize itself. In this example, it creates ''Form1'' and puts it to the same named variable (which is part of the second Unit). The second step is calling the ''Show'' command to make ''Form1'' visible. ''Start'' hands the parameter &amp;quot;AOwner&amp;quot; over, the Handler of the main form of OMSI.&lt;br /&gt;
&lt;br /&gt;
=== ''Finalize'' ===&lt;br /&gt;
&lt;br /&gt;
''Finalize'' will be called while closing OMSI. In the example, ''Form1'' will be destroyed and freed.&lt;br /&gt;
&lt;br /&gt;
=== ''AccessVariable'' ===&lt;br /&gt;
&lt;br /&gt;
While running OMSI, this procedure will be called for all variables listed in the *.opl file. The index of the variable will be handed over via the variable ''varindex''. The procedure can write now ''value'' and ''write''.&lt;br /&gt;
&lt;br /&gt;
If you just would like to read a vehicle variable, you just have to read ''value'' like in the case &amp;quot;0:&amp;quot;. But it is also possible (like in &amp;quot;1:&amp;quot;)  to give a new value to ''value''. In this case you have to set ''write'' to ''true'' to advise OMSI to use the new value. In the example, the position of the track bar will be used as new value of the variable with index 1 (&amp;quot;bus_doorfront0&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
=== ''AccessTrigger'' ===&lt;br /&gt;
&lt;br /&gt;
This procedure is very similar to ''AccessVariable'', but OMSI will use the trigger list of the *.opl file. The DLL can set ''active'' to ''true'' and can trigger the event.&lt;br /&gt;
&lt;br /&gt;
[[Category:Developing Reference]]&lt;br /&gt;
&lt;br /&gt;
[[de:Plug-in-Schnittstelle]]&lt;/div&gt;</summary>
		<author><name>Marcel Kuhnt</name></author>
		
	</entry>
</feed>