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 1: | Line 1: | ||
+ | lacolacnad | ||
==Introduction== | ==Introduction== | ||
'''--- 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 | + | 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 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. | ||
Line 9: | Line 10: | ||
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. | + | 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 124: | Line 125: | ||
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. | 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 | + | For example, if you have a glob |
+ | 1000 | ||
+ | al '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. | 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:Tutorials]][[Category:Addon tutorials]] | |
− | [[Category:Tutorials]] | ||
− | [[Category: |