Index: trunk/src/world_entities/WorldEntities.am
===================================================================
--- trunk/src/world_entities/WorldEntities.am	(revision 10622)
+++ trunk/src/world_entities/WorldEntities.am	(revision 10638)
@@ -111,4 +111,5 @@
 		world_entities/script_triggers/tick_trigger.cc \
 		world_entities/script_triggers/time_trigger.cc \
+                world_entities/script_triggers/action_trigger.cc \
                 \
                 \
@@ -234,4 +235,5 @@
 		script_triggers/tick_trigger.h \
 		script_triggers/time_trigger.h \
+                script_triggers/action_trigger.h \
                 \
                 \
Index: trunk/src/world_entities/script_triggers/action_trigger.cc
===================================================================
--- trunk/src/world_entities/script_triggers/action_trigger.cc	(revision 10638)
+++ trunk/src/world_entities/script_triggers/action_trigger.cc	(revision 10638)
@@ -0,0 +1,151 @@
+/*
+   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 "action_trigger.h"
+#include "debug.h"
+#include "event_handler.h"
+
+ObjectListDefinition(ActionTrigger);
+CREATE_FACTORY(ActionTrigger);
+
+CREATE_SCRIPTABLE_CLASS(ActionTrigger,
+            // 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<ActionTrigger, lua_State*, const std::string&>(&ActionTrigger::setTarget))
+                            ->addMethod("setTriggerParent", Executor1<ScriptTrigger, lua_State*, const std::string&>(&ScriptTrigger::setTriggerParent))
+                            ->addMethod("setInvert", Executor1<ActionTrigger, lua_State*, bool>(&ActionTrigger::setInvert))
+                            ->addMethod("setRadius", Executor1<ActionTrigger, lua_State*, float>(&ActionTrigger::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 ActionTrigger.
+ * @param root the xml element to load the parameters from.
+ *
+ */
+ActionTrigger::ActionTrigger(const TiXmlElement* root)
+{
+  this->registerObject(this, ActionTrigger::_objectList);
+  this->subscribeEvent(ES_GAME, KeyMapper::PEV_ACTION);
+
+  radius = 10;
+  invert = false;
+  actionScheduled = false;
+ 
+  if(root != NULL)
+  {
+    loadParams(root);
+
+    if(addToScript && scriptIsOk)
+    {
+      script->addObject( "ActionTrigger", this->getName());
+    }
+
+  }
+
+}
+
+/**
+ * Deletes the ActionTrigger.
+ *
+ */
+ActionTrigger::~ActionTrigger()
+{
+
+}
+
+/**
+ * Reads the values from the tml element and sets them.
+ * @param root the xml element to load the parameters from.
+ *
+ */
+void ActionTrigger::loadParams(const TiXmlElement* root)
+{
+
+  ScriptTrigger ::loadParams(root);
+
+ 
+  LoadParam(root, "radius", this, ActionTrigger, setRadius)
+      .describe("the fileName of the script, that should be triggered by this script trigger")
+      .defaultValues(0);
+  LoadParam(root, "worldentity", this, ActionTrigger, setTarget)
+      .describe("The name of the target as it is in the *.oxw file")
+      .defaultValues("");
+  LoadParam(root, "invert", this, ActionTrigger, setInvert)
+      .describe("")
+      .defaultValues(false);
+ 
+}
+
+
+/**
+ * Sets the target(a world entity) of the ActionTrigger. 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 ActionTrigger::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 ActionTrigger::process( const Event &event)
+{
+ if (event.type == KeyMapper::PEV_ACTION && event.bPressed)
+ {
+   actionScheduled = true;
+ }
+}
+
+void ActionTrigger::tick( float timestep )
+{
+  if( scriptFinished ) return;
+
+  if( this->target != NULL && actionScheduled)
+  {
+    if( !invert && this->distance(target) < radius && actionScheduled)
+    {
+      executeScriptFunction(timestep);
+      scriptCalled = true;
+    }
+    else if( invert && this->distance(target) > radius  && actionScheduled)
+    {
+      executeScriptFunction(timestep);
+      scriptCalled = true;
+    }
+  }
+
+  actionScheduled = false;
+}
+
+
+
Index: trunk/src/world_entities/script_triggers/action_trigger.h
===================================================================
--- trunk/src/world_entities/script_triggers/action_trigger.h	(revision 10638)
+++ trunk/src/world_entities/script_triggers/action_trigger.h	(revision 10638)
@@ -0,0 +1,49 @@
+/*!
+ * @file action_trigger.h
+ *  triggeres a script when a world_entity is in range and the player has pressed the action button
+ */
+
+#ifndef _ACTION_TRIGGER_H
+#define _ACTION_TRIGGER_H
+
+#include <string>
+
+#include "script.h"
+#include "script_class.h"
+#include "script_trigger.h"
+#include "event_listener.h"
+
+class ActionTrigger : public ScriptTrigger, public EventListener
+{
+  ObjectListDeclaration(ActionTrigger);
+  
+  public:
+    ActionTrigger(const TiXmlElement* root = NULL);
+    ~ActionTrigger();
+    
+    ///LOADING
+    virtual void loadParams(const TiXmlElement* root);
+
+
+    /// DO WORK
+    virtual void process( const Event &event);
+    virtual void tick(float timestep);
+
+    /// SET MEMBER
+    void setTarget(const std::string& targetName);
+    void setTarget(WorldEntity* target) { if(target!=NULL) this->target=target; }
+    void setInvert(const bool inv) { this->invert = invert; }
+    void setRadius(const float radius) { if(radius>0) this->radius = radius; }
+
+
+  private:
+    bool          actionScheduled;
+    WorldEntity*  target;
+    bool          invert;
+    float         radius;
+
+
+};
+
+
+#endif
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 10638)
@@ -104,5 +104,5 @@
 
 
-void ScriptTrigger::executeAction(float timestep)
+void ScriptTrigger::executeScriptFunction(float timestep)
 {
   if(executionStopped && scriptIsOk) // If the script has been loaded correctly but something is wrong with the settings of the trigger
@@ -114,5 +114,4 @@
   if(scriptIsOk)
   {
-       //testScriptingFramework();
     if(!(script->selectFunction(this->functionName,returnCount)) )
      {
@@ -166,47 +165,2 @@
   }
 }
-
-/*
- 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 10638)
@@ -27,7 +27,6 @@
 
     /// DO WORK
-    virtual void tick(float timestep) = 0;
-    virtual void executeAction(float timestep);
-    void testScriptingFramework();
+    virtual void tick(float timestep){}
+    virtual void executeScriptFunction(float timestep);
 
     /// SET MEMBER
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 10638)
@@ -128,5 +128,5 @@
   if(triggerRemains && scriptCalled )
   {
-    executeAction(timestep);
+    executeScriptFunction(timestep);
     return;
   }
@@ -136,6 +136,5 @@
     if( !invert && this->distance(target) < radius)
     {
-    //printf("Distance is %f \n", this->distance(target));
-      executeAction(timestep);
+      executeScriptFunction(timestep);
       scriptCalled = true;
       return;
@@ -144,5 +143,5 @@
     else if( invert && this->distance(target) > radius)
     {
-      executeAction(timestep);
+      executeScriptFunction(timestep);
       scriptCalled = true;
       return;
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 10638)
@@ -72,5 +72,5 @@
   if( scriptFinished ) return;
 
-  this->executeAction(timestep);
+  this->executeScriptFunction(timestep);
       
 }
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 10638)
@@ -102,5 +102,5 @@
     if(currentTime < 0)
     {
-      this->executeAction(timestep);
+      this->executeScriptFunction(timestep);
       this->stop();
     }
