Implement color locking and state checks
This commit is contained in:
parent
b72b045f29
commit
9e70916c0e
44
script.lua
44
script.lua
@ -539,7 +539,7 @@ REG_TAIL_BONES={
|
|||||||
model.Body_Tail.Tail_L2.Tail_L3,
|
model.Body_Tail.Tail_L2.Tail_L3,
|
||||||
model.Body_Tail.Tail_L2.Tail_L3.fin
|
model.Body_Tail.Tail_L2.Tail_L3.fin
|
||||||
}
|
}
|
||||||
EMISSIVES={
|
BODY_EMISSIVES={
|
||||||
model.Body.MTail1.MTailDots1,
|
model.Body.MTail1.MTailDots1,
|
||||||
model.Body.MTail1.MTail2.MTailDots2,
|
model.Body.MTail1.MTail2.MTailDots2,
|
||||||
model.Body.MTail1.MTail2.MTail3.MTailDots3,
|
model.Body.MTail1.MTail2.MTail3.MTailDots3,
|
||||||
@ -548,13 +548,17 @@ EMISSIVES={
|
|||||||
model.Body_Tail.Tail_L2.TailDots2,
|
model.Body_Tail.Tail_L2.TailDots2,
|
||||||
model.Body_Tail.Tail_L2.Tail_L3.TailDots3,
|
model.Body_Tail.Tail_L2.Tail_L3.TailDots3,
|
||||||
model.Body_Tail.Tail_L2.Tail_L3.fin.TailDots4,
|
model.Body_Tail.Tail_L2.Tail_L3.fin.TailDots4,
|
||||||
model.Head.Face,
|
|
||||||
model.Head.EmDots
|
model.Head.EmDots
|
||||||
}
|
}
|
||||||
|
FACE_EMISSIVES={
|
||||||
|
model.Head.Face
|
||||||
|
}
|
||||||
|
EMISSIVES=mergeTable(BODY_EMISSIVES, FACE_EMISSIVES)
|
||||||
COLORS={}
|
COLORS={}
|
||||||
COLORS.neutral=vectors.of{127/255,127/255,255/255}
|
COLORS.neutral=vectors.of{127/255,127/255,255/255}
|
||||||
COLORS.hurt= vectors.of{1, 0, 63/255}
|
COLORS.hurt= vectors.of{1, 0, 63/255}
|
||||||
COLORS.lava= vectors.of{1, 128/255, 64/255}
|
COLORS.lava= vectors.of{1, 128/255, 64/255}
|
||||||
|
COLORS["end"]="end"
|
||||||
for k, v in pairs(EMISSIVES) do
|
for k, v in pairs(EMISSIVES) do
|
||||||
v.setColor(COLORS.neutral)
|
v.setColor(COLORS.neutral)
|
||||||
end
|
end
|
||||||
@ -699,8 +703,10 @@ SNORES={"snore-1", "snore-2", "snore-3"}
|
|||||||
do
|
do
|
||||||
local expressions={}
|
local expressions={}
|
||||||
expressions.neutral={0,0}
|
expressions.neutral={0,0}
|
||||||
|
expressions["end"]=expressions.neutral
|
||||||
expressions.hurt={0,1}
|
expressions.hurt={0,1}
|
||||||
local expruvm=UVManager:new({8, 8}, nil, expressions)
|
local expruvm=UVManager:new({8, 8}, nil, expressions)
|
||||||
|
current_expression="neutral"
|
||||||
|
|
||||||
-- color/expression rules
|
-- color/expression rules
|
||||||
function getBestColor()
|
function getBestColor()
|
||||||
@ -714,28 +720,36 @@ do
|
|||||||
return "neutral"
|
return "neutral"
|
||||||
end
|
end
|
||||||
function setColor(col)
|
function setColor(col)
|
||||||
col=(col~=nil) and col or getBestColor()
|
if not lock_color then
|
||||||
for _, v in pairs(EMISSIVES) do
|
col=(col~=nil) and col or getBestColor()
|
||||||
v.setColor(col)
|
for _, v in pairs(EMISSIVES) do
|
||||||
|
v.setColor(col)
|
||||||
|
v.setShader("None")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Expression change code
|
-- Expression change code
|
||||||
function setExpression(expression)
|
function setExpression(expression)
|
||||||
FACE.setUV(expruvm:getUV(expression))
|
current_expression=expression
|
||||||
setColor(COLORS[expression])
|
FACE.setUV(expruvm:getUV(current_expression))
|
||||||
|
setColor(COLORS[current_expression])
|
||||||
end
|
end
|
||||||
function changeExpression(expression, ticks)
|
function changeExpression(expression, ticks)
|
||||||
setExpression(expression)
|
FACE.setUV(expruvm:getUV(expression))
|
||||||
|
setColor(COLORS[expression])
|
||||||
namedWait(ticks, resetExpression, "resetExpression")
|
namedWait(ticks, resetExpression, "resetExpression")
|
||||||
end
|
end
|
||||||
function resetExpression()
|
function resetExpression()
|
||||||
FACE.setUV(expruvm:getUV(getBestExpression()))
|
lock_color=false
|
||||||
|
FACE.setUV(expruvm:getUV(current_expression))
|
||||||
setColor(getBestColor())
|
setColor(getBestColor())
|
||||||
end
|
end
|
||||||
|
|
||||||
function hurt()
|
function hurt()
|
||||||
|
lock_color=false
|
||||||
changeExpression("hurt", 10)
|
changeExpression("hurt", 10)
|
||||||
|
lock_color=true
|
||||||
PartsManager.refreshPart(SHATTER)
|
PartsManager.refreshPart(SHATTER)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -756,6 +770,12 @@ action_wheel.SLOT_4.setFunction(function() ping.tPose() end)
|
|||||||
|
|
||||||
-- Pings --
|
-- Pings --
|
||||||
--- Damage function --
|
--- Damage function --
|
||||||
|
function ping.expr(expr)
|
||||||
|
local val=(expr==current_expression) and "neutral" or expr
|
||||||
|
setExpression(val)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function ping.oof(health) -- This is a replacement for onDamage, that function doesn't sync for some reason
|
function ping.oof(health) -- This is a replacement for onDamage, that function doesn't sync for some reason
|
||||||
hurt()
|
hurt()
|
||||||
end
|
end
|
||||||
@ -1026,8 +1046,9 @@ function hostTick()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function tick()
|
function tick()
|
||||||
|
if old_state.in_lava ~= player.isInLava() then
|
||||||
setColor()
|
setColor()
|
||||||
|
end
|
||||||
-- optimization, only execute these once a second --
|
-- optimization, only execute these once a second --
|
||||||
if world.getTimeOfDay() % 20 == 0 then
|
if world.getTimeOfDay() % 20 == 0 then
|
||||||
|
|
||||||
@ -1063,6 +1084,7 @@ function tick()
|
|||||||
|
|
||||||
-- End of tick --
|
-- End of tick --
|
||||||
old_state.health=player.getHealth()
|
old_state.health=player.getHealth()
|
||||||
|
old_state.in_lava=player.isInLava()
|
||||||
local_state.anim=player.getAnimation()
|
local_state.anim=player.getAnimation()
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user