Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/script_engine/script.h @ 8440

Last change on this file since 8440 was 8408, checked in by bensch, 19 years ago

trunk: merged the script_engine branche back here
merged with command
svn merge https://svn.orxonox.net/orxonox/branches/script_engine . -r8284:HEAD
no conflicts

File size: 2.4 KB
RevLine 
[8075]1#ifndef _SCRIPT_H
2#define _SCRIPT_H
3
4
5#include "base_object.h"
6
[8362]7#include <list>
[8206]8
[8202]9struct lua_State;
[8075]10
[8207]11struct WorldObject
[8206]12{
13  std::string name;
14  std::string type;
15};
16
[8193]17class Script : public BaseObject
[8075]18{
19  public:
[8193]20    Script(const TiXmlElement* root = NULL);
[8075]21    ~Script();
[8362]22
[8193]23    /// LOADING
24    void loadParams(const TiXmlElement* root);
[8075]25
[8193]26    void loadFileNoRet(const std::string& filename) { loadFile(filename); };
27    bool loadFile(const std::string& filename);
[8206]28    void addObject(const std::string& className, const std::string& objectName);
[8362]29
[8206]30    /// QUERRYING
[8193]31    /** @returns fileName */
32    std::string getFileName() { return currentFile; }
33    lua_State* getLuaState() const { return luaState; }
34
35
[8362]36
[8193]37    /// EXECUTING
38    // first select function
[8075]39    bool selectFunction(std::string& functionName, int retCount);
[8193]40
[8075]41    // push parameters for luafunction
[8093]42    bool  pushParam(int param, std::string& toFunction);
[8075]43    bool  pushParam(float param, std::string& toFunction);
44    bool  pushParam(double param, std::string& toFunction);
[8193]45
46    // Execute the Function
47    bool executeFunction();
[8362]48
[8408]49     // get returned values in the order the lua function returns it
[8093]50    int   getReturnedInt();
[8075]51    bool  getReturnedBool();
52    float getReturnedFloat();
[8155]53    void  getReturnedString(std::string& string);
[8075]54
[8193]55    bool executeFile();
[8075]56
57  private:
58
[8206]59    int  reportError(int error);                      //!< Get errormessage from the lua stack and print it.
[8207]60    bool classIsRegistered(const std::string& type);  //!< Checks wheter the class "type" has already been registered with the script
61    bool objectIsAdded(const std::string& name);      //!< Checks wheter the object "name" has already been added to the script
[8075]62
[8206]63    lua_State*              luaState;                //!< The lua_State that the Script works on
64    std::string             currentFile;             //!< The file that is loaded in the script
65    std::string             currentFunction;         //!< The name of the current active function (the one that gets the pushed parameter)
66    int                     argumentCount;           //!< Number of arguments for the current function
67    int                     returnCount;             //!< Number of return values of the current function
[8362]68
[8207]69    std::list<WorldObject>  registeredObjects;       //!< The list of all the objects and their type that have been registered with this script
[8075]70
71
72
73};
74#endif /* _SCRIPT_H */
Note: See TracBrowser for help on using the repository browser.