Questions About Managing Embedded Scripts in C++
Members - Reputation: 815
Posted 30 October 2012 - 08:43 AM
If the Lua code is literally in the C++ code, then I immediately lose the huge benefit of being able to make changes to the script without having to recompile. I know one solution is to load the code as a string of characters from some outside file and pass that to the function. Or, if I just have the wrong attitude about this, what might be some wise options for loading up the script from some outside source? Right now my only plan is to write it up in a text editor with highlighting (like gedit), save it as a text file and load it up manually from there using the filestream. Plan B is to use pugixml (an xml parser) in a hacky way to read the script in.
Also, feel free to let me know if I'm just confronting this problem completely wrongly. Maybe dealing with a scripting language isn't the right move at all?
Members - Reputation: 498
Posted 30 October 2012 - 06:53 PM
I know one solution is to load the code as a string of characters from some outside file and pass that to the function. Or, if I just have the wrong attitude about this, what might be some wise options for loading up the script from some outside source?
It's not quite that complicated. What you want is luaL_dofile. No need to manage the file streams yourself.
Between Scylla and Charybdis: First Look <-- The game I'm working on
Object-Oriented Programming Sucks <-- The kind of thing I say
Members - Reputation: 756
Posted 30 October 2012 - 08:39 PM
Also, the test/example in Luabind is using C++ string for script doesn't mean you must do it.
You can always load the script from anywhere you want, an external file, an XML, what ever, and call Lua API to execute, no matter which script binding engine you are using.
cpgf library -- free C++ open source library for reflection, serialization, script binding, callbacks, and meta data for OpenGL Box2D, SFML and Irrlicht.
v1.5.5 was released. Now supports tween and timeline for ease animation.
Members - Reputation: 841
Posted 31 October 2012 - 02:35 AM
First technology demo of my game Shinya is out: http://lauris.kaplinski.com/shinya
Khayyam 3D - a freeware poser and scene builder application: http://khayyam.kaplinski.com/