to touch) for a video game?
I was trying to integrate Lua into my game, but it is a bit tough language to debug any errors, and the fact that one can't copy Lua state feels like a potential issue (either I would need to share a mutable state across different places in code, or I would need to fully recreate it each time). Also it took some time to make it safe and useful to work with C++ types, but that was a fun part at least.
I'm looking into AngelScript, daScript and quirrel, but maybe you have experience with some other languages that you've liked or hated
Lua is a solid choice but has it's limitations. Avoid writing your own scripting language
are you using a game engine? or you are somehow making your own engine?
my own, it is a small SDL-based game
Forth is really simple and easy to embed, and optimizing can be after the fact quite easily to get very fast performance (even near C-speed)
near C speed is a myth for anything over 10 lines of code in the context of scripting; unless you go through the works of using a JIT which mostly defeats a lot of the benefits of using a scripting language to begin with
This is not true, well implemented Forth is generally near C speed, sometimes more performant.
Oh I'm talking about Lua, don't know Forth
I am curious why you wouldn't just use C for scripting?
Not sure if I understand what you mean :)
One of the big reasons/advantages is developing the game in real time without having to recompile the engine, especially for things that get tweaked a billion times a day throughout development. That and simple "action events" that may occur in a game. As far as general purpose programming(i.e setting up player movement, enemy ai, etc) it's definitely favourable to use C or whatever the engine language is
Just build scripts into dynamic libraries and have the engine watch a folder for changes, whenever a dynlib changes, reload it
Ah well, there's live++ for that as well, doesn't even need extra libraries, but I wouldn't say that's super convenient
and open the door for internal cheats
but if the game isnt online it doesnt matter tho
What makes it inconvenient
It is not really easy to prototype in C++ or C since there is usually a lot of boilerplate associated with doing anything + all the complexity associated with memory management. Also there's this effect of: - either trying to write a complete solution under disguise of a prototype (based on habits working with the language), which makes it slower to prototype - or the opposite, after writing a prototype just leaving it as it is and calling it the final solution, which worsens the quality of C++ code Not that I care about it now though.
Обсуждают сегодня