Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8869 in orxonox.OLD


Ignore:
Timestamp:
Jun 28, 2006, 4:48:16 PM (18 years ago)
Author:
snellen
Message:

made FPSPlayer scriptable

Location:
branches/single_player_map/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/single_player_map/src/lib/script_engine/script_manager.h

    r8711 r8869  
    11/*!
    2  * @file scrip_manager.h
     2 * @file script_manager.h
    33 *  manages the scripts
    44 */
  • branches/single_player_map/src/world_entities/creatures/fps_player.cc

    r8776 r8869  
    3535
    3636CREATE_FACTORY(FPSPlayer, CL_FPS_PLAYER);
     37
     38#include "script_class.h"
     39CREATE_SCRIPTABLE_CLASS(FPSPlayer, CL_FPS_PLAYER,
     40                        addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))
     41                            ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
     42                            ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))
     43                            ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))
     44                       );
    3745
    3846
  • branches/single_player_map/src/world_entities/npcs/generic_npc.cc

    r8847 r8869  
    4040#include "script_class.h"
    4141CREATE_SCRIPTABLE_CLASS(GenericNPC, CL_GENERIC_NPC,
    42                         //addMethod("walkTo", ExecutorLua7ret<GenericNPC,float, float, float, float, float, float, float, float>(&GenericNPC::walkTo))
     42                       // Move
    4343                        addMethod("walkTo", ExecutorLua3ret<GenericNPC,float,float,float,float>(&GenericNPC::walkTo))
    4444                        ->addMethod("setTime", ExecutorLua1<GenericNPC,float>(&GenericNPC::setTime))
    4545                        ->addMethod("turnTo", ExecutorLua4ret<GenericNPC,bool,float,float,float,float>(&GenericNPC::turnTo))
     46                       // Display
     47                        ->addMethod("hide", ExecutorLua0<WorldEntity>(&WorldEntity::hide))
     48                        ->addMethod("unhide", ExecutorLua0<WorldEntity>(&WorldEntity::unhide))
     49                       // Coordinates
     50                        ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
     51                        ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))
     52                        ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))
    4653                        ->addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))
    4754                        ->addMethod("setAbsDir", ExecutorLua4<PNode,float,float,float,float>(&PNode::setAbsDir))
     55                           
    4856                       );
    4957
     
    412420  printf("Turning: %f, %f, %f, %f \n",qu,qx,qy,qz);
    413421  // check if this is the current goal
    414   this->destDir.debug();
    415   destDir.debug();
    416422  if( this->destDir != destDir)
    417423  {
  • branches/single_player_map/src/world_entities/script_trigger.cc

    r8783 r8869  
    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;
     
    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("")
     
    112109        .defaultValues("");
    113110    LoadParam(root, "debugdraw", this, ScriptTrigger, setDebugDraw)
    114         .describe("True if the script should only be called once")
     111        .describe("")
    115112        .defaultValues("");
    116113    LoadParam(root, "addtoscript", this, ScriptTrigger, setAddToScript)
     
    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     
  • branches/single_player_map/src/world_entities/script_trigger.h

    r8783 r8869  
    3535    void setTarget(WorldEntity* target) { if(target!=NULL) this->target=target; }
    3636    void setTriggerParent(const std::string& name);
    37     void setCallOnce(const bool call) { this->callOnce = call; }
    3837    void setTriggerLasts(const bool lasts) { this->triggerLasts = lasts; }
    3938    void setInvert(const bool inv) { this->invert = invert; }
     
    5150
    5251    WorldEntity* target;
    53     bool         callOnce;
    5452    bool         triggerLasts;
    5553    bool         invert;
     
    6361    bool         scriptCalled;
    6462    bool         scriptIsOk;
    65     bool         actionFinished;
     63    bool         scriptFinished;
    6664    int          returnCount;        //TODO: set return count correctly
    6765
Note: See TracChangeset for help on using the changeset viewer.