normalize line endings

This commit is contained in:
NullBite 2022-03-14 22:13:14 -04:00
parent 7b13932af6
commit 60b5cb495c
Signed by: nullbite
GPG Key ID: 6C4D545385D4925A
2 changed files with 128 additions and 127 deletions

1
.gitattributes vendored

@ -1,2 +1,3 @@
*.xcf filter=lfs diff=lfs merge=lfs -text *.xcf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text *.png filter=lfs diff=lfs merge=lfs -text
* text=auto

@ -1,127 +1,127 @@
-- Texture dimensions -- -- Texture dimensions --
size = 128 size = 128
factor = size / 64 factor = size / 64
-- Values for UV mappings -- -- Values for UV mappings --
face_damage=0 face_damage=0
face_expr=0 face_expr=0
step_u_face=32 step_u_face=32
step_v_face=16 step_v_face=16
offset_u_face=64 offset_u_face=64
offset_v_face=0 offset_v_face=0
armor_enabled=true armor_enabled=true
-- initialize values -- -- initialize values --
function player_init() function player_init()
old_health=player.getHealth() old_health=player.getHealth()
end end
expr_cooldown=0 expr_cooldown=0
-- Parts -- -- Parts --
HEAD=model.Head.Head HEAD=model.Head.Head
-- Initial configuration -- -- Initial configuration --
for key, value in pairs(vanilla_model) do for key, value in pairs(vanilla_model) do
value.setEnabled(false) value.setEnabled(false)
end end
vanilla_model.CAPE.setEnabled(true) vanilla_model.CAPE.setEnabled(true)
-- Expression change -- -- Expression change --
function getExprUV(damage, expression) function getExprUV(damage, expression)
local u=offset_u_face+(damage*step_u_face) local u=offset_u_face+(damage*step_u_face)
local v=offset_v_face+(expression*step_v_face) local v=offset_v_face+(expression*step_v_face)
return {u/size,v/size} return {u/size,v/size}
end end
function changeExpression(_damage, _expression, ticks) function changeExpression(_damage, _expression, ticks)
-- u is damage, v is expression -- u is damage, v is expression
local damage = _damage local damage = _damage
local expression = _expression local expression = _expression
if damage == nil then if damage == nil then
damage = face_damage damage = face_damage
end end
if expression == nil then if expression == nil then
expression = face_expr expression = face_expr
end end
HEAD.setUV(getExprUV(damage,expression)) HEAD.setUV(getExprUV(damage,expression))
expr_cooldown=ticks expr_cooldown=ticks
end end
function setExpression(damage, expression) function setExpression(damage, expression)
face_damage=damage face_damage=damage
face_expr=expression face_expr=expression
HEAD.setUV(getExprUV(damage, expression)) HEAD.setUV(getExprUV(damage, expression))
end end
function resetExpression() function resetExpression()
HEAD.setUV(getExprUV(face_damage,face_expr)) HEAD.setUV(getExprUV(face_damage,face_expr))
end end
-- Action Wheel -- -- Action Wheel --
action_wheel.SLOT_1.setTitle('test expression') action_wheel.SLOT_1.setTitle('test expression')
action_wheel.SLOT_1.setFunction(function() ping.expressionTest() end) action_wheel.SLOT_1.setFunction(function() ping.expressionTest() end)
function ping.expressionTest() function ping.expressionTest()
setExpression(1,0) setExpression(1,0)
changeExpression(nil, 1, 10) changeExpression(nil, 1, 10)
end end
action_wheel.SLOT_2.setTitle('log health') action_wheel.SLOT_2.setTitle('log health')
action_wheel.SLOT_2.setFunction(function() print(player.getHealth()) end) action_wheel.SLOT_2.setFunction(function() print(player.getHealth()) end)
action_wheel.SLOT_3.setTitle('Toggle Armor') action_wheel.SLOT_3.setTitle('Toggle Armor')
action_wheel.SLOT_3.setFunction(function() ping.setArmor() end) action_wheel.SLOT_3.setFunction(function() ping.setArmor() end)
-- Pings -- -- Pings --
--- Damage function -- --- Damage function --
function ping.oof(health) function ping.oof(health)
if health <= 5 then if health <= 5 then
setExpression(1,0) setExpression(1,0)
end end
changeExpression(nil,1,10) changeExpression(nil,1,10)
end end
--- Heal function (revert expression) -- --- Heal function (revert expression) --
function ping.healed(health) function ping.healed(health)
setExpression(0,0) setExpression(0,0)
end end
--- Toggle Armor --- --- Toggle Armor ---
function ping.setArmor(enabled) function ping.setArmor(enabled)
if enabled == nil then if enabled == nil then
armor_enabled=not armor_enabled armor_enabled=not armor_enabled
else else
armor_enabled=enabled armor_enabled=enabled
end end
for key, value in pairs(armor_model) do for key, value in pairs(armor_model) do
value.setEnabled(armor_enabled) value.setEnabled(armor_enabled)
end end
end end
-- does not work on multiplayer, use ping.oof() -- does not work on multiplayer, use ping.oof()
function onDamage(amount, source) function onDamage(amount, source)
end end
-- Tick function -- -- Tick function --
function tick() function tick()
-- expression reset spaghetti code -- -- expression reset spaghetti code --
if expr_cooldown > 0 then if expr_cooldown > 0 then
expr_cooldown = expr_cooldown-1 expr_cooldown = expr_cooldown-1
if expr_cooldown <= 0 then if expr_cooldown <= 0 then
resetExpression() resetExpression()
end end
end end
-- optimization, only execute these once a second -- -- optimization, only execute these once a second --
if world.getTimeOfDay() % 20 then if world.getTimeOfDay() % 20 then
-- if face is cracked -- if face is cracked
if face_damage==1 and player.getHealth() > 5 then if face_damage==1 and player.getHealth() > 5 then
ping.healed() ping.healed()
end end
end end
-- Damage ping (onDamage doesn't work in multiplayer) -- -- Damage ping (onDamage doesn't work in multiplayer) --
if old_health>player.getHealth() then if old_health>player.getHealth() then
-- debug -- debug
-- print(string.format('old_health=%03.2f, player.getHealth=%03.2f', old_health,player.getHealth())) -- print(string.format('old_health=%03.2f, player.getHealth=%03.2f', old_health,player.getHealth()))
ping.oof(player.getHealth()) ping.oof(player.getHealth())
end end
-- End of tick -- -- End of tick --
old_health=player.getHealth() old_health=player.getHealth()
end end