I'm curious about how scripting systems interact with the type systems in game engines, particularly when comparing approaches like UnrealScript with C++. Unreal Engine uses C++ but also has UnrealScript, allowing new classes to inherit from existing C++ classes. This capability lets developers easily access and modify the game's source code, such as with Unreal Tournament.
In my case, I want to implement scripting using Lua, as I don't plan to create a custom scripting language. However, I have some concerns since Lua isn't inherently object-oriented. I see two main paths: I could create an engine like Unreal that relies on classes and inheritance, or I could go with a model similar to GameMaker, which is more event-driven and treats objects as data containers. I'm looking for insight on how scripting can function within this context, especially concerning the possibility of building an object-oriented scripting API in Lua. Are there successful examples or suggestions for managing this integration?
3 Answers
Honestly, I lean towards the GameMaker architecture because it's more flexible for certain tasks. However, Lua does indeed support implementing inheritance, which could be beneficial for your project.
It's all about compile-time checking. I’m not super familiar with GameMaker, but an event-driven system feels similar to the editors used in games like Warcraft 3 or StarCraft. They still allow for some coding, though. I really like using UE blueprints, even though I haven't tackled C++ yet. If I learn it, I'd like to leverage both scripting systems for maximum flexibility.
UnrealScript worked by letting you declare classes within it, which the UnrealScript compiler would use to generate C++ headers for interoperability. In more recent versions of Unreal, like UE4 and UE5, the process is flipped with Blueprint. Here, you define classes in C++, and then a special markup is added for the Unreal Header Tool to generate the necessary reflection data for the Blueprint interpreter. It's a bit of a complex setup, but it really helps bridge the scripting and type systems seamlessly.

That sounds really complicated. I'm not a fan of custom build steps like that, which can be cumbersome. There might also be runtime reflection options to explore, but that could have its own set of challenges.