Changeset 8202 in orxonox.OLD for branches/script_engine/src
- Timestamp:
- Jun 7, 2006, 4:39:04 PM (18 years ago)
- Location:
- branches/script_engine/src/lib/script_engine
- Files:
-
- 7 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/script_engine/src/lib/script_engine/Makefile.am
r8193 r8202 15 15 script.cc\ 16 16 script_manager.cc\ 17 script able.cc \17 script_class.cc \ 18 18 script_trigger.cc 19 19 … … 24 24 script.h\ 25 25 script_manager.h\ 26 script able.h \26 script_class.h \ 27 27 script_trigger.h 28 28 -
branches/script_engine/src/lib/script_engine/script.cc
r8199 r8202 1 1 #include "script.h" 2 #include "scriptable.h" 2 #include "script_class.h" 3 #include "luaincl.h" 4 3 5 4 6 #include "loading/load_param.h" … … 90 92 void Script::addObject(const std::string& className, const std::string& objectName) 91 93 { 92 BaseObject* scriptClass = ClassList::getObject(className, CL_SCRIPT ABLE);94 BaseObject* scriptClass = ClassList::getObject(className, CL_SCRIPT_CLASS); 93 95 if (scriptClass != NULL) 94 96 { 95 static_cast<Script able*>(scriptClass)->registerClass(this);97 static_cast<ScriptClass*>(scriptClass)->registerClass(this); 96 98 97 99 BaseObject* object = ClassList::getObject(objectName, className); 98 100 if (object != NULL) 99 101 { 100 static_cast<Script able*>(scriptClass)->insertObject(this, object, false);102 static_cast<ScriptClass*>(scriptClass)->insertObject(this, object, false); 101 103 } 102 104 } -
branches/script_engine/src/lib/script_engine/script.h
r8193 r8202 5 5 #include "base_object.h" 6 6 7 #include "luaincl.h" 8 7 struct lua_State; 9 8 10 9 class Script : public BaseObject -
branches/script_engine/src/lib/script_engine/script_class.cc
r8193 r8202 16 16 //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ 17 17 18 #include "script able.h"18 #include "script_class.h" 19 19 20 20 using namespace std; … … 25 25 * @todo this constructor is not jet implemented - do it 26 26 */ 27 Script able::Scriptable(const std::string& name, ClassID classID)27 ScriptClass::ScriptClass(const std::string& name, ClassID classID) 28 28 : BaseObject(name) 29 29 { 30 this->setClassID(CL_SCRIPT ABLE, "Scriptable");30 this->setClassID(CL_SCRIPT_CLASS, "ScriptClass"); 31 31 this->classID = classID; 32 33 34 32 } 35 33 … … 38 36 * standard deconstructor 39 37 */ 40 Script able::~Scriptable()38 ScriptClass::~ScriptClass () 41 39 { 42 40 // delete what has to be deleted here -
branches/script_engine/src/lib/script_engine/script_class.h
r8197 r8202 1 1 /*! 2 * @file script able.h2 * @file script_class.h 3 3 * @brief Definition of ... 4 4 */ 5 5 6 #ifndef _SCRIPT ABLE_H7 #define _SCRIPT ABLE_H6 #ifndef _SCRIPT_CLASS_H 7 #define _SCRIPT_CLASS_H 8 8 9 9 #include "base_object.h" … … 25 25 26 26 //! A class for ... 27 class Script able: protected BaseObject27 class ScriptClass : protected BaseObject 28 28 { 29 29 30 30 public: 31 Script able(const std::string& name, ClassID classID);32 virtual ~Script able();31 ScriptClass(const std::string& name, ClassID classID); 32 virtual ~ScriptClass(); 33 33 34 34 bool operator==(const std::string& name) { return (this->getName() == name); } … … 46 46 47 47 template <class T> 48 class tScriptable : public Script able48 class tScriptable : public ScriptClass 49 49 { 50 50 tScriptable(const std::string& name, ClassID classID) 51 : Script able(name, classID)51 : ScriptClass(name, classID) 52 52 { } 53 53 … … 67 67 68 68 69 #endif /* _SCRIPT ABLE_H */69 #endif /* _SCRIPT_CLASS_H */ -
branches/script_engine/src/lib/script_engine/script_manager.cc
r8193 r8202 2 2 #include <list> 3 3 4 #include "script.h" 4 5 5 #include "script_manager.h" 6 6 #include "lunar.h" 7 8 #include "class_list.h" 9 10 #include "script.h" 11 #include "script_trigger.h" 12 #include "luaincl.h" 13 #include "loading/load_param.h" 14 #include "parser/tinyxml/tinyxml.h" 15 7 16 8 17 … … 23 32 //BaseObject::loadParams(root); 24 33 25 const TiXmlElement* scripttrigger= root->FirstChildElement("ScriptTrigger"); 26 27 while( scripttrigger != NULL) 28 { 29 //TODO: generate script trigger in factory and let them load their params. 30 scripttrigger = scripttrigger->NextSiblingElement("ScriptTrigger"); 31 } 32 33 34 LoadParamXML(root, "Scripts", this, ScriptManager, createScriptList); 35 } 36 37 void ScriptManager::tick(float timestep) 38 { 34 LoadParamXML(root, "ScriptTriggers", this, ScriptManager, createTriggers); 35 36 LoadParamXML(root, "Scripts", this, ScriptManager, createScripts); 39 37 } 40 38 … … 42 40 void ScriptManager::init() 43 41 { 44 42 //this->setClassID(""); 43 this->setName("ScriptManager"); 44 45 this->scripts = NULL; 46 this->triggers = NULL; 45 47 } 46 48 47 49 48 void ScriptManager::createScript List(const TiXmlElement* scripts)50 void ScriptManager::createScripts(const TiXmlElement* scripts) 49 51 { 50 52 … … 54 56 } 55 57 LOAD_PARAM_END_CYCLE(object); 56 57 58 /*59 const TiXmlElement* script = scripts->FirstChildElement();60 58 61 PRINTF(4)("Creating scriptlist\n"); 59 } 62 60 63 while( script != NULL) 61 void ScriptManager::createTriggers(const TiXmlElement* triggers) 62 { 63 LOAD_PARAM_START_CYCLE(triggers, object); 64 64 { 65 { // scope to make the LoadParam work 66 LoadParam(script, "file", this, ScriptManager, setCurrentScriptFile) 67 .describe("the fileName of the script, that should be loaded into this world") 68 .defaultValues(""); 69 } 70 71 if(!currentScript.name.empty()) // if LoadParam didn't fail... fill the object list with the needed objects 72 { 73 74 LOAD_PARAM_START_CYCLE(script, object); 75 { 76 // LoadParam_CYCLE(object, "object", this, ScriptManager, addObjectToScript) 77 // .describe("The name of an object that is needed by a script"); 78 } 79 LOAD_PARAM_END_CYCLE(object); 80 81 scriptList.push_back(currentScript); 82 } 83 84 script = script->NextSiblingElement("Script"); 85 86 }*/ 87 65 new ScriptTrigger(object); 66 } 67 LOAD_PARAM_END_CYCLE(object); 88 68 89 69 } … … 104 84 } 105 85 86 87 bool ScriptManager::getScripts() 88 { 89 return (this->scripts != NULL || (this->scripts = ClassList::getList(CL_SCRIPT)) != NULL); 90 } 91 92 93 -
branches/script_engine/src/lib/script_engine/script_manager.h
r8193 r8202 3 3 4 4 #include <list> 5 #include <string>6 5 6 #include "base_object.h" 7 7 #include "script.h" 8 #include "base_object.h"9 #include "luaincl.h"10 #include "loading/load_param.h"11 8 12 9 … … 24 21 virtual void loadParams(const TiXmlElement* root); 25 22 26 void tick(float timestep);27 23 28 24 Script* getScriptByFile(std::string& file); … … 33 29 34 30 void init(); 35 void createScriptList(const TiXmlElement* scripts); 36 void addObjectToScript(const std::string object); 37 31 void createScripts(const TiXmlElement* scripts); 32 void createTriggers(const TiXmlElement* triggers); 33 34 bool getTriggers(); 35 bool getScripts(); 38 36 39 37 static ScriptManager* singletonRef; //!< Reference to this class 40 38 41 const std::list<BaseObject*>* trigger List;39 const std::list<BaseObject*>* triggers; 42 40 43 const std::list<BaseObject*>* scriptableClasses;44 41 const std::list<BaseObject*>* scripts; 45 42 -
branches/script_engine/src/lib/script_engine/script_trigger.cc
r8199 r8202 1 1 #include "script_trigger.h" 2 #include "class_list.h" 3 #include "script.h" 2 4 3 5 4 ScriptTrigger::ScriptTrigger( )6 ScriptTrigger::ScriptTrigger(const TiXmlElement* root) 5 7 { 6 scriptCalled = false; 7 callScript = false; 8 triggered = false; 8 scriptCalled = false; 9 callScript = false; 10 triggered = false; 11 loadParams(root); 12 13 9 14 } 10 15 … … 16 21 void ScriptTrigger::loadParams(const TiXmlElement* root) 17 22 { 18 WorldEntity ::loadParams(root);23 WorldEntity ::loadParams(root); 19 24 20 25 /*{ LoadParam(root, "file", this, ScriptTrigger, setScript) … … 55 60 else 56 61 { 57 PRINTF(2)("Target %s for %s::%s does not Exist\n", ta get.c_str(), this->getClassName(), this->getName());62 PRINTF(2)("Target %s for %s::%s does not Exist\n", target.c_str(), this->getClassName(), this->getName()); 58 63 } 59 64 } -
branches/script_engine/src/lib/script_engine/script_trigger.h
r8199 r8202 12 12 { 13 13 public: 14 ScriptTrigger( );14 ScriptTrigger(const TiXmlElement* root); 15 15 ~ScriptTrigger(); 16 16 … … 21 21 22 22 void setTarget(const std::string& targetName); 23 24 void setTarget(WorldEntity* target) { if(target!=NULL) this->target=target;if(worldEntityIsParent)this->setParent(target); } 25 void setTargetName(std::string& name){ this->targetName = name; } 23 void setTarget(WorldEntity* target) { if(target!=NULL) this->target=target; } 24 26 25 void setCallOnce(bool call) { this->callOnce = call;} 27 26 void setRadius(float radius) { if(radius>0) this->radius = radius;} … … 30 29 void setFunction(std::string& function){this->functionName = function;} 31 30 32 std::string getTargetName() {return targetName;}31 std::string getTargetName(); 33 32 34 33 private: … … 36 35 std::string parentName; 37 36 WorldEntity* target; 38 std::string targetName;39 37 bool worldEntityIsParent; 40 38 bool callOnce; 41 bool scriptCalled;42 float radius;43 float delay;44 std::string scriptFile;45 std::string functionName;39 bool scriptCalled; 40 float radius; 41 float delay; 42 std::string scriptFile; 43 std::string functionName; 46 44 47 45 bool callScript;
Note: See TracChangeset
for help on using the changeset viewer.