comparison Main.lua @ 289:43a058bd38e0

Robustified DBEntry()
author James D. Callahan III <jcallahan@curse.com>
date Mon, 20 May 2013 10:43:18 -0500
parents d841c44553d5
children 385237bb6ab9
comparison
equal deleted inserted replaced
288:d841c44553d5 289:43a058bd38e0
294 294
295 local function DBEntry(data_type, unit_id) 295 local function DBEntry(data_type, unit_id)
296 if not data_type or not unit_id then 296 if not data_type or not unit_id then
297 return 297 return
298 end 298 end
299 local unit = global_db[data_type][unit_id] 299 local category = global_db[data_type]
300
301 if not category then
302 category = {}
303 global_db[data_type] = category
304 end
305 local unit = category[unit_id]
300 306
301 if not unit then 307 if not unit then
302 unit = {} 308 unit = {}
303 global_db[data_type][unit_id] = unit 309 category[unit_id] = unit
304 end 310 end
305 return unit 311 return unit
306 end 312 end
307 313
308 private.DBEntry = DBEntry 314 private.DBEntry = DBEntry