Tiny but useful little lua gadget

Tiny but useful little lua gadget

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Tiny but useful little lua gadget

Post 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
Last edited by Forboding Angel on 09 Sep 2009, 20:58, edited 2 times in total.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Tiny but useful little lua gadget

Post by lurker »

Not sure why you want to put my name on it. Three lines of code that you didn't even indent.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Tiny but useful little lua gadget

Post by smoth »

What happens when a player loses connection. I still have to address such an issue in gundam.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Tiny but useful little lua gadget

Post 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
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Tiny but useful little lua gadget

Post by lurker »

You have two options. NBSP or
Post Reply

Return to “Lua Scripts”