FG28_Kodiak
01-10-2012, 07:31 PM
After looking into the posibilities of using triggers on Cliffs of Dover without scripting (http://forum.1cpublishing.eu/showthread.php?t=28454) , in this lesson we will make some preperations to make scripting easier for us.
When scripting in Cliffs of Dover, we will be using C# (C Sharp) (http://en.wikipedia.org/wiki/C_Sharp_%28programming_language). This has some advantages, but also some disadvantages. The advantages are that one doesn't have to learn a programming language which was specificaly designed for CloDo. There are enough books and pages on the internet which can be helpful in learning the language. Also, one can use all the posibilieties of .Net. The disadvantages are that especially beginners (I just wanted a victory message!) can be shocked by the posibilites of scripting. The commands are cryptical in part, and that the language is object-oriented doesn't make it easier. Although, beginners will probably have the most problems with missing semicolons or wrongly placed brackets.
Because of this, at first, we will have a look at the Editor which is integrated into Cliffs of Dover. Sadly, it neither supports syntax highlighting nor aumotatic intenting. Basicly, it offers less than Windows Notepad.
http://img12.imageshack.us/img12/6449/il2edi01.jpg
Although, one can open a menu by right clicking which can compile the code. This can be useful when searching for mistakes. As an example, in this code a semicolon was forgoten, and then the code was compiled:
http://img221.imageshack.us/img221/1806/il2edi02.jpg
As expected, the output window shows us an error message:
http://img13.imageshack.us/img13/768/il2edi03.jpg
Now we correct the missing semicolon and try it again:
http://img861.imageshack.us/img861/8674/il2edi04.jpg
Now everything seems to be all right:
http://img62.imageshack.us/img62/6740/il2edi05.jpg
After saving, the CloDo editor automaticaly creates a file with the ending "cs". Script files in Cliffs of Dover have to have the same name as the mission file, but with the ending "cs" instead of "mis".
http://img16.imageshack.us/img16/5292/filesi.jpg
As one can see, Cliffs of Dover doesn't offer to much help with scripting. Because of this, one should look for alternatives to the integrated editor. There are two posibilites: One can use an extended editor, like the freeware Notepad++ http://notepad-plus-plus.org/. It offers syntax highlighting and automated intenting, at least.
http://img221.imageshack.us/img221/3960/notepadplusqh.jpg
Or one gets a professional developing environment. In this case we are lucky, as Microsoft offers one free of charge (registration is requiered though), namely Microsoft Visual C# Express
http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-csharp-express
Especially for beginners, I would recommend downloading and installing this package, because the editor offers a lot of funtions which make programming a lot easier. Syntax errors are shown directly in the editor by a red marking, for example.
http://img833.imageshack.us/img833/8819/mswebsite.jpg
After downloading and installing Microsoft Visual C# Express, we start a new project.
http://img546.imageshack.us/img546/4431/visual01.jpg
In the window which now pops up, we choose "Class Library" and enter a fiting name for our "project", as we will loose track at "ClassLibrary10", at the latest. Now we click OK.
http://img859.imageshack.us/img859/9113/visual02.jpg
Express now creates all necessary files and opens the editor. The code lines which are already in there can be deleted, as we don't need them.
http://img534.imageshack.us/img534/1905/visual03.jpg
We simply replace them with the standard framework (more of that in the next lesson), which is needed to script a mission.
http://img16.imageshack.us/img16/4980/clodoscriptsframework.jpg
After adding it, the Express editor already shows us the first errors. "The type or Namespace ...". This means, that the developing environment doesn't know the used assemblies (http://en.wikipedia.org/wiki/.NET_assembly). To change that, we select "References" in the Solution Explorer (orange arrow) and click it with the right mouse button.
http://img210.imageshack.us/img210/3918/visual04.jpg
Now we click "Add References"
http://img3.imageshack.us/img3/4233/visual05.jpg
In the dialogue box we choose "Browse" and navigate to the folder ..\Steam\SteamApps\common\il-2 sturmovik cliffs of dover\parts\core and highlight the files "antlr.runtime.dll", "core.dll", "gamePages.dll", "gamePlay.dll", "gameWorld.dll", "HostView.dll", "maddox.dll", "part.dll", "sound.dll" and "Strategy.dll"
http://img859.imageshack.us/img859/6223/visual06.jpg
and in the folder ..\Steam\SteamApps\common\il-2 sturmovik cliffs of dover\parts\bob the files "partBob.dll" and "Campaign.dll". We don't need all of them, but it doesn't hurt to add them to the project so we don't have to look for them later, if we might need them.
http://img163.imageshack.us/img163/8397/visual07.jpg
To call up another useful tool of the Express Editor, namely the Object-Explorer, we switch the Editor into expert mode.
http://img52.imageshack.us/img52/8175/visual08.jpg
Now we activate the Object-Browser (and yes, a simple "CTRL+W, J would have done the job, too)
http://img502.imageshack.us/img502/9384/visual09.jpg
In the Object-Explorer we can look more closely at the classes which are present in the Dlls.
http://img337.imageshack.us/img337/5608/visual10.jpg
The Express Editor also has the useful function autocomplete at it's disposal.
http://img27.imageshack.us/img27/9454/visual11.jpg
http://img855.imageshack.us/img855/2632/visual12.jpg
In the next lesson we will finally start with scripting - I promise!
Suggestions or criticism are always welcome.
Thanks again to FG28_Elatan for the translation.
When scripting in Cliffs of Dover, we will be using C# (C Sharp) (http://en.wikipedia.org/wiki/C_Sharp_%28programming_language). This has some advantages, but also some disadvantages. The advantages are that one doesn't have to learn a programming language which was specificaly designed for CloDo. There are enough books and pages on the internet which can be helpful in learning the language. Also, one can use all the posibilieties of .Net. The disadvantages are that especially beginners (I just wanted a victory message!) can be shocked by the posibilites of scripting. The commands are cryptical in part, and that the language is object-oriented doesn't make it easier. Although, beginners will probably have the most problems with missing semicolons or wrongly placed brackets.
Because of this, at first, we will have a look at the Editor which is integrated into Cliffs of Dover. Sadly, it neither supports syntax highlighting nor aumotatic intenting. Basicly, it offers less than Windows Notepad.
http://img12.imageshack.us/img12/6449/il2edi01.jpg
Although, one can open a menu by right clicking which can compile the code. This can be useful when searching for mistakes. As an example, in this code a semicolon was forgoten, and then the code was compiled:
http://img221.imageshack.us/img221/1806/il2edi02.jpg
As expected, the output window shows us an error message:
http://img13.imageshack.us/img13/768/il2edi03.jpg
Now we correct the missing semicolon and try it again:
http://img861.imageshack.us/img861/8674/il2edi04.jpg
Now everything seems to be all right:
http://img62.imageshack.us/img62/6740/il2edi05.jpg
After saving, the CloDo editor automaticaly creates a file with the ending "cs". Script files in Cliffs of Dover have to have the same name as the mission file, but with the ending "cs" instead of "mis".
http://img16.imageshack.us/img16/5292/filesi.jpg
As one can see, Cliffs of Dover doesn't offer to much help with scripting. Because of this, one should look for alternatives to the integrated editor. There are two posibilites: One can use an extended editor, like the freeware Notepad++ http://notepad-plus-plus.org/. It offers syntax highlighting and automated intenting, at least.
http://img221.imageshack.us/img221/3960/notepadplusqh.jpg
Or one gets a professional developing environment. In this case we are lucky, as Microsoft offers one free of charge (registration is requiered though), namely Microsoft Visual C# Express
http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-csharp-express
Especially for beginners, I would recommend downloading and installing this package, because the editor offers a lot of funtions which make programming a lot easier. Syntax errors are shown directly in the editor by a red marking, for example.
http://img833.imageshack.us/img833/8819/mswebsite.jpg
After downloading and installing Microsoft Visual C# Express, we start a new project.
http://img546.imageshack.us/img546/4431/visual01.jpg
In the window which now pops up, we choose "Class Library" and enter a fiting name for our "project", as we will loose track at "ClassLibrary10", at the latest. Now we click OK.
http://img859.imageshack.us/img859/9113/visual02.jpg
Express now creates all necessary files and opens the editor. The code lines which are already in there can be deleted, as we don't need them.
http://img534.imageshack.us/img534/1905/visual03.jpg
We simply replace them with the standard framework (more of that in the next lesson), which is needed to script a mission.
http://img16.imageshack.us/img16/4980/clodoscriptsframework.jpg
After adding it, the Express editor already shows us the first errors. "The type or Namespace ...". This means, that the developing environment doesn't know the used assemblies (http://en.wikipedia.org/wiki/.NET_assembly). To change that, we select "References" in the Solution Explorer (orange arrow) and click it with the right mouse button.
http://img210.imageshack.us/img210/3918/visual04.jpg
Now we click "Add References"
http://img3.imageshack.us/img3/4233/visual05.jpg
In the dialogue box we choose "Browse" and navigate to the folder ..\Steam\SteamApps\common\il-2 sturmovik cliffs of dover\parts\core and highlight the files "antlr.runtime.dll", "core.dll", "gamePages.dll", "gamePlay.dll", "gameWorld.dll", "HostView.dll", "maddox.dll", "part.dll", "sound.dll" and "Strategy.dll"
http://img859.imageshack.us/img859/6223/visual06.jpg
and in the folder ..\Steam\SteamApps\common\il-2 sturmovik cliffs of dover\parts\bob the files "partBob.dll" and "Campaign.dll". We don't need all of them, but it doesn't hurt to add them to the project so we don't have to look for them later, if we might need them.
http://img163.imageshack.us/img163/8397/visual07.jpg
To call up another useful tool of the Express Editor, namely the Object-Explorer, we switch the Editor into expert mode.
http://img52.imageshack.us/img52/8175/visual08.jpg
Now we activate the Object-Browser (and yes, a simple "CTRL+W, J would have done the job, too)
http://img502.imageshack.us/img502/9384/visual09.jpg
In the Object-Explorer we can look more closely at the classes which are present in the Dlls.
http://img337.imageshack.us/img337/5608/visual10.jpg
The Express Editor also has the useful function autocomplete at it's disposal.
http://img27.imageshack.us/img27/9454/visual11.jpg
http://img855.imageshack.us/img855/2632/visual12.jpg
In the next lesson we will finally start with scripting - I promise!
Suggestions or criticism are always welcome.
Thanks again to FG28_Elatan for the translation.