Doing things in Lua or the DLL

ls612

Deity
Moderator
Joined
Mar 10, 2008
Messages
8,276
Location
America
As part of New Horizons I'm adding a lot of different functionality which is not included in the base BNW. These include new mechanics on buildings, units, technologies, and other game objects which aren't available with the stock SQL/XML.

My question is, many of these things I'm planning can be implemented either as lua scripts or as C++ code in the DLL. Is there any benefit to using one or the other? I prefer the C++ code because A) I know C++ well and don't know Lua too well and B) it is compiled and should theoretically run faster than equivalent Lua code. Are there other considerations that I should be aware of here?
 
The only real issue with making a new DLL is compatibility; you can only have one DLL at a time so it's not really suited for individual mod components and won't work with any other mod that also uses its own DLL.

However, a new DLL is highly suited for a more total mod release not only for its speed but you're much less limited than you are with lua.
 
Speed is almost a pointless consideration given:
  1. The core game engine is firing a dozen or more Lua functions in UI for every AI player turn (including city states).
  2. It's possible to write an iterator in Lua that is 70x faster than Firaxis' C++ iterator that does the same thing.
C++ ought to be faster by a wide margin, but you can blow this advantage very easily.


Other considerations:
What is possible (dll wins)
Modularity (Lua wins)
Ease of updates (Lua wins, but this will be diminishing consideration after 2013)
Ease of coding (personal preference)
 
Back
Top Bottom