1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--
-- file: featuredefs_post.lua
-- brief: featureDef post processing
-- author: Dave Rodgers
--
-- Copyright (C) 2008.
-- Licensed under the terms of the GNU GPL, v2 or later.
--
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--
-- Per-unitDef featureDefs
--
--------------------------------------------------------------------------------
local function isbool(x) return (type(x) == 'boolean') end
local function istable(x) return (type(x) == 'table') end
local function isnumber(x) return (type(x) == 'number') end
local function isstring(x) return (type(x) == 'string') end
--------------------------------------------------------------------------------
local function ProcessUnitDef(udName, ud)
local fds = ud.featuredefs
if (not istable(fds)) then
return
end
-- add this unitDef's featureDefs
for fdName, fd in pairs(fds) do
if (isstring(fdName) and istable(fd)) then
local fullName = udName .. '_' .. fdName
FeatureDefs[fullName] = fd
end
end
-- FeatureDead name changes
for fdName, fd in pairs(fds) do
if (isstring(fdName) and istable(fd)) then
if (isstring(fd.featuredead)) then
local fullName = udName .. '_' .. fd.featuredead:lower()
if (FeatureDefs[fullName]) then
fd.featuredead = fullName
end
end
end
end
-- convert the unit corpse name
if (isstring(ud.corpse)) then
local fullName = udName .. '_' .. ud.corpse:lower()
local fd = FeatureDefs[fullName]
if (fd) then
ud.corpse = fullName
end
end
end
--------------------------------------------------------------------------------
-- Process the unitDefs
local UnitDefs = DEFS.unitDefs
for udName, ud in pairs(UnitDefs) do
if (isstring(udName) and istable(ud)) then
ProcessUnitDef(udName, ud)
end
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
|