Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- $Id$
- function gadget:GetInfo()
- return {
- name = "Space Rock",
- desc = "Spawns rocks from space.",
- author = "oksnoop2",
- date = "4/24/2010",
- license = "GNU GPL, v2 or later",
- layer = 0,
- enabled = false, -- loaded by default?
- }
- end
- if (not gadgetHandler:IsSyncedCode()) then
- return false -- no unsynced code
- end
- local oldUnitName = "meteor"
- local testUnitName = "meteor"
- local testUnitDefID = UnitDefNames[testUnitName].id
- function gadget:UnitCreated(unitID, unitDefID, unitTeam)
- local name = UnitDefs[unitDefID].name
- if (name == "meteor" ) then
- local x, y, z = Spring.GetUnitPosition(unitID)
- Spring.CreateUnit(testUnitName, x, y, z, 0, unitTeam)
- end
- end
- function gadget:UnitDestroyed(unitID, unitDefID, unitTeam)
- if UnitDefNames[oldUnitName].id == unitDefID then
- local x, y, z = Spring.GetUnitPosition(unitID)
- Spring.CreateUnit(testUnitName, x, y, z, 0, unitTeam)
- end
- end
- function gadget:GameFrame(frame)
- if frame % 30 == 0 then -- every second
- local x = math.random(Game.mapSizeX)
- local z = math.random(Game.mapSizeZ)
- local unitID = Spring.CreateUnit("meteor", x, 0, z, "n", Spring.GetGaiaTeamID)
- Spring.MoveCtrl.Enable(unitID)
- Spring.MoveCtrl.SetPosition(unitID, x, Spring.GetGroundHeight(x, z) + 10000, z)
- Spring.MoveCtrl.SetGravity(unitID, 100)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement