Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function gadget:GetInfo()
- return {
- name = "feature placer",
- desc = "Spawns Features and Units",
- author = "Gnome, Smoth",
- date = "August 2008, updated 7/11/2014",
- license = "PD",
- layer = 0,
- enabled = true -- loaded by default?
- }
- end
- -- these are here because I like the way they look
- local spSetUnitNeutral = Spring.SetUnitNeutral
- local spSetUnitBlocking = Spring.SetUnitBlocking
- local spSetUnitRotation = Spring.SetUnitRotation
- local spSetUnitLosState = Spring.SetUnitLosState
- local spSetUnitAlwaysVisible = Spring.SetUnitAlwaysVisible
- local spCreateUnit = Spring.CreateUnit
- local spGetGaiaTeamID = Spring.GetGaiaTeamID
- local spCreateFeature = Spring.CreateFeature
- local spGetGroundHeight = Spring.GetGroundHeight
- local spEcho = Spring.Echo
- local featurecfg
- local featureslist = {}
- local buildinglist = {}
- local unitlist = {}
- local rotationMultiplier = math.pi / 32768
- if gadgetHandler:IsSyncedCode() then
- --SYNCED
- function gadget:GamePreload()
- if VFS.FileExists("config/featureconfig.lua") then
- featurecfg = VFS.Include("config/featureconfig.lua")
- featureslist = featurecfg.objectlist
- buildinglist = featurecfg.buildinglist
- unitlist = featurecfg.unitlist
- else
- spEcho("No gamename specific features loaded")
- end
- if ( featurecfg ~= nil ) then
- gaiaTeamID = spGetGaiaTeamID()
- if ( featureslist ) then
- for _,fDef in pairs(featureslist) do
- if FeatureDefNames[fDef.name] then
- spCreateFeature(fDef.name, fDef.x, spGetGroundHeight(fDef.x,fDef.z)+5, fDef.z, fDef.rot)
- else
- spEcho("featureplacer warning: invalid feature name", fDef.name)
- end
- end
- end
- if ( unitlist ) then
- for _,uDef in pairs(unitlist) do
- if UnitDefNames[uDef.name] then
- local unitId = spCreateUnit(uDef.name, uDef.x, 0, uDef.z, 0, gaiaTeamID)
- if unitId ~= nil then
- spSetUnitRotation(unitId, 0, -uDef.rot * rotationMultiplier, 0)
- spSetUnitNeutral(unitId,true)
- spSetUnitBlocking(unitId,true)
- spSetUnitAlwaysVisible(unitId,true)
- spSetUnitLosState(unitId,0,{los=true, prevLos=true, contRadar=true, radar=true})
- end
- else
- spEcho("featureplacer warning: invalid unit def name", bDef.name)
- end
- end
- end
- if ( buildinglist ) then
- for _,bDef in pairs(buildinglist) do
- if UnitDefNames[bDef.name] then
- local buildingId = spCreateUnit(bDef.name, bDef.x, 0, bDef.z, bDef.rot, gaiaTeamID)
- if buildingId ~= nil then
- spSetUnitNeutral(buildingId,true)
- spSetUnitBlocking(buildingId,true)
- spSetUnitAlwaysVisible(buildingId,true)
- spSetUnitLosState(buildingId,0,{los=true, prevLos=true, contRadar=true, radar=true})
- end
- else
- spEcho("featureplacer warning: invalid building def name", bDef.name)
- end
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement