16
General / Re: RPG Data Serialization Methods
« on: August 16, 2013, 04:47:47 am »For something like loading a string of text for the NPC to say, then yes, using Lua is definitely overkill. That article does eventually talks about some of the better use cases for why Lua was used, though. Things like NPC movements, handling quest branches, and enemy AI can all be handled in your scripting language.
But you had mentioned,QuoteIf you've already coded everything in C++ yourself, then I don't know of any reason you'd want to integrate Lua into your game, unless one of the core mechanics is letting the player write code.
Sure, that's definitely something you can have as part of your game, but the main reason people use scripting languages is because they get interpreted when they are loaded, so there is no compiling going on. That means you can make a quick change, and simply run your game again. There are also systems(Wolfire's Overgrowth engine is such an example) that will actually auto-load and make the changes when it detects a change in the script file.
Of course, this is all fine and dandy, but be aware that there is some overhead when running scripting code since it is interpreted at runtime.
As far as other data goes, like items, character stats, etc., how you load that really depends on what you want to interact with. You can use an XML file, a plain text file, a YAML file, a binary file, and the list goes on. If this is your first RPG, use what ever you are comfortable with!
I can definitely understand where things being loaded at runtime would be an advantage. I wasn't really sure if Lua had to be compiled. To be honest I didn't know about compiled vs scripting languages.
So the advantage in using Lua with c++ would be I wouldn't have to recompile the game to test and create content like npc dialog or movement. I could have the game/engine coded completely independently from its content. Sounds like a very clean almost encapsulated way of doing things. I'll start learning Lua.
About the RPG, I've been kind of making the same game over and over again, each time moving up languages, improving the classes and organisation of the engine/game and implementing superior methods (like this for example, moving from .txt files to Lua would be awesome!) So far I've made it (to some extent) in java and c#. C++ makes the 3rd language I've written it in.
Any tips for starting with Lua?