How do games embed scripting languages?

Posted by No_Insurance_6436@reddit | learnprogramming | View on Reddit | 21 comments

I understand that multiple languages can be used to design a single program. Multiple C files can be used as headers, and compiled object files can be linked together with a linker.

However, I do not understand how games such as gmod and ROBLOX have the ability to run scripts in LUA and interact with the game engine while running.

The engine is written in C/C++, I assume. How is LUA implemented in such a way that a user can write a script and have it interact with the game engine?

And, why do many games use LUA for small math (damage/position calculations, etc)? Why not just program it all in C/C++?