Devtest: Fix testnodes bouncy color calculation

Values were out of range.
This commit is contained in:
Desour 2023-11-17 19:15:29 +01:00 committed by sfan5
parent 585e6aa80b
commit 7199ee4ff8
1 changed files with 4 additions and 4 deletions

View File

@ -428,17 +428,17 @@ local MAX_BOUNCE_NONJUMPY = 140
for i=-MAX_BOUNCE_NONJUMPY, MAX_BOUNCE_JUMPY, 20 do
if i ~= 0 then
local desc
local val = math.floor(((i-20)/200)*255)
local val2 = math.max(0, 200 - val)
local val = math.floor((math.abs(i) - 20) / 200 * 255)
local val2 = math.max(0, 255 - val)
local num = string.format("%03d", math.abs(i))
if i > 0 then
desc = S("Bouncy Node (@1%), jumpy", i).."\n"..
S("Sneaking/jumping affects bounce")
color = { r=255-val, g=255-val, b=255, a=255 }
color = { r=val2, g=val2, b=255, a=255 }
else
desc = S("Bouncy Node (@1%), non-jumpy", math.abs(i)).."\n"..
S("Sneaking/jumping does not affect bounce")
color = { r=val, g=255, b=val, a=255 }
color = { r=val2, g=255, b=val2, a=255 }
num = "NEG"..num
end
minetest.register_node("testnodes:bouncy"..num, {