Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11902


Ignore:
Timestamp:
Apr 24, 2018, 5:56:18 PM (6 years ago)
Author:
adamc
Message:

scriptablecontroller trying to move player with lua

Location:
code/branches/ScriptableController_FS18/src/orxonox/scriptablecontroller
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ScriptableController_FS18/src/orxonox/scriptablecontroller/scriptable_controller_api.cc

    r11901 r11902  
    4040
    4141        LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::myTestFunction)>::registerFunction<&ScriptableControllerAPI::myTestFunction>(this, lua, "mytestfunction");
     42        LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::moveControllableEntity)>::registerFunction<&ScriptableControllerAPI::moveControllableEntity>(this, lua, "moveControllableEntity");
    4243
    4344
     
    362363    }
    363364
    364     //void ScriptableControllerAPI::moveEntity(std::string id, double x, double y, double z)
    365 
     365    void ScriptableControllerAPI::moveControllableEntity(std::string id, double x, double y, double z)
     366    {
     367        MobileEntity *entity = this->controller_->getMobileEntityByID(id);
     368        if(entity == nullptr)
     369        {
     370            orxout(user_warning) << "Trying to set velocity of an unknown object" << std::endl;
     371            return;
     372        }
     373
     374
     375
     376
     377        Identifier *identifier = ClassByString("ControllableEntity");
     378       
     379        ControllableEntity *controllable_entity;
     380       
     381        if(identifier->isA(ClassIdentifier<ControllableEntity>::getIdentifier()))
     382        {
     383            controllable_entity = orxonox_cast<ControllableEntity*>(entity);
     384
     385            controllable_entity->moveFrontBack(x);
     386            controllable_entity->moveRightLeft(y);
     387            controllable_entity->moveUpDown(z);
     388        }
     389
     390        return;
     391       
     392    }
    366393}
  • code/branches/ScriptableController_FS18/src/orxonox/scriptablecontroller/scriptable_controller_api.h

    r11854 r11902  
    206206    double myTestFunction(double x, double y);
    207207
     208    void moveControllableEntity(std::string id, double x, double y, double z);
     209
    208210// ### API END ################################################################
    209211
Note: See TracChangeset for help on using the changeset viewer.