Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8894 in orxonox.OLD for trunk/src/world_entities/script_trigger.cc


Ignore:
Timestamp:
Jun 29, 2006, 12:19:48 AM (18 years ago)
Author:
patrick
Message:

merged the branche single_player_map with the trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/script_trigger.cc

    r8783 r8894  
    2424CREATE_SCRIPTABLE_CLASS(ScriptTrigger, CL_SCRIPT_TRIGGER,
    2525                            addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))
    26                                 ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
    27                                 ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))
    28                                 ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))
     26                            ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
     27                            ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))
     28                            ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))
    2929                       );
    3030
     
    4141
    4242  returnCount = 1;
    43   actionFinished = false;
     43  scriptFinished = false;
    4444  doDebugDraw = false;
    4545  invert = false;
    4646  scriptCalled = false;
    4747  scriptIsOk = false;
    48   triggerLasts = false;
     48  triggerLasts = true;
    4949  addToScript = false;
    5050 
     
    5454  loadParams(root);
    5555 
    56   if(addToScript)
     56  if(addToScript && scriptIsOk)
    5757  {
    5858    script->addObject( "ScriptTrigger", this->getName());
     
    102102        .describe("The name of the parent as it is in the *.oxw file")
    103103        .defaultValues("");
    104     LoadParam(root, "callonce", this, ScriptTrigger, setCallOnce)
    105         .describe("True if the script shoul only be called once")
    106         .defaultValues("");
    107104    LoadParam(root, "invert", this, ScriptTrigger, setInvert)
    108105        .describe("")
    109         .defaultValues("");
     106        .defaultValues("false");
    110107    LoadParam(root, "triggerlasts", this, ScriptTrigger, setTriggerLasts)
    111108        .describe("")
    112         .defaultValues("");
     109        .defaultValues("true");
    113110    LoadParam(root, "debugdraw", this, ScriptTrigger, setDebugDraw)
    114         .describe("True if the script should only be called once")
    115         .defaultValues("");
     111        .describe("")
     112        .defaultValues("false");
    116113    LoadParam(root, "addtoscript", this, ScriptTrigger, setAddToScript)
    117114        .describe("True if this scripttrigger should be aviable in the script")
    118         .defaultValues("");
     115        .defaultValues("false");
    119116}
    120117
     
    159156void ScriptTrigger::tick(float timestep)
    160157{
    161   if(actionFinished) return;
     158  if(scriptFinished) return;
    162159
    163160  if(triggerLasts && scriptCalled)
     
    169166  if( !invert && this->distance(target) < radius)
    170167 {
    171   if(!callOnce)
    172    {
    173168    executeAction(timestep);
    174169    scriptCalled = true;
    175    }
    176   else if(callOnce && !scriptCalled)
    177   {
    178    executeAction(timestep);
    179    scriptCalled = true;
    180   }
    181170 
    182171 }
    183172 else if( invert && this->distance(target) > radius)
    184173 {
    185    if(!callOnce)
    186    {
    187      executeAction(timestep);
    188    }
    189    else if(callOnce && !scriptCalled)
    190    {
    191      executeAction(timestep);
     174     executeAction(timestep);
    192175     scriptCalled = true;
    193    }
    194    
    195176 }
    196177 //else
     
    202183void ScriptTrigger::executeAction(float timestep)
    203184{
     185 
    204186     if(scriptIsOk)
    205187     {
     
    213195       printf("Error ScriptTrigger: Execution of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str());
    214196     
    215      actionFinished = script->getReturnedBool();
     197     scriptFinished = script->getReturnedBool();
    216198     }
    217199     
Note: See TracChangeset for help on using the changeset viewer.