Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 8456 was 8408, checked in by bensch, 18 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
Line 
1#ifndef _SCRIPT_H
2#define _SCRIPT_H
3
4
5#include "base_object.h"
6
7#include <list>
8
9struct lua_State;
10
11struct WorldObject
12{
13  std::string name;
14  std::string type;
15};
16
17class Script : public BaseObject
18{
19  public:
20    Script(const TiXmlElement* root = NULL);
21    ~Script();
22
23    /// LOADING
24    void loadParams(const TiXmlElement* root);
25
26    void loadFileNoRet(const std::string& filename) { loadFile(filename); };
27    bool loadFile(const std::string& filename);
28    void addObject(const std::string& className, const std::string& objectName);
29
30    /// QUERRYING
31    /** @returns fileName */
32    std::string getFileName() { return currentFile; }
33    lua_State* getLuaState() const { return luaState; }
34
35
36
37    /// EXECUTING
38    // first select function
39    bool selectFunction(std::string& functionName, int retCount);
40
41    // push parameters for luafunction
42    bool  pushParam(int param, std::string& toFunction);
43    bool  pushParam(float param, std::string& toFunction);
44    bool  pushParam(double param, std::string& toFunction);
45
46    // Execute the Function
47    bool executeFunction();
48
49     // get returned values in the order the lua function returns it
50    int   getReturnedInt();
51    bool  getReturnedBool();
52    float getReturnedFloat();
53    void  getReturnedString(std::string& string);
54
55    bool executeFile();
56
57  private:
58
59    int  reportError(int error);                      //!< Get errormessage from the lua stack and print it.
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
62
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
68
69    std::list<WorldObject>  registeredObjects;       //!< The list of all the objects and their type that have been registered with this script
70
71
72
73};
74#endif /* _SCRIPT_H */
Note: See TracBrowser for help on using the repository browser.