Can you add fields to a type at runtime?

Blitz3D Forums/Blitz3D Beginners Area/Can you add fields to a type at runtime?

PowerPC603(Posted 2004) [#1]
Hi all, maybe this is a strange (perhaps stupid) question,
but can you add fields to a type at runtime?

I'm creating a game like Freelancer (sort of space sim),
where I use an array (filled with types) to hold all data about sectors, spacestations, planets, ...

When I've completed the game, I want the game to be able to use Mod-packs.

For example:
On a station, you can buy and sell commodities like Water, Fuel, computers, ...

I want each station to be able to buy/sell some specific commodities (not all).
Therefore I use fields like WaterSells and WaterPrice in the type StationCommodities.
I use that type in an array, so I can refer to a specific station (each one has a number) with the index of the array.

But when a Mod-pack comes out, I may have added some new commodities.
And their fields (new commodity: Crystals, fields: CrystalSells and CrystalPrice) must be added to that type.

Is this possible, without recompiling the exe, which holds the edited types?


jhocking(Posted 2004) [#2]
I don't think fields can be added without recompiling the exe. But this isn't a big deal for an add-on/mod. Just include the new exe with the mod, and overwrite the old exe when installing. For most mods, the size of the exe will be pretty minor relative to the size of the added art and sound assets.


Wiebo(Posted 2004) [#3]
I would add the commodoties in a linked list which you can add to a type. you can expand the linked list with new commodities endlessly


eBusiness(Posted 2004) [#4]
Whatever, you are probably not going to expand your game without modifying the anyways.