Editing Vessel code

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 3: Line 3:
 
'''--- THIS IS WORK IN PROGRESS ---'''
 
'''--- THIS IS WORK IN PROGRESS ---'''
  
This is a quick guide to create your own vessel dll with VC++. It's not suited for newbies to c++. If you are new to [[Orbiter]], make a config based vessel first, or one based on vinkas spacecraft.dll or spacecraft2.dll.
+
This is a quick guide to create your own vessel dll with VC++. It's not suited for newbees to c++. If you are new to orbiter, make a config based vessel first, or one based on vinkas spacecraft.dll or spacecraft2.dll.
You will find here which API functions are necessary to get a project running. This is basically just a very cut down version from one of the sample ships included in Orbiter SDK.
+
You will find here wich API functions are necessary to get a project running. This is basically just a very cut down version from one of the sample ships included in Orbiter SDK.
  
 
==Adding Files to your Project==
 
==Adding Files to your Project==
 
After you have set up the compiler, it's time to start setting up the actual code.
 
After you have set up the compiler, it's time to start setting up the actual code.
  
Try to settle on a name for your vessel class first. Don't choose "testship" or "spacecraft". Try a unique name, like "ProtonLV", "HeavyCruiserHC" or whatever suits you. Save the project under that name and add the following two files (with your vessels name)
+
Try to settle on a name for your vessel class first. Dont choose "testship" or "spacecraft". Try a unique name, like "ProtonLV", "HeavyCruiserHC" or whatever suits you. Save the project under that name and add the following two files (with your vessels name)
  
 
*Source *.cpp file
 
*Source *.cpp file
Line 119: Line 119:
 
</nowiki>
 
</nowiki>
 
</pre>
 
</pre>
 
==Global variables==
 
 
One of the biggest causes of crashes in Orbiter modules is the use of global variables. Orbiter doesn't unload and reload the module DLL when you return to the Launchpad and start a new scenario, so any values saved in global variables will maintain their state when you start the new scenario.
 
 
For example, if you have a global 'abort' flag to indicate that you're aborting an automatic launch, and that was set by the scenario you were running before you quit out to the Launchpad, the abort flag will still be set when you start the new scenario and your autopilot will immediately and unexpectedly abort the launch.
 
 
Consequently you should only ever use global variables when you're absolutely sure they're safe, or when they're constants which therefore cannot change between runs. If you're not sure whether a variable should be global or part of your class, make it a class variable for safety.
 
 
[[Category: Articles]]
 
[[Category:Tutorials]]
 
[[Category:Add-on tutorials]]
 

Please note that all contributions to OrbiterWiki are considered to be released under the GNU Free Documentation License 1.2 (see OrbiterWiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following hCaptcha:

Cancel Editing help (opens in new window)