Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 9, 2009, 12:43:12 PM (14 years ago)
Author:
rgrieder
Message:

Added LuaFunctor that can execute arbitrary lua code.
Also added LuaState::createLuaFunctor(std::string) and implemented that for the keybindings menu.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/libraries/core/LuaState.h

    r6150 r6281  
    4040
    4141#include "util/ScopeGuard.h"
     42#include "core/Functor.h"
    4243#include "ToluaInterface.h"
    4344
    44 // tolua_begin
    45 namespace orxonox
    46 {
     45namespace orxonox // tolua_export
     46{ // tolua_export
     47    class Functor; // tolua_export
     48
     49    //! Functor subclass that simply executes code with 0 arguments.
     50    class _CoreExport LuaFunctor : public Functor
     51    {
     52        public:
     53            LuaFunctor(const std::string& code, LuaState* luaState);
     54            void operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null);
     55            void evaluateParam(unsigned int index, MultiType& param) const {}
     56
     57        private:
     58            std::string code_;
     59            LuaState*   lua_;
     60    };
     61
     62
    4763    /**
    4864    @brief
    4965        Representation of an interface to lua
    5066    */
    51     class _CoreExport LuaState
    52     {
    53 // tolua_end
     67    class _CoreExport LuaState // tolua_export
     68    { // tolua_export
    5469    public:
    5570        LuaState();
     
    7489        void setDefaultResourceInfo(const shared_ptr<ResourceInfo>& sourceFileInfo) { this->sourceFileInfo_ = sourceFileInfo; }
    7590        const shared_ptr<ResourceInfo>& getDefaultResourceInfo() { return this->sourceFileInfo_; }
     91
     92        Functor* createLuaFunctor(const std::string& code) { return new LuaFunctor(code, this); } // tolua_export
    7693
    7794        static bool addToluaInterface(int (*function)(lua_State*), const std::string& name);
Note: See TracChangeset for help on using the changeset viewer.