Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10631 in orxonox.OLD


Ignore:
Timestamp:
Apr 12, 2007, 7:10:23 PM (17 years ago)
Author:
snellen
Message:

Action Trigger finished

Location:
branches/inputdevice/src/world_entities
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/inputdevice/src/world_entities/WorldEntities.am

    r10622 r10631  
    111111                world_entities/script_triggers/tick_trigger.cc \
    112112                world_entities/script_triggers/time_trigger.cc \
     113                world_entities/script_triggers/action_trigger.cc \
    113114                \
    114115                \
     
    234235                script_triggers/tick_trigger.h \
    235236                script_triggers/time_trigger.h \
     237                script_triggers/action_trigger.h \
    236238                \
    237239                \
  • branches/inputdevice/src/world_entities/script_triggers/action_trigger.cc

    r10630 r10631  
    5151  radius = 10;
    5252  invert = false;
     53  actionScheduled = false;
    5354 
    5455  if(root != NULL)
     
    117118
    118119
    119 void ActionTrigger::tick(float timestep)
     120void ActionTrigger::tick( float timestep )
    120121{
    121   if( scriptFinished ) return;
     122  if( scriptFinished || !actionScheduled ) return;
    122123
    123124  if( this->target != NULL)
     
    125126    if( !invert && this->distance(target) < radius && actionScheduled)
    126127    {
    127     //printf("Distance is %f \n", this->distance(target));
    128       executeAction(timestep);
     128      executeScriptFunction(timestep);
    129129      scriptCalled = true;
    130130      return;
    131 
    132131    }
    133132    else if( invert && this->distance(target) > radius  && actionScheduled)
    134133    {
    135       executeAction(timestep);
     134      executeScriptFunction(timestep);
    136135      scriptCalled = true;
    137136      return;
  • branches/inputdevice/src/world_entities/script_triggers/action_trigger.h

    r10630 r10631  
    44 */
    55
    6 #ifndef _SPACE_TRIGGER_H
    7 #define _SPACE_TRIGGER_H
     6#ifndef _ACTION_TRIGGER_H
     7#define _ACTION_TRIGGER_H
    88
    99#include <string>
     
    2626
    2727    /// DO WORK
     28    virtual void executeAction(){actionScheduled = true;}
    2829    virtual void tick(float timestep);
    29 
    3030
    3131    /// SET MEMBER
  • branches/inputdevice/src/world_entities/script_triggers/script_trigger.cc

    r10622 r10631  
    104104
    105105
    106 void ScriptTrigger::executeAction(float timestep)
     106void ScriptTrigger::executeScriptFunction(float timestep)
    107107{
    108108  if(executionStopped && scriptIsOk) // If the script has been loaded correctly but something is wrong with the settings of the trigger
     
    114114  if(scriptIsOk)
    115115  {
    116        //testScriptingFramework();
    117116    if(!(script->selectFunction(this->functionName,returnCount)) )
    118117     {
     
    166165  }
    167166}
    168 
    169 /*
    170  void ScriptTrigger::testScriptingFramework()
    171 {
    172    std::string file("lunartest2.lua");
    173    //get script
    174    Script* script = State::getScriptManager()->getScriptByFile(file);
    175    printf("-------------------------- top of the stack:%i\n",lua_gettop(script->getLuaState()));
    176 
    177       //execute a function
    178    printf("----------- main -----------\n");
    179    std::string main("main");
    180    if( script->selectFunction(main,3))
    181      printf("function %s selected\n",main.c_str());
    182 
    183    script->pushParam(3.14159,main);
    184    printf("-------------------------- top of the stack:%i\n",lua_gettop(script->getLuaState()));
    185    script->executeFunction();
    186 
    187    int ret = script->getReturnedInt();
    188    printf("main returned %i\n",ret);
    189 
    190    if(script->getReturnedBool())
    191      printf("main returned true\n");
    192    else
    193      printf("main returned false\n");
    194 
    195    float retf = script->getReturnedFloat();
    196    printf("main returned %f\n",retf);
    197 
    198 
    199    printf("-------------------------- top of the stack:%i\n",lua_gettop(script->getLuaState()));
    200       //execute a 2nd function
    201    printf("----------- test -----------\n");
    202    std::string test("test");
    203    if( script->selectFunction(test,0))
    204      printf("function %s selected\n",test.c_str());
    205 
    206    script->executeFunction();
    207 
    208 
    209       //if(argc>1) lua_dofile(script.getLuaState(), argv[1]);
    210    printf("-------------------------- top of the stack:%i\n",lua_gettop(script->getLuaState()));
    211 
    212 }*/
  • branches/inputdevice/src/world_entities/script_triggers/script_trigger.h

    r10622 r10631  
    2727
    2828    /// DO WORK
    29     virtual void tick(float timestep) = 0;
    30     virtual void executeAction(float timestep);
     29    virtual void tick(float timestep){}
     30    virtual void executeScriptFunction(float timestep);
    3131    void testScriptingFramework();
    3232
  • branches/inputdevice/src/world_entities/script_triggers/space_trigger.cc

    r10622 r10631  
    128128  if(triggerRemains && scriptCalled )
    129129  {
    130     executeAction(timestep);
     130    executeScriptFunction(timestep);
    131131    return;
    132132  }
     
    136136    if( !invert && this->distance(target) < radius)
    137137    {
    138     //printf("Distance is %f \n", this->distance(target));
    139       executeAction(timestep);
     138      executeScriptFunction(timestep);
    140139      scriptCalled = true;
    141140      return;
     
    144143    else if( invert && this->distance(target) > radius)
    145144    {
    146       executeAction(timestep);
     145      executeScriptFunction(timestep);
    147146      scriptCalled = true;
    148147      return;
  • branches/inputdevice/src/world_entities/script_triggers/tick_trigger.cc

    r10622 r10631  
    7272  if( scriptFinished ) return;
    7373
    74   this->executeAction(timestep);
     74  this->executeScriptFunction(timestep);
    7575     
    7676}
  • branches/inputdevice/src/world_entities/script_triggers/time_trigger.cc

    r10622 r10631  
    102102    if(currentTime < 0)
    103103    {
    104       this->executeAction(timestep);
     104      this->executeScriptFunction(timestep);
    105105      this->stop();
    106106    }
Note: See TracChangeset for help on using the changeset viewer.