Page 1 of 1

Tiny but useful little lua gadget

Posted: 09 Sep 2009, 10:08
by Forboding Angel
The entire poi9nt of this gadget is to alleviate having to tie starting resource income to a unit. I figured others might like to have it. The values are obvious enough, but this gadget gives those values per second all game long to each player.

For example, BA could make it so that the comm didn't have an income of 2/2 anymore, but that the 2/2 was there not tied to a unit. To edit, just change the values that I highlighted in red.
function gadget:GetInfo()
return {
name = "Resource Gifts",
desc = "Adds 1/1 resource income so that I don't have to tie it to units anymore",
author = "lurker (Dylan Petonke)",
date = "Sept 8 2009",
license = "GPL",
layer = 1,
enabled = true
}
end


if (gadgetHandler:IsSyncedCode()) then
---synced----

function gadget:GameFrame(n)
if n%30 == 4 then
for _,i in ipairs(Spring.GetTeamList()) do
Spring.AddTeamResource(i,"e",1)
Spring.AddTeamResource(i,"m",1)
end
end
end

end --for ifsynced

Re: Tiny but useful little lua gadget

Posted: 09 Sep 2009, 14:12
by lurker
Not sure why you want to put my name on it. Three lines of code that you didn't even indent.

Re: Tiny but useful little lua gadget

Posted: 09 Sep 2009, 18:10
by smoth
What happens when a player loses connection. I still have to address such an issue in gundam.

Re: Tiny but useful little lua gadget

Posted: 09 Sep 2009, 21:01
by Forboding Angel
lurker wrote:Not sure why you want to put my name on it. Three lines of code that you didn't even indent.
Actually I did, quote stripped the spaces tho.

@smoth I'm not entirely sure what you mean. Loses connection as in drops and is no longer there? If that's the case the team of untaken units will still gain 1/1, but once the units are taken, the previous tem no longer exists, so that magic 1/1 income will simply vanish.

Otherwise the player who took the units would end up with 2/2 and we can't ahve that now can we ;p

Re: Tiny but useful little lua gadget

Posted: 10 Sep 2009, 06:17
by lurker
You have two options. NBSP or