Index: trunk/src/world_entities/Makefile.am
===================================================================
--- trunk/src/world_entities/Makefile.am	(revision 10618)
+++ trunk/src/world_entities/Makefile.am	(revision 10622)
@@ -27,5 +27,6 @@
  		     effects/trail.cc\
 		     elements/glgui_energywidget.cc\
- 		     elements/glgui_energywidgetvertical.cc
+ 		     elements/glgui_energywidgetvertical.cc\
+		     script_triggers/script_trigger.cc
 
 
@@ -51,5 +52,6 @@
   		 effects/wobblegrid.h\
   		 elements/glgui_energywidget.h\
- 		 elements/glgui_energywidgetvertical.h
+ 		 elements/glgui_energywidgetvertical.h\
+		 script_triggers/script_trigger.h
 
 
Index: trunk/src/world_entities/WorldEntities.am
===================================================================
--- trunk/src/world_entities/WorldEntities.am	(revision 10618)
+++ trunk/src/world_entities/WorldEntities.am	(revision 10622)
@@ -106,5 +106,9 @@
                 world_entities/tools/sound_entity.cc \
                 world_entities/tools/camera.cc \
-                world_entities/tools/script_trigger.cc \
+		\
+                world_entities/script_triggers/script_trigger.cc \
+                world_entities/script_triggers/space_trigger.cc \
+		world_entities/script_triggers/tick_trigger.cc \
+		world_entities/script_triggers/time_trigger.cc \
                 \
                 \
@@ -227,5 +231,7 @@
                 effects/blink.h \
                 \
-                script_trigger.h \
+                script_triggers/space_trigger.h \
+		script_triggers/tick_trigger.h \
+		script_triggers/time_trigger.h \
                 \
                 \
