Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jun 22, 2006, 1:09:20 PM (18 years ago)
Author:
bensch
Message:

merged the script_engine back here

File:
1 edited

Legend:

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

    r8408 r8711  
    1 //for testing
    2 #include "luaincl.h"
     1/*
     2   orxonox - the future of 3D-vertical-scrollers
     3
     4   Copyright (C) 2004 orx
     5
     6   This program is free software; you can redistribute it and/or modify
     7   it under the terms of the GNU General Public License as published by
     8   the Free Software Foundation; either version 2, or (at your option)
     9   any later version.
     10
     11### File Specific:
     12   main-programmer: Silvan Nellen
     13   co-programmer: ...
     14*/
     15
    316
    417#include "script_trigger.h"
     
    2033  this->toList(OM_COMMON);
    2134
     35  returnCount = 1;
     36  actionFinished = false;
    2237  doDebugDraw = false;
     38  invert = false;
    2339  scriptCalled = false;
    2440  scriptIsOk = false;
     41  triggerLasts = false;
    2542  loadParams(root);
    2643
     
    7188        .describe("True if the script shoul only be called once")
    7289        .defaultValues("");
     90    LoadParam(root, "invert", this, ScriptTrigger, setInvert)
     91        .describe("")
     92        .defaultValues("");
     93    LoadParam(root, "triggerlasts", this, ScriptTrigger, setTriggerLasts)
     94        .describe("")
     95        .defaultValues("");
    7396    LoadParam(root, "debugdraw", this, ScriptTrigger, setDebugDraw)
    7497        .describe("True if the script should only be called once")
     
    118141void ScriptTrigger::tick(float timestep)
    119142{
    120 
    121   if( this->distance(target) < radius)
     143  if(actionFinished) return;
     144
     145  if(triggerLasts && scriptCalled)
     146  {
     147    executeAction(timestep);
     148    return;
     149  }
     150 
     151  if( !invert && this->distance(target) < radius)
    122152 {
    123153  if(!callOnce)
    124154   {
    125     executeAction();
     155    executeAction(timestep);
     156    scriptCalled = true;
    126157   }
    127158  else if(callOnce && !scriptCalled)
    128159  {
    129    executeAction();
     160   executeAction(timestep);
    130161   scriptCalled = true;
    131162  }
     163 
     164 }
     165 else if( invert && this->distance(target) > radius)
     166 {
     167   if(!callOnce)
     168   {
     169     executeAction(timestep);
     170   }
     171   else if(callOnce && !scriptCalled)
     172   {
     173     executeAction(timestep);
     174     scriptCalled = true;
     175   }
     176   
    132177 }
    133178 //else
     
    137182
    138183
    139 void ScriptTrigger::executeAction()
     184void ScriptTrigger::executeAction(float timestep)
    140185{
    141186     if(scriptIsOk)
    142187     {
    143        testScriptingFramework();
    144      /*if(!(script->selectFunction(this->functionName,0)) )
     188       //testScriptingFramework();
     189     if(!(script->selectFunction(this->functionName,returnCount)) )
    145190       printf("Error ScriptTrigger: Selection of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str());
     191     
     192     script->pushParam( timestep, this->functionName);
     193     
    146194     if( !(script->executeFunction()) )
    147        printf("Error ScriptTrigger: Execution of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str());*/
     195       printf("Error ScriptTrigger: Execution of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str());
     196     
     197     actionFinished = script->getReturnedBool();
    148198     }
     199     
     200     
    149201}
    150202
     
    165217}
    166218
    167 
     219/*
    168220 void ScriptTrigger::testScriptingFramework()
    169221 {
     
    208260   printf("-------------------------- top of the stack:%i\n",lua_gettop(script->getLuaState()));
    209261
    210  }
     262}*/
Note: See TracChangeset for help on using the changeset viewer.