Just doing this:
Code: Select all
newunit.name = "testunit"
newunit.objectname = "cube.s3o"
newunit.script = "empty.lua"
UnitDefs["testunit"] = newunit
/give testunit
testunit is not a valid unitname
If I add something on top to copy every tag from an existing unitdef like this:
Code: Select all
newunit = {}
ud = UnitDefs ["tpthulsa"]
for key,value in pairs(ud) do
Spring.Echo(key,value)
newunit[key]=value
end
newunit.name = "testunit"
newunit.objectname = "cube.s3o"
newunit.script = "empty.lua"
UnitDefs["testunit"] = newunit
So I thought that maybe name, objectname & script alone are not enough to define a valid unitDef.
But this unitdef works, when saved as units\cube.lua:
Code: Select all
local unitName = "cube"
local unitDef = {
name = "Cube Unit",
objectName = "cube.s3o",
script = "empty.lua",
}
return lowerkeys({ [unitName] = unitDef })
So what is going on there?
Are the rules for unitdefs_post just more strict?
Or something else?