Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 15, 2006, 5:33:25 PM (19 years ago)
Author:
snellen
Message:

helicopter scripted

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/script_engine/src/world_entities/script_trigger.cc

    r8417 r8485  
    2020  this->toList(OM_COMMON);
    2121
     22  returnCount = 1;
     23  actionFinished = false;
    2224  doDebugDraw = false;
     25  invert = false;
    2326  scriptCalled = false;
    2427  scriptIsOk = false;
     28  triggerLasts = false;
    2529  loadParams(root);
    2630
     
    7175        .describe("True if the script shoul only be called once")
    7276        .defaultValues("");
     77    LoadParam(root, "invert", this, ScriptTrigger, setInvert)
     78        .describe("")
     79        .defaultValues("");
     80    LoadParam(root, "triggerlasts", this, ScriptTrigger, setTriggerLasts)
     81        .describe("")
     82        .defaultValues("");
    7383    LoadParam(root, "debugdraw", this, ScriptTrigger, setDebugDraw)
    7484        .describe("True if the script should only be called once")
     
    118128void ScriptTrigger::tick(float timestep)
    119129{
    120 
    121   if( this->distance(target) < radius)
     130  if(actionFinished) return;
     131
     132  if(triggerLasts && scriptCalled)
     133  {
     134    executeAction(timestep);
     135    return;
     136  }
     137 
     138 
     139  if( !invert && this->distance(target) < radius)
    122140 {
    123141  if(!callOnce)
    124142   {
    125     executeAction();
     143    executeAction(timestep);
     144    scriptCalled = true;
    126145   }
    127146  else if(callOnce && !scriptCalled)
    128147  {
    129    executeAction();
     148   executeAction(timestep);
    130149   scriptCalled = true;
    131150  }
     151 
     152 }
     153 else if( invert && this->distance(target) > radius)
     154 {
     155   if(!callOnce)
     156   {
     157     executeAction(timestep);
     158   }
     159   else if(callOnce && !scriptCalled)
     160   {
     161     executeAction(timestep);
     162     scriptCalled = true;
     163   }
     164   
    132165 }
    133166 //else
     
    137170
    138171
    139 void ScriptTrigger::executeAction()
     172void ScriptTrigger::executeAction(float timestep)
    140173{
    141174     if(scriptIsOk)
    142175     {
    143        testScriptingFramework();
    144      if(!(script->selectFunction(this->functionName,0)) )
     176       //testScriptingFramework();
     177     if(!(script->selectFunction(this->functionName,returnCount)) )
    145178       printf("Error ScriptTrigger: Selection of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str());
     179     
     180     script->pushParam( timestep, this->functionName);
     181     
    146182     if( !(script->executeFunction()) )
    147183       printf("Error ScriptTrigger: Execution of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str());
    148184     }
     185     
     186     actionFinished = script->getReturnedBool();
    149187}
    150188
Note: See TracChangeset for help on using the changeset viewer.