ive wrote script based systems for this kind of thing. my table parser and meta systems are in all my scripts. but i noticed that very few people actually use those systems, instead opting to write their own from scratch. this is wasted effort and a hindrance to anyone trying to learn scripting, or modders who want to use imported scripts. these things seem somewhat fundamental to what most people try to do with scripting, and that is make objects in the game do things they dont normally do. needless to say this is yet another rehash of a very old idea of mine (that ive probibly brought up several times).
anyway im thinking of a way to integrate this stuff on the c side (should point out now that i only want to discuss the idea of this system, im not intending this as a feature request or something i may be planning to do). i want to make a general structure for storing script variables which are bound to an object class (anything accessed in lua through a handle) and/or instance (an actual game object like a ship or a weapon). these variables would be defined in the varous freespace table files that modders know and love. lets call it a meta page. its not defined in scripting but in the tables. it would look something like this:
$Meta Page:
+Class Vars:
+Number: "meaningOfLife" 42
+String: "aLameHaiku" "shivans everywhere\nwe will die\nbosch is shivan food"
+Number "maxBrowniePoints" 60
+Instance Vars:
+Bool: "enableBigAssGun" false
+Bool: "moreExplosions" true
+Bool: "useCustomFeatures" true
+Number: "browniePoints" 0
fairly simple you have a list of variables with a datatype a name and a default value (this can be changed in scripting). there are two sections here: +Class Vars: are the vars that apply to every instance of that object.
+Instance Vars: apply to every object of that type. say this is defined in a weapon table entry. the class vars will be the same for every weapon, if you change it for one you change it for all. the instance variables can change on an object by object basis. so one instance of a weapon may have 0 browniePoints and another may have 10. browniePoints is just an example. say you wanted a missile that shoots lasers, but only a certain number of shots you might have an ammo field which decriments each time the missile fires a laser. on the script side of things you can gain access to the data through the associated weapon class handle or weapon handle.
wep = mn.Weapons[wpnidx]
wepCl = wep.Class
haiku = wepCl.Meta.aLameHaiku
bpnts = wep.Meta.browniePoints
if wep.Meta.moreExplosions then
blow****Up()
end
and this is just the obvious example. you could apply this other features of the game. ships, object types, hud gauges, input mapping, the pilot (perhaps allow you to save scrip meta to the pilot file). so the system would need to be fairly generic. the data itself would be stored in a c++ object which is exposed to scripting, which could be added as a variable to any structure in the game that gets its data from a table. the class would also include the parsing routines too allow it to be loaded with a single function call. the game itself mostly wont care what gets stored there. and how the data is utilized is entirely up to the scripter.
main benefits here are cleaner scripts, lower memory usage (your not relying on lua's memory sucking tables to store data for every object in the game), more secure than parsing custom files, allows modder friendly scripts, and you dont need megalithic scripts to create systems the game should provide, etc.