From 5d9fb5b09cc23f843c51ce1766ce839b0822b70e Mon Sep 17 00:00:00 2001 From: Bluub Date: Sun, 20 Jun 2021 22:00:51 +0200 Subject: [PATCH] check if script has Update function --- .../Component/IAControllable/IAControllableComponent.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sources/Component/IAControllable/IAControllableComponent.cpp b/sources/Component/IAControllable/IAControllableComponent.cpp index c91a75d9..dcfc3069 100644 --- a/sources/Component/IAControllable/IAControllableComponent.cpp +++ b/sources/Component/IAControllable/IAControllableComponent.cpp @@ -20,6 +20,12 @@ namespace BBM { if (std::filesystem::exists(scriptPath)) { _state.dofile(scriptPath); + _state.getGlobal("Update"); + if (lua_isfunction(_state.getState(), -1)) { + _state.popLast(); + } else { + throw Error("Lua script doesn't have Update function"); + } } else { throw Error("Couldn't load lua script: " + scriptPath);