|
|
| Implementing a game (cont'd, other thread locked?) |
|
Schala Zeal
Member #11,509
November 2009
|
Well I looked at Luabind a bit further and I believe because Lua is a vital scripting language for games, and in general, and given that Boost is pretty essential for C++, I doubt it's going anywhere. I'm actually hoping Boost officially supports it as they do with Python, perhaps merge it. So after looking at LB further, I decided to pick it up. My only complaint has to be lack of an API reference. Rasterbar claims to have this, and although useful, is pretty much a tutorial. I'm kind of wondering how to manipulate arrays and strings though. Yeah, there's vector but that seems to be bigger in size than a raw array. As for strings, there's std::string, but I want each string entry only 128 characters per dialogue entry. I really don't prefer using memory meant for a 2 million character string for a simple 128 character string. Again, I mean an array of 128-character string entries. An array of std::strings would like result in more memory used than necessary |
|
Evert
Member #794
November 2000
|
Schala Zeal said: I'm kind of wondering how to manipulate arrays and strings though. Yeah, there's vector but that seems to be bigger in size than a raw array.
Insignificantly so. Quote: As for strings, there's std::string, but I want each string entry only 128 characters per dialogue entry. I really don't prefer using memory meant for a 2 million character string for a simple 128 character string.
Quote: Again, I mean an array of 128-character string entries. An array of std::strings would like result in more memory used than necessary
Huh? I guess I'm not really sure what you're asking here. |
|
X-G
Member #856
December 2000
|
Evert said: There should be fairly little overhead to using an std::string for a short character sequence There should in fact be no overhead at all for sufficiently short strings, or 4-8 bytes for other strings. -- |
|
imaxcs
Member #4,036
November 2003
|
Even if there is an overhead when using std::string over a pure char array, you can most definately ignore it and just benefit from the functionality std::string has over char[]. We are talking about (at most) a few bytes per string. Do you have less than a million strings? Then forget about the overhead!
|
|
BAF
Member #2,981
December 2002
|
And if you did have a million strings, the overhead is still (likely) negligible. |
|
Bruce Perry
Member #270
April 2000
|
I think the point is std::string won't use up two million characters' worth of memory unless you actually store a two-million-character string in one. If your string is 128 characters long, then the std::string will use just slightly over 128 bytes of memory (assuming one byte per character). -- |
|
Fishcake
Member #8,704
June 2007
|
Schala Zeal said: My only complaint has to be lack of an API reference. Rasterbar claims to have this, and although useful, is pretty much a tutorial. I agree with you there. The documentation lacks detail. Though maybe it's because the documentation is targeted for those whom have experience with Lua's C API (I barely touched it). Some of the functions are vaguely documented, and I had to search through some development blogs to find out how to use them.
|
|
Schala Zeal
Member #11,509
November 2009
|
Well, one of the things I got annoyed about was lack of an explanation on how to get/set Lua variables, but a third-party site told me: to get: luabind::globals(L)["somevar"]; to set, it's simply adding the C/C++ assignment statement: luabind::globals(L)["somevar"] = 2; I also found out Luabind represents Lua tables as luabind::object, which can also represent any variable type in Lua! This'll be fun! |
|
|