Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 2, 2008, 9:23:30 PM (16 years ago)
Author:
landauf
Message:

merged console-branch back to trunk.
IMPORTANT: update your media directory!

you need TCL to compile. TCL is available here: http://www.tcl.tk/
another option is to check out https://svn.orxonox.net/ogre/tcl8.5.2/ and compile it by yourself. makefiles are in the 'macosx', 'unix' and 'win' subfolders.
FindTCL.cmake searches in the usual locations and in ../libs/tcl8.5.2/

the orxonox console can be activated with numpad-enter. whatever you enter will be parsed by TCL. if TCL doesn't know a command, it gets executed by orxonox.

simple tcl commands are: "puts text" to write "text" into the console, "expr 1+1" to calculate the result of the given expression. just try it by yourself with "puts [expr 1+1]".
[x] means: evaluate x and use the returnvalue as an argument. in this case the returned value is "2" and the resulting command therefore "puts 2".

you can combine orxonox and tcl commands. a simple orxonox command is "log text" that writes text into the console and the logfile. test it with "log [expr 1+1]" to write "2" into all output channels of orxonox. something more advanced: "log [clock seconds]" writes the seconds since 1970 into the logfile. feel free to combine both: "log [clock seconds]: 1+1 is [expr 1+1]"

TCL uses variables. to set a new variable, use "set varname value". you can use the variable wherever you want with $varname. with this we can make the above command a bit more elegant:
set myexpression 1+1
log [clock seconds]: $myexpression is [expr $myexpression]

read more about tcl in the wiki: http://wiki.tcl.tk/

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/Orxonox.cc

    r1206 r1214  
    7676#include "tools/Timer.h"
    7777#include "hud/HUD.h"
     78#include "console/InGameConsole.h"
    7879
    7980// FIXME: is this really file scope?
     
    128129  {
    129130  public:
    130     static void calculate(const std::string& calculation)
     131    static float calculate(const std::string& calculation)
    131132    {
    132133      ExprParser expr(calculation);
     
    140141          std::cout << "Warning: Expression could not be parsed to the end! Remains: '"
    141142              << expr.getRemains() << "'" << std::endl;
     143        return expr.getResult();
    142144      }
    143145      else
     146      {
    144147        std::cout << "Cannot calculate expression: Parse error" << std::endl;
     148        return 0;
     149      }
    145150    }
    146151  };
     
    420425    InputBuffer* ib = new InputBuffer();
    421426    InputManager::getSingleton().feedInputBuffer(ib);
     427    /*
    422428    Testconsole* console = new Testconsole(ib);
    423429    ib->registerListener(console, &Testconsole::listen, true);
    424430    ib->registerListener(console, &Testconsole::execute, '\r', false);
    425     ib->registerListener(console, &Testconsole::execute, '\n', false);
    426431    ib->registerListener(console, &Testconsole::hintandcomplete, '\t', true);
    427432    ib->registerListener(console, &Testconsole::clear, '§', true);
    428433    ib->registerListener(console, &Testconsole::removeLast, '\b', true);
    429434    ib->registerListener(console, &Testconsole::exit, (char)0x1B, true);
     435    */
     436
     437    orxonoxConsole_ = new InGameConsole(ib);
     438    ib->registerListener(orxonoxConsole_, &InGameConsole::listen, true);
     439    ib->registerListener(orxonoxConsole_, &InGameConsole::execute, '\r', false);
     440    ib->registerListener(orxonoxConsole_, &InGameConsole::hintandcomplete, '\t', true);
     441    ib->registerListener(orxonoxConsole_, &InGameConsole::clear, '§', true);
     442    ib->registerListener(orxonoxConsole_, &InGameConsole::removeLast, '\b', true);
     443    ib->registerListener(orxonoxConsole_, &InGameConsole::exit, (char)0x1B, true);
    430444
    431445    // first check whether ogre root object has been created
     
    477491      for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it)
    478492        it->tick((float)evt.timeSinceLastFrame * this->timefactor_);
     493      orxonoxConsole_->tick((float)evt.timeSinceLastFrame * this->timefactor_);
    479494
    480495      // don't forget to call _fireFrameStarted in ogre to make sure
Note: See TracChangeset for help on using the changeset viewer.