Changeset 11549 for code/branches/ScriptableController_HS17/src/orxonox/scriptablecontroller/scriptable_controller.cc
- Timestamp:
- Nov 6, 2017, 5:23:08 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ScriptableController_HS17/src/orxonox/scriptablecontroller/scriptable_controller.cc
r11519 r11549 6 6 { 7 7 8 RegisterUnloadableClass(ScriptableController); 9 8 10 // Used https://csl.name/post/lua-and-cpp/ as a reference 11 ScriptableController::ScriptableController(Context* context) 12 : BaseObject(context) 13 { 14 RegisterObject(ScriptableController); 15 } 16 9 17 int ScriptableController::runScript(const std::string &file_path) 10 18 { … … 71 79 } 72 80 81 void ScriptableController::registerTimeout(std::function<void ()> callback, double timeout) 82 { 83 this->timeouts.push_back(std::make_pair(callback, static_cast<float>(timeout))); 84 orxout(user_warning) << "Calling should work..." << std::endl; 85 callback(); 86 } 87 88 void ScriptableController::tick(float dt) 89 { 90 auto timeout = this->timeouts.begin(); 91 92 while(timeout != this->timeouts.end()) 93 { 94 timeout->second -= dt; 95 if(timeout->second <= 0) 96 { 97 orxout(user_warning) << "Calling..." << std::endl; 98 timeout->first(); 99 timeout = this->timeouts.erase(timeout); 100 } 101 else 102 { 103 timeout++; 104 } 105 } 106 107 Tickable::tick(dt); 108 } 109 73 110 void ScriptableController::printLuaError(lua_State *lua) 74 111 {
Note: See TracChangeset
for help on using the changeset viewer.