2DWorlds Forums
[RESOURCE][SKINS][LUA] Casual Team Skins - Printable Version

+- 2DWorlds Forums (http://2dworlds.buildism.net/forum)
+-- Forum: 2DWorlds (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=4)
+--- Forum: 2DWorlds Discussion (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=10)
+--- Thread: [RESOURCE][SKINS][LUA] Casual Team Skins (/showthread.php?tid=14)



[RESOURCE][SKINS][LUA] Casual Team Skins - Ghosty - 10-04-2012

I took a few minutes earlier today to create a set of basic skins for new users / team-based games. I already had the basic template created, so I tweaked shirt and hair colors to give more variety.

[Image: 21.png][Image: 26.png][Image: 31.png]

For users:
Choose the one you want and click "Add to My Stuff" to use. Then, go to the Change Character page and click "Use Skin".


Dark brown / black hair, blue shirt



Dark brown / black hair, red shirt



Dark brown / black hair, yellow shirt



Dark brown / black hair, green shirt



Blonde hair, blue shirt



Blonde hair, red shirt



Blonde hair, yellow shirt



Blonde hair, green shirt



Light brown hair, blue shirt



Light brown hair, red shirt



Light brown hair, yellow shirt



Light brown hair, green shirt


For game makers:

This script adds 4 teams to your game: Red, Blue, Yellow, and Green. Every player who joins gets added to one of these teams, and gets a skin of their team color. You can disable any team by setting the "use[color]team = true" line to false instead.

Code:
local teams = game:getService("Teams")

local red = teams:getChild("Red Team")
local blue = teams:getChild("Blue Team")
local yellow = teams:getChild("Yellow Team")
local green = teams:getChild("Green Team")

local useredteam = true
local useblueteam = true
local useyellowteam = true
local usegreenteam = true

local redshirts = {22, 26, 30}
local blueshirts = {21, 25, 29}
local yellowshirts = {23, 27, 31}
local greenshirts = {24, 28, 32}

if red == nil and useredteam == true then
red = create("Team")
red.Name = "Red Team"
red.Color = Color(255, 0, 0)
red.Parent = teams
end

if blue == nil and useblueteam == true then
blue = create("Team")
blue.Name = "Blue Team"
blue.Color = Color(0, 0, 255)
blue.Parent = teams
end

if yellow == nil and useyellowteam == true then
yellow = create("Team")
yellow.Name = "Yellow Team"
yellow.Color = Color(255, 255, 0)
yellow.Parent = teams
end

if green == nil and usegreenteam == true then
green = create("Team")
green.Name = "Green Team"
green.Color = Color(0, 255, 0)
green.Parent = teams
end

function getEmptiestTeam()
local reds = 0
local blues = 0
local yellows = 0
local greens = 0

local players = game.Players:getChildren()
for q = 1, #players do
if players[q].Stats:getChild("Team") ~= nil then
if players[q].Stats.Team.Value == "Red Team" then
reds = reds + 1
elseif players[q].Stats.Team.Value == "Blue Team" then
blues = blues + 1
elseif players[q].Stats.Team.Value == "Yellow Team" then
yellows = yellows + 1
elseif players[q].Stats.Team.Value == "Green Team" then
greens = greens + 1
end
end
end

if greens < yellows and greens < blues and greens < reds and usegreenteam == true then
return green
elseif yellows <= greens and yellows < blues and yellows < reds and useyellowteam == true then
return yellow
elseif blues <= greens and blues <= yellows and blues < reds and useblueteam == true then
return blue
elseif reds <= greens and reds <= yellows and reds <= blues and useredteam == true then
return red
else
error("No available teams!")
end

end

function changeSkin(p)
while p.Character == nil or p.Character.Health == 0 or p:getChild("Stats") == nil or p.Stats:getChild("Team") == nil do
sleep(0.01)
end

if p.Stats.Team.Value == "Red Team" then
p.Character.Skin = "http://2dworlds.org/asset/file/" .. tostring(redshirts[math.random(1, #redshirts)]) .. ".png"
elseif p.Stats.Team.Value == "Blue Team" then
p.Character.Skin = "http://2dworlds.org/asset/file/" .. tostring(blueshirts[math.random(1, #blueshirts)]) .. ".png"
elseif p.Stats.Team.Value == "Yellow Team" then
p.Character.Skin = "http://2dworlds.org/asset/file/" .. tostring(yellowshirts[math.random(1, #yellowshirts)]) .. ".png"
elseif p.Stats.Team.Value == "Green Team" then
p.Character.Skin = "http://2dworlds.org/asset/file/" .. tostring(greenshirts[math.random(1, #greenshirts)]) .. ".png"
else
print("Improper team stat value for " .. p.Name)
end

end

function addTeam(p)
link(p.Died, function()
changeSkin(p)
end)
local stats = p:getChild("Stats")
while stats == nil do
sleep(0.01)
end
local teamvalue = stats:getChild("Team")
if teamvalue == nil then
teamvalue = create("TextValue")
teamvalue.Name = "Team"
teamvalue.Parent = stats
end
teamvalue.Value = getEmptiestTeam().Name
changeSkin(p)
end

link(game.Players.ChildAdded, addTeam)



RE: [RESOURCE][SKINS][LUA] Casual Team Skins - Leonartist - 11-26-2012

They're just Jeff recolors.


RE: [RESOURCE][SKINS][LUA] Casual Team Skins - Ghosty - 11-26-2012

No, this is a Jeff recolor:

http://2dworlds.org/items/Jeff-Recolor/159