52 | | The interesting part: Modifying the C++ code. '''Open orxonox/trunk/src/orxonox/objects/TutorialShip.cc'''. As you have already heard from Fabian, the Core Framework is like a language extension to C++. But it cannot be 100% automatic. That means you have to add a few lines accordingly: |
53 | | 1. Find the constructor (TutorialShip::TutorialShip()) and add '''RegisterObject(TutorialShip)''' as the first statement. This is used for the class hierarchy and for the ObjectLists. |
54 | | 1. do more stuff |
55 | | 1. (???) |
56 | | 1. ... |
| 52 | The interesting part: Modifying the C++ code. '''Open orxonox/trunk/src/orxonox/objects/TutorialShip.cc'''. As you have already heard from Fabian, the Core Framework is like a language extension to C++. But it cannot be fully automatic. That means you have to add a few lines accordingly: |
| 53 | 1. Find the constructor (TutorialShip::TutorialShip()) and add '''RegisterObject(TutorialShip);''' as the first statement. This is used for the class hierarchy and for the ObjectLists. Whenever you derive from OrxonoxClass or any derivative, this call is necessary. |
| 54 | 1. Next will be creating a configurable value in our class. This enables us to configure the TutorialShip from outside (Shell or orxonox.ini). Go to the ''setConfigValues()'' and configure the member variable ''reloadTime_'' with a default value of 0.125. Remember the syntax: |
| 55 | {{{ SetConfigValue(''variable name'', ''default value'').description(''description text''); }}} |
| 56 | 1. The console command: It enables you to call a static function in the shell. Currently, our TutorialShip cannot fire any projectiles because there is no ConsoleCommand for "fire". This code is static, so we have to go to the beginning of the source code, just after {{{namespace orxonox {}}}. Now add a !ConsoleCommand for the static function ''fire()'' of the TutorialShip: |
| 57 | {{{ SetConsoleCommand(''class name'', ''function name'', true).keybindMode(KeybindMode::''mode''); }}} |
| 58 | keybindMode specifies how the console command should be treated when used on a key. ''OnHold'' means the command gets fired continuously, ''OnRelease'' and ''OnPress'' only once. [[br]][[br]] |