Index: code/trunk/src/core/CMakeLists.txt
===================================================================
--- code/trunk/src/core/CMakeLists.txt	(revision 1209)
+++ code/trunk/src/core/CMakeLists.txt	(revision 1214)
@@ -28,4 +28,5 @@
   tolua/tolua_bind.cc
 #tolua/tolua_bind.h
+  TclBind.cc
 )
 
@@ -49,4 +50,5 @@
 
 TARGET_LINK_LIBRARIES(core
+  cpptcl
   ${Lua_LIBRARIES}
   ${OIS_LIBRARIES}
Index: code/trunk/src/core/CommandExecutor.cc
===================================================================
--- code/trunk/src/core/CommandExecutor.cc	(revision 1209)
+++ code/trunk/src/core/CommandExecutor.cc	(revision 1214)
@@ -36,4 +36,5 @@
 #include "Executor.h"
 #include "ConfigValueContainer.h"
+#include "TclBind.h"
 
 #define COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE "set"
@@ -236,8 +237,19 @@
             if (this->shortcut_)
             {
-                if (this->shortcut_->evaluate(this->processedCommand_ + this->getAdditionalParameter(), this->param_, " "))
-                {
-                    this->bEvaluatedParams_ = true;
-                    this->evaluatedExecutor_ = this->shortcut_;
+                if (this->tokens_.size() <= 1)
+                {
+                    if (this->shortcut_->evaluate(this->getAdditionalParameter(), this->param_, " "))
+                    {
+                        this->bEvaluatedParams_ = true;
+                        this->evaluatedExecutor_ = this->shortcut_;
+                    }
+                }
+                else if (this->tokens_.size() > 1)
+                {
+                    if (this->shortcut_->evaluate(this->tokens_.subSet(1).join() + this->getAdditionalParameter(), this->param_, " "))
+                    {
+                        this->bEvaluatedParams_ = true;
+                        this->evaluatedExecutor_ = this->shortcut_;
+                    }
                 }
             }
@@ -247,8 +259,19 @@
             if (this->function_)
             {
-                if (this->function_->evaluate(this->processedCommand_ + this->getAdditionalParameter(), this->param_, " "))
-                {
-                    this->bEvaluatedParams_ = true;
-                    this->evaluatedExecutor_ = this->function_;
+                if (this->tokens_.size() <= 2)
+                {
+                    if (this->function_->evaluate(this->getAdditionalParameter(), this->param_, " "))
+                    {
+                        this->bEvaluatedParams_ = true;
+                        this->evaluatedExecutor_ = this->function_;
+                    }
+                }
+                else if (this->tokens_.size() > 2)
+                {
+                    if (this->function_->evaluate(this->tokens_.subSet(2).join() + this->getAdditionalParameter(), this->param_, " "))
+                    {
+                        this->bEvaluatedParams_ = true;
+                        this->evaluatedExecutor_ = this->function_;
+                    }
                 }
             }
@@ -266,4 +289,20 @@
         if (index >= 0 && index < MAX_FUNCTOR_ARGUMENTS)
             return this->param_[index];
+
+        return MT_null;
+    }
+
+    bool CommandEvaluation::hasReturnvalue() const
+    {
+        if (this->state_ == CS_Shortcut_Params || this->state_ == CS_Shortcut_Finished)
+        {
+            if (this->shortcut_)
+                return this->shortcut_->hasReturnvalue();
+        }
+        else if (this->state_ == CS_Function_Params || this->state_ == CS_Function_Finished)
+        {
+            if (this->function_)
+                return this->function_->hasReturnvalue();
+        }
 
         return MT_null;
@@ -297,4 +336,9 @@
 
     CommandEvaluation& CommandExecutor::getEvaluation()
+    {
+        return CommandExecutor::getInstance().evaluation_;
+    }
+
+    const CommandEvaluation& CommandExecutor::getLastEvaluation()
     {
         return CommandExecutor::getInstance().evaluation_;
@@ -336,59 +380,17 @@
     }
 
-    bool CommandExecutor::execute(const std::string& command)
-    {
-        std::string strippedCommand = stripEnclosingQuotes(command);
-
-        SubString tokensIO(strippedCommand, " ", SubString::WhiteSpaces, false, '\\', false, '"', false, '(', ')', false, '\0');
-        if (tokensIO.size() >= 2)
-        {
-            if (tokensIO[tokensIO.size() - 2] == ">")
-            {
-                bool success = CommandExecutor::execute(tokensIO.subSet(0, tokensIO.size() - 2).join());
-                write(tokensIO[tokensIO.size() - 1], CommandExecutor::getEvaluation().getReturnvalue());
-                return success;
-            }
-            else if (tokensIO[tokensIO.size() - 2] == "<")
-            {
-                std::string input = read(tokensIO[tokensIO.size() - 1]);
-                if (input == "" || input.size() == 0)
-                    return CommandExecutor::execute(tokensIO.subSet(0, tokensIO.size() - 2).join());
-                else
-                    return CommandExecutor::execute(tokensIO.subSet(0, tokensIO.size() - 2).join() + " " + input);
-            }
-        }
-
-
-        SubString tokensPipeline(strippedCommand, "|", SubString::WhiteSpaces, false, '\\', false, '"', false, '(', ')', false, '\0');
-        if (tokensPipeline.size() > 1)
-        {
-            bool success = true;
-            std::string returnValue = "";
-            for (int i = tokensPipeline.size() - 1; i >= 0; i--)
-            {
-                if (returnValue == "" || returnValue.size() == 0)
-                {
-                    //CommandEvaluation evaluation = CommandExecutor::evaluate(tokens[i]);
-                    if (!CommandExecutor::execute(tokensPipeline[i]))
-                        success = false;
-                }
-                else
-                {
-                    //CommandEvaluation evaluation = CommandExecutor::evaluate(tokens[i] + " " + returnValue);
-                    if (!CommandExecutor::execute(tokensPipeline[i] + " " + returnValue))
-                        success = false;
-                }
-
-                //CommandExecutor::execute(evaluation);
-                //returnValue = evaluation.getReturnvalue();
-                returnValue = CommandExecutor::getEvaluation().getReturnvalue().toString();
-            }
-            return success;
-        }
-
-        if ((CommandExecutor::getEvaluation().processedCommand_ != strippedCommand) || (CommandExecutor::getEvaluation().state_ == CS_Uninitialized))
-            CommandExecutor::parse(strippedCommand);
-
-        return CommandExecutor::execute(CommandExecutor::getEvaluation());
+    bool CommandExecutor::execute(const std::string& command, bool useTcl)
+    {
+        if (useTcl)
+        {
+            return TclBind::eval(command);
+        }
+        else
+        {
+            if ((CommandExecutor::getEvaluation().processedCommand_ != command) || (CommandExecutor::getEvaluation().state_ == CS_Uninitialized))
+                CommandExecutor::parse(command);
+
+            return CommandExecutor::execute(CommandExecutor::getEvaluation());
+        }
     }
 
@@ -400,7 +402,10 @@
         if (evaluation.bEvaluatedParams_ && evaluation.evaluatedExecutor_)
         {
+std::cout << "CE_execute (evaluation): " << evaluation.evaluatedExecutor_->getName() << " " << evaluation.param_[0] << " " << evaluation.param_[1] << " " << evaluation.param_[2] << " " << evaluation.param_[3] << " " << evaluation.param_[4] << std::endl;
             (*evaluation.evaluatedExecutor_)(evaluation.param_[0], evaluation.param_[1], evaluation.param_[2], evaluation.param_[3], evaluation.param_[4]);
-        }
-
+            return true;
+        }
+
+std::cout << "CE_execute: " << evaluation.processedCommand_ << "\n";
         switch (evaluation.state_)
         {
@@ -645,4 +650,14 @@
     {
         CommandExecutor::parse(command, true);
+
+        if (CommandExecutor::getEvaluation().tokens_.size() > 0)
+        {
+            std::string lastToken;
+            lastToken = CommandExecutor::getEvaluation().tokens_[CommandExecutor::getEvaluation().tokens_.size() - 1];
+            lastToken = lastToken.substr(0, lastToken.size() - 1);
+            CommandExecutor::getEvaluation().tokens_.pop_back();
+            CommandExecutor::getEvaluation().tokens_.append(SubString(lastToken, " ", "", true, '\0', false, '\0', false, '\0', '\0', false, '\0'));
+        }
+
         CommandExecutor::getEvaluation().evaluateParams();
         return CommandExecutor::getEvaluation();
@@ -1082,4 +1097,7 @@
         CommandExecutor::getEvaluation().additionalParameter_ = "";
 
+        CommandExecutor::getEvaluation().bEvaluatedParams_ = false;
+        CommandExecutor::getEvaluation().evaluatedExecutor_ = 0;
+
         CommandExecutor::getEvaluation().listOfPossibleFunctionClasses_.clear();
         CommandExecutor::getEvaluation().listOfPossibleShortcuts_.clear();
Index: code/trunk/src/core/CommandExecutor.h
===================================================================
--- code/trunk/src/core/CommandExecutor.h	(revision 1209)
+++ code/trunk/src/core/CommandExecutor.h	(revision 1214)
@@ -95,4 +95,5 @@
             void evaluateParams();
 
+            bool hasReturnvalue() const;
             MultiTypeMath getReturnvalue() const;
 
@@ -130,5 +131,5 @@
     {
         public:
-            static bool execute(const std::string& command);
+            static bool execute(const std::string& command, bool useTcl = true);
             static bool execute(const CommandEvaluation& evaluation);
 
@@ -140,4 +141,6 @@
 
             static CommandEvaluation evaluate(const std::string& command);
+
+            static const CommandEvaluation& getLastEvaluation();
 
             static Executor& addConsoleCommandShortcut(ExecutorStatic* executor);
Index: code/trunk/src/core/CorePrereqs.h
===================================================================
--- code/trunk/src/core/CorePrereqs.h	(revision 1209)
+++ code/trunk/src/core/CorePrereqs.h	(revision 1214)
@@ -139,4 +139,5 @@
   template <class T>
   class SubclassIdentifier;
+  class TclBind;
   class Tickable;
   template <class T, class O>
Index: code/trunk/src/core/Functor.h
===================================================================
--- code/trunk/src/core/Functor.h	(revision 1209)
+++ code/trunk/src/core/Functor.h	(revision 1214)
@@ -284,23 +284,23 @@
 #define FUNCTOR_EVALUATE_PARAM0
 #define FUNCTOR_EVALUATE_PARAM1 \
-    if (index == 0) param = (P1)param
+    if (index == 0) { P1 temp = param; param = temp; }
 #define FUNCTOR_EVALUATE_PARAM2 \
-    if (index == 0) param = (P1)param; \
-    else if (index == 1) param = (P2)param
+    if (index == 0) { P1 temp = param; param = temp; } \
+    else if (index == 1) { P2 temp = param; param = temp; }
 #define FUNCTOR_EVALUATE_PARAM3 \
-    if (index == 0) param = (P1)param; \
-    else if (index == 1) param = (P2)param; \
-    else if (index == 2) param = (P3)param
+    if (index == 0) { P1 temp = param; param = temp; } \
+    else if (index == 1) { P2 temp = param; param = temp; } \
+    else if (index == 2) { P3 temp = param; param = temp; }
 #define FUNCTOR_EVALUATE_PARAM4 \
-    if (index == 0) param = (P1)param; \
-    else if (index == 1) param = (P2)param; \
-    else if (index == 2) param = (P3)param; \
-    else if (index == 3) param = (P4)param
+    if (index == 0) { P1 temp = param; param = temp; } \
+    else if (index == 1) { P2 temp = param; param = temp; } \
+    else if (index == 2) { P3 temp = param; param = temp; } \
+    else if (index == 3) { P4 temp = param; param = temp; }
 #define FUNCTOR_EVALUATE_PARAM5 \
-    if (index == 0) param = (P1)param; \
-    else if (index == 1) param = (P2)param; \
-    else if (index == 2) param = (P3)param; \
-    else if (index == 3) param = (P4)param; \
-    else if (index == 4) param = (P5)param
+    if (index == 0) { P1 temp = param; param = temp; } \
+    else if (index == 1) { P2 temp = param; param = temp; } \
+    else if (index == 2) { P3 temp = param; param = temp; } \
+    else if (index == 3) { P4 temp = param; param = temp; } \
+    else if (index == 4) { P5 temp = param; param = temp; }
 
 
Index: code/trunk/src/core/InputBuffer.cc
===================================================================
--- code/trunk/src/core/InputBuffer.cc	(revision 1209)
+++ code/trunk/src/core/InputBuffer.cc	(revision 1214)
@@ -39,9 +39,17 @@
     {
         //this->bActivated_ = false;
-        this->allowedChars_ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZäöüÄÖÜ0123456789 \\\"().:,;_-+*/=!?<>[|]";
+        this->allowedChars_ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZäöüÄÖÜ0123456789 \\\"(){}[]<>.:,;_-+*/=!?|$&%^";
         this->keyboard_ = InputManager::getSingleton().getKeyboard();
         this->buffer_ = "";
 
         //this->keyboard_->setEventCallback(this);
+    }
+
+    InputBuffer::InputBuffer(const std::string allowedChars)
+    {
+        //this->bActivated_ = false;
+        this->allowedChars_ = allowedChars;
+        this->keyboard_ = InputManager::getSingleton().getKeyboard();
+        this->buffer_ = "";
     }
 /*
Index: code/trunk/src/core/InputBuffer.h
===================================================================
--- code/trunk/src/core/InputBuffer.h	(revision 1209)
+++ code/trunk/src/core/InputBuffer.h	(revision 1214)
@@ -59,4 +59,5 @@
         public:
             InputBuffer();
+            InputBuffer(const std::string allowedChars);
 
             template <class T>
Index: code/trunk/src/core/InputHandler.cc
===================================================================
--- code/trunk/src/core/InputHandler.cc	(revision 1209)
+++ code/trunk/src/core/InputHandler.cc	(revision 1214)
@@ -85,5 +85,5 @@
       InputHandlerGame::callListeners(e);
     }
-    else if (e.key == OIS::KC_NUMPADENTER)
+    else if (e.key == OIS::KC_UNASSIGNED || e.key == OIS::KC_NUMPADENTER)
     {
       InputManager::getSingleton().setInputMode(IM_KEYBOARD);
Index: code/trunk/src/core/TclBind.cc
===================================================================
--- code/trunk/src/core/TclBind.cc	(revision 1214)
+++ code/trunk/src/core/TclBind.cc	(revision 1214)
@@ -0,0 +1,156 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include <iostream>
+#include <string>
+
+#include "ConsoleCommand.h"
+#include "CommandExecutor.h"
+#include "Debug.h"
+#include "TclBind.h"
+
+namespace orxonox
+{
+    ConsoleCommandShortcutGeneric(tcl, createExecutor(createFunctor(&TclBind::tcl), "tcl", AccessLevel::None));
+
+    TclBind::TclBind()
+    {
+        this->interpreter_ = 0;
+        this->bSetTclLibPath_ = false;
+    }
+
+    TclBind::~TclBind()
+    {
+        if (this->interpreter_)
+            delete this->interpreter_;
+    }
+
+    TclBind& TclBind::getInstance()
+    {
+        static TclBind instance;
+        return instance;
+    }
+
+    void TclBind::setDataPath(const std::string& datapath)
+    {
+        this->tclLibPath_ = datapath + "/tcl";
+        this->bSetTclLibPath_ = true;
+
+        this->createTclInterpreter();
+    }
+
+    void TclBind::createTclInterpreter()
+    {
+        if (this->bSetTclLibPath_ && !this->interpreter_)
+        {
+            this->interpreter_ = new Tcl::interpreter(this->tclLibPath_);
+            this->interpreter_->def("puts", TclBind::puts, Tcl::variadic());
+            this->interpreter_->def("orxonox", TclBind::orxonox, Tcl::variadic());
+            this->interpreter_->def("execute", TclBind::execute, Tcl::variadic());
+            this->interpreter_->eval("proc unknown {args} { return [orxonox $args] }");
+            this->interpreter_->eval("rename exit tclexit; proc exit {} { orxonox exit }");
+        }
+    }
+
+    void TclBind::createNewTclInterpreter()
+    {
+        if (this->interpreter_)
+        {
+            delete this->interpreter_;
+            this->interpreter_ = 0;
+        }
+
+        this->createTclInterpreter();
+    }
+
+    void TclBind::puts(Tcl::object const &args)
+    {
+        COUT(0) << args.get() << std::endl;
+    }
+
+    std::string TclBind::orxonox(Tcl::object const &args)
+    {
+std::cout << "Tcl_execute: args: " << args.get() << std::endl;
+        std::string command = args.get();
+
+        if (command.size() >= 2 && command[0] == '{' && command[command.size() - 1] == '}')
+            command = command.substr(1, command.size() - 2);
+
+        if (!CommandExecutor::execute(command, false))
+            COUT(1) << "Error: Can't execute command \"" << command << "\"!" << std::endl;
+
+        if (CommandExecutor::getLastEvaluation().hasReturnvalue())
+            return CommandExecutor::getLastEvaluation().getReturnvalue().toString();
+
+        return "";
+    }
+
+    void TclBind::execute(Tcl::object const &args)
+    {
+    }
+
+    std::string TclBind::tcl(const std::string& tclcode)
+    {
+        try
+        {
+            std::string output = TclBind::getInstance().interpreter_->eval(tclcode);
+            if (output != "")
+                COUT(0) << "tcl> " << output << std::endl;
+            return output;
+        }
+        catch (Tcl::tcl_error const &e)
+        {
+            COUT(1) << "tcl> Error: " << e.what() << std::endl;
+        }
+        catch (std::exception const &e)
+        {
+            COUT(1) << "Error while executing tcl: " << e.what() << std::endl;
+        }
+
+        return "";
+    }
+
+    bool TclBind::eval(const std::string& tclcode)
+    {
+        try
+        {
+            TclBind::getInstance().interpreter_->eval(tclcode);
+            return true;
+        }
+        catch (Tcl::tcl_error const &e)
+        {
+            COUT(1) << "Error: " << e.what() << std::endl;
+        }
+        catch (std::exception const &e)
+        {
+            COUT(1) << "Error while executing tcl: " << e.what() << std::endl;
+        }
+
+        return false;
+    }
+}
Index: code/trunk/src/core/TclBind.h
===================================================================
--- code/trunk/src/core/TclBind.h	(revision 1214)
+++ code/trunk/src/core/TclBind.h	(revision 1214)
@@ -0,0 +1,64 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _TclBind_H__
+#define _TclBind_H__
+
+#include "CorePrereqs.h"
+
+#include "cpptcl/CppTcl.h"
+
+namespace orxonox
+{
+    class TclBind
+    {
+        public:
+            static TclBind& getInstance();
+
+            void setDataPath(const std::string& datapath);
+            void createTclInterpreter();
+            void createNewTclInterpreter();
+
+            static void puts(Tcl::object const &args);
+            static void execute(Tcl::object const &args);
+            static std::string orxonox(Tcl::object const &args);
+            static std::string tcl(const std::string& tclcode);
+            static bool TclBind::eval(const std::string& tclcode);
+
+        private:
+            TclBind();
+            TclBind(const TclBind& other);
+            ~TclBind();
+
+            Tcl::interpreter* interpreter_;
+            std::string tclLibPath_;
+            bool bSetTclLibPath_;
+    };
+}
+
+#endif /* _TclBind_H__ */
