Home » PLAYER'S HQ 1.13 » JA2 Complete Mods & Sequels » Stracciatella Project (Platform Independent JA2) » Data externalisation
Data externalisation[message #189797]
|
Sun, 29 June 2008 19:44
|
|
Tron |
|
Messages:225
Registered:August 2007 Location: Germany |
|
|
I'm working a bit on data externalisation for JA2-Stracciatella. I plan to use simple key/value pairs. It will look about like this:
weapon GLOCK_17 {
weapon_class = HANDGUNCLASS,
weapon_type = GUN_PISTOL,
calibre = AMMO9,
ready_time = 0,
rate_of_fire = 14,
bullet_speed = 24,
impact = 21,
deadliness = 8,
clip_size = 15,
range = 120,
attack_volume = 60,
impact_volume = 5,
fire_sound = S_GLOCK17
}
I'll probably start with merge combinations, because this has the least dependencies in the source:
merge { result = FIRSTAIDKIT, action = COMBINE_POINTS }
merge { result = MEDICKIT, action = COMBINE_POINTS }
merge { result = LOCKSMITHKIT, action = COMBINE_POINTS }
merge { item1 = COMPOUND18, item2 = FLAK_JACKET, result = FLAK_JACKET_18, action = TREAT_ARMOUR }
merge { item1 = COMPOUND18, item2 = FLAK_JACKET_Y, action = DESTRUCTION }
merge { item1 = RDX, item2 = TNT, result = HMX, action = EXPLOSIVE }
merge {
item1 = STRING,
item2 = TIN_CAN,
result = STRING_TIED_TO_TIN_CAN,
action = EASY_MERGE
}
merge {
item1 = FLASH_DEVICE,
item2 = DISPLAY_UNIT,
result = XRAY_DEVICE,
action = ELECTRONIC_MERGE
}
Parsing this only needs a very simple recursive descent parser. Of course the order of the key/value pairs and placement of whitespace does not matter. Consistency (typo in key, a missing mandatory key, etc.) is checked when the input is parsed and an appropriate error message will be generated:
merge { item1 = RDX, item2 = TNT, resul = HMX, action = EXPLOSIVE }
merge.cfg:1:35: error: got unknown key "resul"
merge { item1 = RDX, item2 = TNT, action = EXPLOSIVE }
merge.cfg:1:1: error: merge has no valid result
I think, this approach leads to configuration files, which are easy to read and edit.
Report message to a moderator
|
Sergeant 1st Class
|
|
|
|
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Mon Jan 20 10:56:48 GMT+2 2025
Total time taken to generate the page: 0.01855 seconds
|