Index: trunk/src/world_entities/script_triggers/script_trigger.cc
===================================================================
--- trunk/src/world_entities/script_triggers/script_trigger.cc	(revision 10622)
+++ trunk/src/world_entities/script_triggers/script_trigger.cc	(revision 10622)
@@ -0,0 +1,212 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+### File Specific:
+   main-programmer: Silvan Nellen
+   co-programmer: ...
+*/
+
+
+#include "script_trigger.h"
+#include "script.h"
+
+#include "state.h"
+#include "debug.h"
+ObjectListDefinition(ScriptTrigger);
+
+
+/**
+ * Constructs a new ScriptTrigger.
+ * @param root the xml element to load the parameters from.
+ *
+ */
+ScriptTrigger::ScriptTrigger(const TiXmlElement* root)
+{
+  this->registerObject(this, ScriptTrigger::_objectList);
+  this->toList(OM_COMMON);
+
+  returnCount = 1;
+  scriptFinished = false;
+  doDebugDraw = false;
+
+  scriptCalled = false;
+  scriptIsOk = false;
+  executionStopped = false; // true when something goes wrong and the trigger has to be stopped
+  addToScript = false;
+
+}
+
+/**
+ * Deletes the ScriptTrigger.
+ *
+ */
+ScriptTrigger::~ScriptTrigger()
+{
+
+}
+
+/**
+ * Reads the values from the tml element and sets them.
+ * @param root the xml element to load the parameters from.
+ *
+ */
+void ScriptTrigger::loadParams(const TiXmlElement* root)
+{
+
+  WorldEntity ::loadParams(root);
+
+  LoadParam(root, "file", this, ScriptTrigger, setScript)
+      .describe("the fileName of the script, that should be triggered by this script trigger")
+      .defaultValues("");
+  LoadParam(root, "function", this, ScriptTrigger, setFunction)
+      .describe("the function of the script, that should be triggered by this script trigger")
+      .defaultValues("");
+  LoadParam(root, "abs-coor", this, ScriptTrigger, setAbsCoor)
+      .describe("where this script trigger should be located")
+      .defaultValues("");
+  LoadParam(root, "triggerparent", this, ScriptTrigger, setTriggerParent)
+      .describe("The name of the parent as it is in the *.oxw file")
+      .defaultValues("");
+  LoadParam(root, "debugdraw", this, ScriptTrigger, setDebugDraw)
+      .describe("")
+      .defaultValues(false);
+  LoadParam(root, "addtoscript", this, ScriptTrigger, setAddToScript)
+      .describe("True if this scripttrigger should be aviable in the script")
+      .defaultValues(false);
+}
+
+
+/**
+ * Sets the parent of the trigger.
+ * @param parent The parent.
+ */
+void ScriptTrigger::setTriggerParent(const std::string& parent)
+{
+  WorldEntity* parentEntity = WorldEntity::objectList().getObject(parent);
+
+  if (parentEntity != NULL)
+  {
+    this->setParent(parentEntity);
+    this->setParentMode(PNODE_MOVEMENT);
+  }
+  else
+  {
+    PRINTF(2)("ERROR SCRTIPTTRIGGER : Parent %s for %s::%s does not Exist\n", parent.c_str(), this->getClassCName(), this->getCName());
+  }
+}
+
+
+void ScriptTrigger::executeAction(float timestep)
+{
+  if(executionStopped && scriptIsOk) // If the script has been loaded correctly but something is wrong with the settings of the trigger
+  {
+   PRINT(1)("ERROR SCRTIPTTRIGGER: Something went wrong while executing %s in %s . Execution stopped! \n", functionName.c_str(), script->getFileName().c_str());
+   return;
+  }
+
+  if(scriptIsOk)
+  {
+       //testScriptingFramework();
+    if(!(script->selectFunction(this->functionName,returnCount)) )
+     {
+      PRINT(1)("ERROR SCRTIPTTRIGGER : Selection of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str());
+      executionStopped = true; //Since the triggersettings won't change on runtime, it makes no sense to call the function again.
+      return;
+     }
+
+    if (! (script->pushParam( timestep, this->functionName)) )
+     {
+      executionStopped = true; //Since the triggersettings won't change on runtime, it makes no sense to call the function again.
+      return;
+     }
+    if( !(script->executeFunction()) )
+     {
+      PRINT(1)("ERROR SCRTIPTTRIGGER : Execution of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str());
+      executionStopped = true; //Since the triggersettings won't change on runtime, it makes no sense to call the function again.
+      return;
+     }
+    scriptFinished = script->getReturnedBool();
+  }
+  else
+  printf("ERROR SCRTIPTTRIGGER : Script could not be executed !\n");
+
+
+}
+
+
+void ScriptTrigger::setScript(const std::string& filename)
+{
+
+  std::string file = filename;
+
+  unsigned int seperation =  filename.find_last_of('/');
+  if (seperation != std::string::npos)
+  {
+    file = filename.substr( seperation+1 );
+  }
+
+  ScriptManager* scriptManager = State::getScriptManager();
+  if (scriptManager != NULL)
+  {
+
+    script = scriptManager->getScriptByFile(file);
+    if(script != NULL)
+    {
+      scriptIsOk = true;
+    }
+    else
+    printf("ERROR SCRTIPTTRIGGER : Could not find the wrapperobject of %s , the script won't be executed ! \n", file.c_str());
+  }
+}
+
+/*
+ void ScriptTrigger::testScriptingFramework()
+{
+   std::string file("lunartest2.lua");
+   //get script
+   Script* script = State::getScriptManager()->getScriptByFile(file);
+   printf("-------------------------- top of the stack:%i\n",lua_gettop(script->getLuaState()));
+
+      //execute a function
+   printf("----------- main -----------\n");
+   std::string main("main");
+   if( script->selectFunction(main,3))
+     printf("function %s selected\n",main.c_str());
+
+   script->pushParam(3.14159,main);
+   printf("-------------------------- top of the stack:%i\n",lua_gettop(script->getLuaState()));
+   script->executeFunction();
+
+   int ret = script->getReturnedInt();
+   printf("main returned %i\n",ret);
+
+   if(script->getReturnedBool())
+     printf("main returned true\n");
+   else
+     printf("main returned false\n");
+
+   float retf = script->getReturnedFloat();
+   printf("main returned %f\n",retf);
+
+
+   printf("-------------------------- top of the stack:%i\n",lua_gettop(script->getLuaState()));
+      //execute a 2nd function
+   printf("----------- test -----------\n");
+   std::string test("test");
+   if( script->selectFunction(test,0))
+     printf("function %s selected\n",test.c_str());
+
+   script->executeFunction();
+
+
+      //if(argc>1) lua_dofile(script.getLuaState(), argv[1]);
+   printf("-------------------------- top of the stack:%i\n",lua_gettop(script->getLuaState()));
+
+}*/
Index: trunk/src/world_entities/script_triggers/script_trigger.h
===================================================================
--- trunk/src/world_entities/script_triggers/script_trigger.h	(revision 10622)
+++ trunk/src/world_entities/script_triggers/script_trigger.h	(revision 10622)
@@ -0,0 +1,63 @@
+/*!
+ * @file scrip_trigger.h
+ *  triggeres a script
+ */
+
+#ifndef _SCRIPT_TRIGGER_H
+#define _SCRIPT_TRIGGER_H
+
+#include <string>
+
+#include "world_entity.h"
+#include "loading/load_param.h"
+#include "script_manager.h"
+#include "script.h"
+
+
+class ScriptTrigger : public WorldEntity
+{
+  ObjectListDeclaration(ScriptTrigger);
+  public:
+    ScriptTrigger(const TiXmlElement* root = NULL);
+    ~ScriptTrigger();
+
+    ///LOADING
+    virtual void loadParams(const TiXmlElement* root);
+
+
+    /// DO WORK
+    virtual void tick(float timestep) = 0;
+    virtual void executeAction(float timestep);
+    void testScriptingFramework();
+
+    /// SET MEMBER
+    void setScript(const std::string& file);
+    void setFunction(const std::string& function){ this->functionName = function;}
+    void setDebugDraw(const bool draw) { this->doDebugDraw = draw; }
+    void setAddToScript(const bool add) { this->addToScript = add; }
+    void setTriggerParent(const std::string& name);
+    
+    
+    ///DRAWING
+    void draw()const{if(doDebugDraw)this->debugDraw();};
+
+  private:
+
+    bool         doDebugDraw;
+    
+    //for internal use
+    bool         executionStopped;   // true when something goes wrong and the trigger had to be stopped
+    int          returnCount;        //TODO: set return count correctly
+    
+  protected:
+    Script*      script;
+    std::string  functionName;
+    bool         scriptCalled;
+    bool         scriptIsOk;
+    bool         scriptFinished;
+    bool         addToScript;
+
+};
+
+
+#endif
Index: trunk/src/world_entities/script_triggers/space_trigger.cc
===================================================================
--- trunk/src/world_entities/script_triggers/space_trigger.cc	(revision 10622)
+++ trunk/src/world_entities/script_triggers/space_trigger.cc	(revision 10622)
@@ -0,0 +1,154 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+### File Specific:
+   main-programmer: Silvan Nellen
+   co-programmer: ...
+*/
+
+#include "util/loading/factory.h"
+#include "space_trigger.h"
+#include "debug.h"
+
+ObjectListDefinition(SpaceTrigger);
+CREATE_FACTORY(SpaceTrigger);
+
+CREATE_SCRIPTABLE_CLASS(SpaceTrigger,
+            // Coordinates
+                        addMethod("setAbsCoor", Executor3<PNode, lua_State*,float,float,float>(&PNode::setAbsCoor))
+                            ->addMethod("getAbsCoorX", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorX))
+                            ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY))
+                            ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ))
+            //Properties
+                            ->addMethod("setName", Executor1<BaseObject, lua_State*, const std::string&>(&BaseObject::setName))
+                            ->addMethod("setTarget", Executor1<SpaceTrigger, lua_State*, const std::string&>(&SpaceTrigger::setTarget))
+                            ->addMethod("setTriggerParent", Executor1<ScriptTrigger, lua_State*, const std::string&>(&ScriptTrigger::setTriggerParent))
+                            ->addMethod("setTriggerRemains", Executor1<SpaceTrigger, lua_State*, bool>(&SpaceTrigger::setTriggerRemains))
+                            ->addMethod("setInvert", Executor1<SpaceTrigger, lua_State*, bool>(&SpaceTrigger::setInvert))
+                            ->addMethod("setRadius", Executor1<SpaceTrigger, lua_State*, float>(&SpaceTrigger::setRadius))
+                            ->addMethod("setScript", Executor1<ScriptTrigger, lua_State*, const std::string&>(&ScriptTrigger::setScript))
+                            ->addMethod("setFunction", Executor1<ScriptTrigger, lua_State*, const std::string&>(&ScriptTrigger::setFunction))
+                            ->addMethod("setDebugDraw", Executor1<ScriptTrigger, lua_State*, bool>(&ScriptTrigger::setDebugDraw))
+                            ->addMethod("setAddToScript", Executor1<ScriptTrigger, lua_State*, bool>(&ScriptTrigger::setAddToScript))
+                       );
+
+
+/**
+ * Constructs a new SpaceTrigger.
+ * @param root the xml element to load the parameters from.
+ *
+ */
+SpaceTrigger::SpaceTrigger(const TiXmlElement* root)
+{
+  this->registerObject(this, SpaceTrigger::_objectList);
+
+  radius = 10;
+  invert = false;
+  triggerRemains = true;
+ 
+   if(root != NULL)
+  {
+    loadParams(root);
+
+    if(addToScript && scriptIsOk)
+    {
+      script->addObject( "SpaceTrigger", this->getName());
+    }
+
+  }
+
+}
+
+/**
+ * Deletes the SpaceTrigger.
+ *
+ */
+SpaceTrigger::~SpaceTrigger()
+{
+
+}
+
+/**
+ * Reads the values from the tml element and sets them.
+ * @param root the xml element to load the parameters from.
+ *
+ */
+void SpaceTrigger::loadParams(const TiXmlElement* root)
+{
+
+  ScriptTrigger ::loadParams(root);
+
+ 
+  LoadParam(root, "radius", this, SpaceTrigger, setRadius)
+      .describe("the fileName of the script, that should be triggered by this script trigger")
+      .defaultValues(0);
+  LoadParam(root, "worldentity", this, SpaceTrigger, setTarget)
+      .describe("The name of the target as it is in the *.oxw file")
+      .defaultValues("");
+  LoadParam(root, "invert", this, SpaceTrigger, setInvert)
+      .describe("")
+      .defaultValues(false);
+  LoadParam(root, "triggerRemains", this, SpaceTrigger, setTriggerRemains)
+      .describe("")
+      .defaultValues(true);
+ 
+}
+
+
+/**
+ * Sets the target(a world entity) of the SpaceTrigger. If the distance between the target and this trigger is smaller than the radius, the script gets triggered.
+ * @param target The worldentity that the script supervises.
+ */
+void SpaceTrigger::setTarget(const std::string& target)
+{
+
+  WorldEntity* targetEntity = WorldEntity::objectList().getObject(target);
+  if (targetEntity != NULL)
+  {
+    this->setTarget(targetEntity);
+  }
+  else
+  {
+    PRINTF(2)("ERROR SCRTIPTTRIGGER : Target %s for %s::%s does not Exist\n", target.c_str(), this->getClassCName(), this->getCName());
+  }
+}
+
+
+void SpaceTrigger::tick(float timestep)
+{
+  if( scriptFinished ) return;
+
+  if(triggerRemains && scriptCalled )
+  {
+    executeAction(timestep);
+    return;
+  }
+
+  if( this->target != NULL)
+  {
+    if( !invert && this->distance(target) < radius)
+    {
+    //printf("Distance is %f \n", this->distance(target));
+      executeAction(timestep);
+      scriptCalled = true;
+      return;
+
+    }
+    else if( invert && this->distance(target) > radius)
+    {
+      executeAction(timestep);
+      scriptCalled = true;
+      return;
+    }
+  }
+}
+
+
+
Index: trunk/src/world_entities/script_triggers/space_trigger.h
===================================================================
--- trunk/src/world_entities/script_triggers/space_trigger.h	(revision 10622)
+++ trunk/src/world_entities/script_triggers/space_trigger.h	(revision 10622)
@@ -0,0 +1,50 @@
+/*!
+ * @file space_trigger.h
+ *  triggeres a script when a world_entity is in range
+ */
+
+#ifndef _SPACE_TRIGGER_H
+#define _SPACE_TRIGGER_H
+
+#include <string>
+
+#include "script.h"
+#include "script_class.h"
+#include "script_trigger.h"
+
+class SpaceTrigger : public ScriptTrigger
+{
+  ObjectListDeclaration(SpaceTrigger);
+  
+  public:
+    SpaceTrigger(const TiXmlElement* root = NULL);
+    ~SpaceTrigger();
+    
+    ///LOADING
+    virtual void loadParams(const TiXmlElement* root);
+
+
+    /// DO WORK
+    virtual void tick(float timestep);
+
+
+    /// SET MEMBER
+    void setTarget(const std::string& targetName);
+    void setTarget(WorldEntity* target) { if(target!=NULL) this->target=target; }
+    void setTriggerRemains(const bool lasts) { this->triggerRemains = lasts; }
+    void setInvert(const bool inv) { this->invert = invert; }
+    void setRadius(const float radius) { if(radius>0) this->radius = radius; }
+
+
+  private:
+
+    WorldEntity* target;
+    bool         triggerRemains;
+    bool         invert;
+    float        radius;
+
+
+};
+
+
+#endif
Index: trunk/src/world_entities/script_triggers/tick_trigger.cc
===================================================================
--- trunk/src/world_entities/script_triggers/tick_trigger.cc	(revision 10622)
+++ trunk/src/world_entities/script_triggers/tick_trigger.cc	(revision 10622)
@@ -0,0 +1,76 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+### File Specific:
+   main-programmer: Silvan Nellen
+   co-programmer: ...
+*/
+
+#include "util/loading/factory.h"
+#include "script_class.h"
+#include "tick_trigger.h"
+#include "debug.h"
+
+ObjectListDefinition(TickTrigger);
+CREATE_FACTORY(TickTrigger);
+
+CREATE_SCRIPTABLE_CLASS(TickTrigger,
+             // Coordinates
+			addMethod("setAbsCoor", Executor3<PNode, lua_State*,float,float,float>(&PNode::setAbsCoor))
+			    ->addMethod("getAbsCoorX", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorX))
+			    ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY))
+			    ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ))
+             //Properties
+			    ->addMethod("setName", Executor1<BaseObject, lua_State*, const std::string&>(&BaseObject::setName))
+			    ->addMethod("setScript", Executor1<ScriptTrigger, lua_State*, const std::string&>(&ScriptTrigger::setScript))
+			    ->addMethod("setFunction", Executor1<ScriptTrigger, lua_State*, const std::string&>(&ScriptTrigger::setFunction))
+			    ->addMethod("setDebugDraw", Executor1<ScriptTrigger, lua_State*, bool>(&ScriptTrigger::setDebugDraw))
+             );
+
+
+/**
+ * Constructs a new TickTrigger.
+ * @param root the xml element to load the parameters from.
+ *
+ */
+TickTrigger::TickTrigger(const TiXmlElement* root)
+{
+  this->registerObject(this, TickTrigger::_objectList);
+
+  if(root != NULL)
+   {
+    loadParams(root);
+
+    if(addToScript && scriptIsOk)
+    {
+      script->addObject( "TickTrigger", this->getName());
+    }
+
+   }
+
+}
+
+/**
+ * Deletes the TickTrigger.
+ *
+ */
+TickTrigger::~TickTrigger()
+{
+
+}
+
+
+void TickTrigger::tick(float timestep)
+{
+  if( scriptFinished ) return;
+
+  this->executeAction(timestep);
+      
+}
Index: trunk/src/world_entities/script_triggers/tick_trigger.h
===================================================================
--- trunk/src/world_entities/script_triggers/tick_trigger.h	(revision 10622)
+++ trunk/src/world_entities/script_triggers/tick_trigger.h	(revision 10622)
@@ -0,0 +1,28 @@
+/*!
+ * @file tick_trigger.h
+ *  always triggeres a script
+ */
+
+#ifndef _TICK_TRIGGER_H
+#define _TICK_TRIGGER_H
+
+#include <string>
+
+#include "script.h"
+#include "script_trigger.h"
+
+class TickTrigger : public ScriptTrigger
+{
+  ObjectListDeclaration(TickTrigger);
+  
+  public:
+    TickTrigger(const TiXmlElement* root = NULL);
+    ~TickTrigger();
+
+    /// DO WORK
+    virtual void tick(float timestep);
+
+};
+
+
+#endif
Index: trunk/src/world_entities/script_triggers/time_trigger.cc
===================================================================
--- trunk/src/world_entities/script_triggers/time_trigger.cc	(revision 10622)
+++ trunk/src/world_entities/script_triggers/time_trigger.cc	(revision 10622)
@@ -0,0 +1,111 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+### File Specific:
+   main-programmer: Silvan Nellen
+   co-programmer: ...
+*/
+
+#include "util/loading/factory.h"
+#include "time_trigger.h"
+#include "debug.h"
+#include "script_class.h"
+
+ObjectListDefinition(TimeTrigger);
+CREATE_FACTORY(TimeTrigger);
+
+CREATE_SCRIPTABLE_CLASS(TimeTrigger,
+             // Coordinates
+                        addMethod("setAbsCoor", Executor3<PNode, lua_State*,float,float,float>(&PNode::setAbsCoor))
+                            ->addMethod("getAbsCoorX", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorX))
+                            ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY))
+                            ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ))
+             //Properties
+                            ->addMethod("setName", Executor1<BaseObject, lua_State*, const std::string&>(&BaseObject::setName))
+                            ->addMethod("setScript", Executor1<ScriptTrigger, lua_State*, const std::string&>(&ScriptTrigger::setScript))
+                            ->addMethod("setFunction", Executor1<ScriptTrigger, lua_State*, const std::string&>(&ScriptTrigger::setFunction))
+                            ->addMethod("setDebugDraw", Executor1<ScriptTrigger, lua_State*, bool>(&ScriptTrigger::setDebugDraw))
+                            ->addMethod("start", Executor0<TimeTrigger, lua_State*>(&TimeTrigger::start))
+                            ->addMethod("stop", Executor0<TimeTrigger, lua_State*>(&TimeTrigger::stop))
+                            ->addMethod("reset", Executor0<TimeTrigger, lua_State*>(&TimeTrigger::reset))
+                            ->addMethod("setDelay", Executor1<TimeTrigger, lua_State*, float>(&TimeTrigger::setDelay))
+                           
+                       );
+
+
+/**
+ * Constructs a new TimeTrigger.
+ * @param root the xml element to load the parameters from.
+ *
+ */
+TimeTrigger::TimeTrigger(const TiXmlElement* root)
+{
+  this->registerObject(this, TimeTrigger::_objectList);
+  
+  this->delay = 1;
+  this->currentTime = delay;
+  this->isStopped = true;
+
+  if(root != NULL)
+  {
+    loadParams(root);
+
+    if(addToScript && scriptIsOk)
+    {
+      script->addObject( "TimeTrigger", this->getName());
+    }
+
+  }
+
+}
+
+/**
+ * Deletes the TimeTrigger.
+ *
+ */
+TimeTrigger::~TimeTrigger()
+{
+
+}
+
+/**
+ * Reads the values from the tml element and sets them.
+ * @param root the xml element to load the parameters from.
+ *
+ */
+void TimeTrigger::loadParams(const TiXmlElement* root)
+{
+
+  ScriptTrigger ::loadParams(root);
+
+  LoadParam(root, "delay", this, TimeTrigger, setDelay)
+      .describe("the time after wich the timer is activated")
+      .defaultValues(0);
+ 
+}
+
+void TimeTrigger::tick(float timestep)
+{
+  if( scriptFinished ) return;
+  
+  if( !isStopped )
+  {
+    currentTime -= timestep;
+    
+    if(currentTime < 0)
+    {
+      this->executeAction(timestep);
+      this->stop();
+    }
+  
+  }
+
+      
+}
Index: trunk/src/world_entities/script_triggers/time_trigger.h
===================================================================
--- trunk/src/world_entities/script_triggers/time_trigger.h	(revision 10622)
+++ trunk/src/world_entities/script_triggers/time_trigger.h	(revision 10622)
@@ -0,0 +1,40 @@
+/*!
+ * @file time_trigger.h
+ *  triggers a script after a given time
+ */
+
+#ifndef _TIME_TRIGGER_H
+#define _TIME_TRIGGER_H
+
+#include <string>
+
+#include "script.h"
+#include "script_trigger.h"
+
+class TimeTrigger : public ScriptTrigger
+{
+  ObjectListDeclaration(TimeTrigger);
+  
+  public:
+    TimeTrigger(const TiXmlElement* root = NULL);
+    ~TimeTrigger();
+    
+    ///LOADING
+    virtual void loadParams(const TiXmlElement* root);
+    
+    void setDelay(float newDelay){this->currentTime = this->delay = newDelay;}
+    void start(){ this->isStopped = false; }
+    void stop(){ this->isStopped = true; }
+    void reset(){ this->currentTime = delay; }
+
+    /// DO WORK
+    virtual void tick(float timestep);
+  
+  private:
+    float delay;
+    float currentTime;
+    bool  isStopped;
+
+};
+
+#endif
Index: trunk/src/world_entities/tools/script_trigger.cc
===================================================================
--- trunk/src/world_entities/tools/script_trigger.cc	(revision 10618)
+++ 	(revision )
@@ -1,245 +1,0 @@
-/*
-   orxonox - the future of 3D-vertical-scrollers
-
-   Copyright (C) 2004 orx
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
-
-### File Specific:
-   main-programmer: Silvan Nellen
-   co-programmer: ...
-*/
-
-
-#include "script_trigger.h"
-#include "script.h"
-
-#include "state.h"
-#include "debug.h"
-ObjectListDefinition(ScriptTrigger);
-
-CREATE_SCRIPTABLE_CLASS(ScriptTrigger,
-            // Coordinates
-			addMethod("setAbsCoor", Executor3<PNode, lua_State*,float,float,float>(&PNode::setAbsCoor))
-			    ->addMethod("getAbsCoorX", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorX))
-			    ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY))
-			    ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ))
-            //Properties
-			    ->addMethod("setName", Executor1<BaseObject, lua_State*, const std::string&>(&BaseObject::setName))
-			    ->addMethod("setTarget", Executor1<ScriptTrigger, lua_State*, const std::string&>(&ScriptTrigger::setTarget))
-			    ->addMethod("setTriggerParent", Executor1<ScriptTrigger, lua_State*, const std::string&>(&ScriptTrigger::setTriggerParent))
-			    ->addMethod("setTriggerRemains", Executor1<ScriptTrigger, lua_State*, bool>(&ScriptTrigger::setTriggerRemains))
-			    ->addMethod("setActiveOnCreation", Executor1<ScriptTrigger, lua_State*, bool>(&ScriptTrigger::setActiveOnCreation))
-			    ->addMethod("setInvert", Executor1<ScriptTrigger, lua_State*, bool>(&ScriptTrigger::setInvert))
-			    ->addMethod("setRadius", Executor1<ScriptTrigger, lua_State*, float>(&ScriptTrigger::setRadius))
-			    ->addMethod("setScript", Executor1<ScriptTrigger, lua_State*, const std::string&>(&ScriptTrigger::setScript))
-			    ->addMethod("setFunction", Executor1<ScriptTrigger, lua_State*, const std::string&>(&ScriptTrigger::setFunction))
-			    ->addMethod("setDebugDraw", Executor1<ScriptTrigger, lua_State*, bool>(&ScriptTrigger::setDebugDraw))
-			    ->addMethod("setAddToScript", Executor1<ScriptTrigger, lua_State*, bool>(&ScriptTrigger::setAddToScript))
-             );
-
-
-/**
- * Constructs a new ScriptTrigger.
- * @param root the xml element to load the parameters from.
- *
- */
-ScriptTrigger::ScriptTrigger(const TiXmlElement* root)
-{
-  this->registerObject(this, ScriptTrigger::_objectList);
-  this->toList(OM_COMMON);
-
-  radius = 10;
-  returnCount = 1;
-  scriptFinished = false;
-  doDebugDraw = false;
-  invert = false;
-  scriptCalled = false;
-  scriptIsOk = false;
-  triggerRemains = true;
-  addToScript = false;
-  this->activeOnCreation = false;
-  target = NULL;
-
-  if(root != NULL)
-  {
-
-    loadParams(root);
-
-    if(addToScript && scriptIsOk)
-    {
-      script->addObject( "ScriptTrigger", this->getName());
-    }
-
-  }
-
-}
-
-/**
- * Deletes the ScriptTrigger.
- *
- */
-ScriptTrigger::~ScriptTrigger()
-{
-
-}
-
-/**
- * Reads the values from the tml element and sets them.
- * @param root the xml element to load the parameters from.
- *
- */
-void ScriptTrigger::loadParams(const TiXmlElement* root)
-{
-
-  WorldEntity ::loadParams(root);
-
-  LoadParam(root, "file", this, ScriptTrigger, setScript)
-      .describe("the fileName of the script, that should be triggered by this script trigger")
-      .defaultValues("");
-  LoadParam(root, "function", this, ScriptTrigger, setFunction)
-      .describe("the function of the script, that should be triggered by this script trigger")
-      .defaultValues("");
-  LoadParam(root, "abs-coor", this, ScriptTrigger, setAbsCoor)
-      .describe("where this script trigger should be located")
-      .defaultValues("");
-  LoadParam(root, "radius", this, ScriptTrigger, setRadius)
-      .describe("the fileName of the script, that should be triggered by this script trigger")
-      .defaultValues(0);
-  LoadParam(root, "delay", this, ScriptTrigger, setDelay)
-      .describe("the delay after which the funtion sould be triggered")
-      .defaultValues(0);
-  LoadParam(root, "worldentity", this, ScriptTrigger, setTarget)
-      .describe("The name of the target as it is in the *.oxw file")
-      .defaultValues("");
-  LoadParam(root, "triggerparent", this, ScriptTrigger, setTriggerParent)
-      .describe("The name of the parent as it is in the *.oxw file")
-      .defaultValues("");
-  LoadParam(root, "invert", this, ScriptTrigger, setInvert)
-      .describe("")
-      .defaultValues(false);
-  LoadParam(root, "triggerRemains", this, ScriptTrigger, setTriggerRemains)
-      .describe("")
-      .defaultValues(true);
-  LoadParam(root, "debugdraw", this, ScriptTrigger, setDebugDraw)
-      .describe("")
-      .defaultValues(false);
-  LoadParam(root, "addtoscript", this, ScriptTrigger, setAddToScript)
-      .describe("True if this scripttrigger should be aviable in the script")
-      .defaultValues(false);
-}
-
-
-/**
- * Sets the target(a world entity) of the ScriptTrigger. If the distance between the target and this trigger is smaller than the radius, the script gets triggered.
- * @param target The worldentity that the script supervises.
- */
-void ScriptTrigger::setTarget(const std::string& target)
-{
-
-  WorldEntity* targetEntity = WorldEntity::objectList().getObject(target);
-  if (targetEntity != NULL)
-  {
-    this->setTarget(targetEntity);
-  }
-  else
-  {
-    PRINTF(2)("ERROR SCRTIPTTRIGGER : Target %s for %s::%s does not Exist\n", target.c_str(), this->getClassCName(), this->getCName());
-  }
-}
-
-/**
- * Sets the parent of the trigger.
- * @param parent The parrent.
- */
-void ScriptTrigger::setTriggerParent(const std::string& parent)
-{
-  WorldEntity* parentEntity = WorldEntity::objectList().getObject(parent);
-
-  if (parentEntity != NULL)
-  {
-    this->setParent(parentEntity);
-    this->setParentMode(PNODE_MOVEMENT);
-  }
-  else
-  {
-    PRINTF(2)("ERROR SCRTIPTTRIGGER : Parent %s for %s::%s does not Exist\n", parent.c_str(), this->getClassCName(), this->getCName());
-  }
-}
-
-void ScriptTrigger::tick(float timestep)
-{
-  if(scriptFinished) return;
-
-  if(activeOnCreation)
-   {
-     executeAction(timestep);
-     return;
-   }
-
- if(triggerRemains && scriptCalled)
-  {
-    executeAction(timestep);
-    return;
-  }
-
-  if( this->target != NULL)
-  {
-    if( !invert && this->distance(target) < radius)
-    {
-    //printf("Distance is %f \n", this->distance(target));
-    executeAction(timestep);
-    scriptCalled = true;
-    return;
-
-    }
-    else if( invert && this->distance(target) > radius)
-    {
-      executeAction(timestep);
-      scriptCalled = true;
-      return;
-    }
-  }
-}
-
-
-void ScriptTrigger::executeAction(float timestep)
-{
-  if(scriptIsOk)
-  {
-       //testScriptingFramework();
-    if(!(script->selectFunction(this->functionName,returnCount)) )
-      PRINT(1)("ERROR SCRTIPTTRIGGER : Selection of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str());
-
-    script->pushParam( timestep, this->functionName);
-
-    if( !(script->executeFunction()) )
-      PRINT(1)("ERROR SCRTIPTTRIGGER : Execution of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str());
-
-    scriptFinished = script->getReturnedBool();
-  }
-  else
-  printf("ERROR SCRTIPTTRIGGER : Script could not be executed !\n");
-
-
-}
-
-
-void ScriptTrigger::setScript(const std::string& file)
-{
-  ScriptManager* scriptManager = State::getScriptManager();
-  if (scriptManager != NULL)
-  {
-
-    script = scriptManager->getScriptByFile(file);
-    if(script != NULL)
-    {
-      scriptIsOk = true;
-    }
-    else
-    printf("ERROR SCRTIPTTRIGGER : Could not find the wrapperobject of %s , the script won't be executed ! \n", file.c_str());
-  }
-}
Index: trunk/src/world_entities/tools/script_trigger.h
===================================================================
--- trunk/src/world_entities/tools/script_trigger.h	(revision 10618)
+++ 	(revision )
@@ -1,71 +1,0 @@
-/*!
- * @file scrip_trigger.h
- *  triggeres a script
- */
-
-#ifndef _SCRIPT_TRIGGER_H
-#define _SCRIPT_TRIGGER_H
-
-#include <string>
-
-#include "world_entity.h"
-#include "loading/load_param.h"
-#include "vector.h"
-#include "script_manager.h"
-#include "script.h"
-#include "script_class.h"
-
-class ScriptTrigger : public WorldEntity
-{
-  ObjectListDeclaration(ScriptTrigger);
-  public:
-    ScriptTrigger(const TiXmlElement* root = NULL);
-    ~ScriptTrigger();
-
-    ///LOADING
-    virtual void loadParams(const TiXmlElement* root);
-
-
-    /// DO WORK
-    virtual void tick(float timestep);
-    virtual void executeAction(float timestep);
-
-    /// SET MEMBER
-    void setTarget(const std::string& targetName);
-    void setTarget(WorldEntity* target) { if(target!=NULL) this->target=target; }
-    void setTriggerParent(const std::string& name);
-    void setTriggerRemains(const bool lasts) { this->triggerRemains = lasts; }
-    void setActiveOnCreation(const bool avtive) { this->activeOnCreation = avtive; }
-    void setInvert(const bool inv) { this->invert = invert; }
-    void setDelay(float delay) { this->delay = delay; };
-    void setRadius(const float radius) { if(radius>0) this->radius = radius; }
-    void setScript(const std::string& file);
-    void setFunction(const std::string& function){ this->functionName = function;}
-    void setDebugDraw(const bool draw) { this->doDebugDraw = draw; }
-    void setAddToScript(const bool add) { this->addToScript = add; }
-
-    ///DRAWING
-    void draw()const{if(doDebugDraw)this->debugDraw();};
-
-  private:
-
-    WorldEntity* target;
-    bool         triggerRemains;
-    bool         activeOnCreation;
-    bool         invert;
-    float        radius;
-    float        delay;
-    Script*      script;
-    std::string  functionName;
-    bool         doDebugDraw;
-    bool         addToScript;
-    //for internal use
-    bool         scriptCalled;
-    bool         scriptIsOk;
-    bool         scriptFinished;
-    int          returnCount;        //TODO: set return count correctly
-
-};
-
-
-#endif
