I think the trap is engine people trying to decide what variables Lua/Java/Whatever will want to read. A better approach would be to store pretty much any engine gameplay variable in an exportable form unless there is a clear performance impact. I suspect there is a lot of stuff in C variables that are only inaccessable because of programming convenience. What would be ideal I think is for many key variables to be written back to a global array that has a set of access functions in all hosted languages. So in C the code would be something like
Code: Select all
#include globalvars
int game_time = 0;
// var name, access flags, description
createGlobalVarInt("game_time", AI|GAIA|SYNCED, "Game time in ticks");
// ... then in later code ...
int game_time = getGlobalVarInt("game_time");
// ... do C stuff with game_time ...
setGlobalVarInt("game_time", game_time);
Code: Select all
local gvars = Spring.getGlobalVars()
print "Elapsed Time: " .. gvars.game_time
If used consistently it would provide a framework for what I was talking about earlier. Obviously it needs more thought but I think the principle of the concept is sound.
