Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/terrain/src/lib/script_engine/script.h @ 8420

Last change on this file since 8420 was 8271, checked in by bensch, 18 years ago

merge

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