I'm starting work with the Allegro C++ library to get some lower level game development experience after working mostly with Unity. I've read about how Lua is a popular scripting language choice for game developers, but I have never used it before. I've been trying to work through how Lua might be integrated with a game engine in my head, and I've ran into some conceptual problems.
I imagine the simple scenario where I have a block that I want to move to the left at a certain speed for 2 seconds. I imagine that something like the Draw() method would sit nicely in the game engine in C++, where the actual command to move the block, being a fairly specific one, would originate in Lua.
I have trouble imagining where the transition between the languages is. I've read that calling to Lua every frame of the Game Loop isn't very performant, so that means that unless Lua can keep track of the movement timer asynchronously and interrupt C++ execution when the timer runs out, I would have to track the timer in the C++ engine. I would need a method like MoveForSeconds(direction, time) implemented in C++. At that point, Lua calling my MoveForSeconds() method is little more than a passthrough, and seems to defeat the purpose of using a scripting language.
What am I misunderstanding here? Or is my example too myopic, and the uses of Lua become more evident on a larger scale?