Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function gadget:GameFrame(frame)
- if frame % 12 < .1 then
- for unitId, timeLeft in pairs(saleTime) do
- if timeLeft < frame then
- local unitDefId = spGetUnitDefID(unitId)
- local teamId = spGetUnitTeam(unitId)
- local ux, uy, uz = Spring.GetUnitPosition(unitId)
- spDestroyUnit(unitId, false, true)
- --Spring.Echo(resCount, type(resCount))
- if resCount and resCount ~= "" then
- for i = 1,resCount do
- resources[teamId][i] = min(resources[teamId][i] + (unitCost[unitDefId][i] or 0) * refundFactor, capacity[teamId][i])
- end
- else
- local currentMetal = Spring.GetTeamResources(teamId,"metal")
- local currentEnergy = Spring.GetTeamResources(teamId,"energy")
- local unitMetal = (UnitDefs[unitDefId].metalCost or 0) * refundFactor
- local unitEnergy = (UnitDefs[unitDefId].energyCost or 0) * refundFactor
- --Spring.Echo(currentMetal, unitMetal)
- Spring.SetTeamResource(teamId, "m", currentMetal + unitMetal)
- Spring.SetTeamResource(teamId, "e", currentEnergy + unitEnergy)
- Spring.PlaySoundFile('sounds/chaching.wav', 5, ux, uy, uz)
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment