03-20-2011, 09:15 PM
(This post was last modified: 03-20-2011, 09:17 PM by Jacob__mybb_import1.)
If you make a left, right, and center version of a skin, you can use this script to make all players of your game use it. The direction they are facing will change appropriately as they move.
[lua]left ="http://buildism.net/asset/file/152.png"
center = "http://buildism.net/game/defaultskin.png"
right = "http://buildism.net/asset/file/153.png"
character = nil
function propertyChanged(name, value)
if name == "Velocity" then
if value.x == 0 then
character.Skin = center
elseif value.x < 0 then
character.Skin = left
elseif value.x > 0 then
character.Skin = right
end
end
end
function childAdded(newcharacter)
if newcharacter:isA("Character") and game.Players:getChild(newcharacter.Name) ~= nil then
character = newcharacter
character.Skin = center
local c = character.Body:getChild("Controller")
if c ~= nil and c:isA("VelocityController") then
link(c.PropertyChanged, propertyChanged)
end
end
end
link(game.World.ChildAdded, childAdded)[/lua]
I'm thinking about officially adding this to the game. I would put space in the skin file for 2 extra heads, so you can do the effect with just one file, and it will work at any game. Opinions?
[lua]left ="http://buildism.net/asset/file/152.png"
center = "http://buildism.net/game/defaultskin.png"
right = "http://buildism.net/asset/file/153.png"
character = nil
function propertyChanged(name, value)
if name == "Velocity" then
if value.x == 0 then
character.Skin = center
elseif value.x < 0 then
character.Skin = left
elseif value.x > 0 then
character.Skin = right
end
end
end
function childAdded(newcharacter)
if newcharacter:isA("Character") and game.Players:getChild(newcharacter.Name) ~= nil then
character = newcharacter
character.Skin = center
local c = character.Body:getChild("Controller")
if c ~= nil and c:isA("VelocityController") then
link(c.PropertyChanged, propertyChanged)
end
end
end
link(game.World.ChildAdded, childAdded)[/lua]
I'm thinking about officially adding this to the game. I would put space in the skin file for 2 extra heads, so you can do the effect with just one file, and it will work at any game. Opinions?