From 5df0d0616ee3996add0b14e0fb0becd6257d04a2 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 21 Feb 2021 17:56:17 -0500 Subject: Added a debug console Open it by pressing backtick, close it by hitting escape. Pressing backtick does not open it in release builds. Current shortcomings: opening it for the first time also types a backtick for some reason, but not on subsequent times. Also, it doesn't create a coroutine, so any script function that yields is going to fail. This also added a "is gameplay paused" flag to Game, which will be useful for adding a pause menu. --- src/script_system.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/script_system.cpp') diff --git a/src/script_system.cpp b/src/script_system.cpp index 3293753..14d247e 100644 --- a/src/script_system.cpp +++ b/src/script_system.cpp @@ -190,6 +190,8 @@ ScriptSystem::ScriptSystem(Game& game) : game_(game) { } void ScriptSystem::tick(double dt) { + if (game_.isGameplayPaused()) return; + if (callable_ && *callable_) { auto result = (*callable_)(dt); if (!result.valid()) { @@ -228,3 +230,11 @@ void ScriptSystem::runScript(std::string mapName, std::string scriptName) { runner_.reset(); } } + +void ScriptSystem::runDebugScript(std::string script) { + auto result = engine_.script(script); + if (!result.valid()) { + sol::error e = result; + std::cout << e.what() << std::endl; + } +} -- cgit 1.4.1