Move the "boom barrier" to animated textures and make the last gate light stay on solid

This commit is contained in:
cheapie 2016-01-12 22:22:44 -06:00
parent 4a3a3f40be
commit 08a391e4cc
4 changed files with 483 additions and 445 deletions

View File

@ -1,5 +1,5 @@
-- Boom barrier
function move_arm(pos, node)
function move_arm(pos, node)
local node = minetest.env:get_node(pos)
local param2 = node.param2
@ -25,8 +25,10 @@
if dir == "x+" then
for i = 1, 10 do
pos.x = pos.x + 1
if (string.match(minetest.env:get_node(pos).name, "infrastructure:boom_barrier_arm_h_bright")
or string.match(minetest.env:get_node(pos).name, "infrastructure:boom_barrier_arm_h_dark")) == nil then
if (string.match(minetest.env:get_node(pos).name, "infrastructure:boom_barrier_arm_h_lightfirst")
or string.match(minetest.env:get_node(pos).name, "infrastructure:boom_barrier_arm_h_end")
or string.match(minetest.env:get_node(pos).name, "infrastructure:boom_barrier_arm_h_darkfirst")) == nil then
pos.x = pos.x - 1
break
end
minetest.env:remove_node(pos)
@ -36,8 +38,9 @@
elseif dir == "x-" then
for i = 1, 10 do
pos.x = pos.x - 1
if (string.match(minetest.env:get_node(pos).name, "infrastructure:boom_barrier_arm_h_bright")
or string.match(minetest.env:get_node(pos).name, "infrastructure:boom_barrier_arm_h_dark")) == nil then
if (string.match(minetest.env:get_node(pos).name, "infrastructure:boom_barrier_arm_h_lightfirst")
or string.match(minetest.env:get_node(pos).name, "infrastructure:boom_barrier_arm_h_end")
or string.match(minetest.env:get_node(pos).name, "infrastructure:boom_barrier_arm_h_darkfirst")) == nil then
break
end
minetest.env:remove_node(pos)
@ -47,8 +50,9 @@
elseif dir == "z+" then
for i = 1, 10 do
pos.z = pos.z + 1
if (string.match(minetest.env:get_node(pos).name, "infrastructure:boom_barrier_arm_h_bright")
or string.match(minetest.env:get_node(pos).name, "infrastructure:boom_barrier_arm_h_dark")) == nil then
if (string.match(minetest.env:get_node(pos).name, "infrastructure:boom_barrier_arm_h_lightfirst")
or string.match(minetest.env:get_node(pos).name, "infrastructure:boom_barrier_arm_h_end")
or string.match(minetest.env:get_node(pos).name, "infrastructure:boom_barrier_arm_h_darkfirst")) == nil then
break
end
minetest.env:remove_node(pos)
@ -58,8 +62,9 @@
elseif dir == "z-" then
for i = 1, 10 do
pos.z = pos.z - 1
if (string.match(minetest.env:get_node(pos).name, "infrastructure:boom_barrier_arm_h_bright")
or string.match(minetest.env:get_node(pos).name, "infrastructure:boom_barrier_arm_h_dark")) == nil then
if (string.match(minetest.env:get_node(pos).name, "infrastructure:boom_barrier_arm_h_lightfirst")
or string.match(minetest.env:get_node(pos).name, "infrastructure:boom_barrier_arm_h_end")
or string.match(minetest.env:get_node(pos).name, "infrastructure:boom_barrier_arm_h_darkfirst")) == nil then
break
end
minetest.env:remove_node(pos)
@ -78,9 +83,12 @@
end
minetest.env:remove_node(pos)
if i % 2 == 1 then
node.name = "infrastructure:boom_barrier_arm_h_bright"
node.name = "infrastructure:boom_barrier_arm_h_lightfirst"
else
node.name = "infrastructure:boom_barrier_arm_h_dark"
node.name = "infrastructure:boom_barrier_arm_h_darkfirst"
end
if minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}).name ~= "infrastructure:boom_barrier_arm_v" then
node.name = "infrastructure:boom_barrier_arm_h_end"
end
minetest.env:add_node({x=pos.x+i, y=pos.y-i, z=pos.z}, node)
end
@ -92,9 +100,12 @@
end
minetest.env:remove_node(pos)
if i % 2 == 1 then
node.name = "infrastructure:boom_barrier_arm_h_bright"
node.name = "infrastructure:boom_barrier_arm_h_lightfirst"
else
node.name = "infrastructure:boom_barrier_arm_h_dark"
node.name = "infrastructure:boom_barrier_arm_h_darkfirst"
end
if minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}).name ~= "infrastructure:boom_barrier_arm_v" then
node.name = "infrastructure:boom_barrier_arm_h_end"
end
minetest.env:add_node({x=pos.x-i, y=pos.y-i, z=pos.z}, node)
end
@ -106,9 +117,12 @@
end
minetest.env:remove_node(pos)
if i % 2 == 1 then
node.name = "infrastructure:boom_barrier_arm_h_bright"
node.name = "infrastructure:boom_barrier_arm_h_lightfirst"
else
node.name = "infrastructure:boom_barrier_arm_h_dark"
node.name = "infrastructure:boom_barrier_arm_h_darkfirst"
end
if minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}).name ~= "infrastructure:boom_barrier_arm_v" then
node.name = "infrastructure:boom_barrier_arm_h_end"
end
minetest.env:add_node({x=pos.x, y=pos.y-i, z=pos.z+i}, node)
end
@ -120,31 +134,20 @@
end
minetest.env:remove_node(pos)
if i % 2 == 1 then
node.name = "infrastructure:boom_barrier_arm_h_bright"
node.name = "infrastructure:boom_barrier_arm_h_lightfirst"
else
node.name = "infrastructure:boom_barrier_arm_h_dark"
node.name = "infrastructure:boom_barrier_arm_h_darkfirst"
end
if minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}).name ~= "infrastructure:boom_barrier_arm_v" then
node.name = "infrastructure:boom_barrier_arm_h_end"
end
minetest.env:add_node({x=pos.x, y=pos.y-i, z=pos.z-i}, node)
end
end
end
end
end
minetest.register_abm( {
nodenames = {"infrastructure:boom_barrier_arm_h_bright", "infrastructure:boom_barrier_arm_h_dark"},
interval = 1,
chance = 1,
action = function(pos, node)
local node = minetest.env:get_node(pos)
if node.name == "infrastructure:boom_barrier_arm_h_bright" then
minetest.swap_node(pos, {name = "infrastructure:boom_barrier_arm_h_dark", param2 = node.param2})
elseif node.name == "infrastructure:boom_barrier_arm_h_dark" then
minetest.swap_node(pos, {name = "infrastructure:boom_barrier_arm_h_bright", param2 = node.param2})
end
end
})
minetest.register_node("infrastructure:boom_barrier_top_h", {
minetest.register_node("infrastructure:boom_barrier_top_h", {
description = "Boom barrier mechanism",
tiles = {
"infrastructure_boom_barrier_h_top.png",
@ -225,9 +228,9 @@
on_punch = function(pos, node)
move_arm(pos, node)
end
})
})
minetest.register_node("infrastructure:boom_barrier_top_v", {
minetest.register_node("infrastructure:boom_barrier_top_v", {
tiles = {
"infrastructure_boom_barrier_h_front_back.png",
"infrastructure_boom_barrier_v_bottom.png",
@ -299,9 +302,9 @@
on_punch = function(pos, node)
move_arm(pos, node)
end
})
})
minetest.register_node("infrastructure:boom_barrier_bottom", {
minetest.register_node("infrastructure:boom_barrier_bottom", {
tiles = {
"infrastructure_traffic_lights_side.png",
"infrastructure_traffic_lights_side.png",
@ -367,15 +370,15 @@
end
}
},
})
})
minetest.register_node("infrastructure:boom_barrier_arm_h_bright", {
minetest.register_node("infrastructure:boom_barrier_arm_h_lightfirst", {
description = "Boom barrier arm",
tiles = {
"infrastructure_boom_barrier_arm_h_top.png",
"infrastructure_boom_barrier_arm_h_bottom_front_back.png",
"infrastructure_boom_barrier_arm_h_left_right_bright.png",
"infrastructure_boom_barrier_arm_h_left_right_bright.png",
{name="infrastructure_boom_barrier_arm_h_anim_lightfirst.png",animation={type="vertical_frames", aspect_w=64, aspect_h=64, length=1.5}},
{name="infrastructure_boom_barrier_arm_h_anim_lightfirst.png",animation={type="vertical_frames", aspect_w=64, aspect_h=64, length=1.5}},
"infrastructure_boom_barrier_arm_h_bottom_front_back.png",
"infrastructure_boom_barrier_arm_h_bottom_front_back.png"
},
@ -400,14 +403,14 @@
{-1/8, -1/2, -1/2, 1/8, -1/4, 1/2}
}
}
})
})
minetest.register_node("infrastructure:boom_barrier_arm_h_dark", {
minetest.register_node("infrastructure:boom_barrier_arm_h_darkfirst", {
tiles = {
"infrastructure_boom_barrier_arm_h_top.png",
"infrastructure_boom_barrier_arm_h_bottom_front_back.png",
"infrastructure_boom_barrier_arm_h_left_right_dark.png",
"infrastructure_boom_barrier_arm_h_left_right_dark.png",
{name="infrastructure_boom_barrier_arm_h_anim_darkfirst.png",animation={type="vertical_frames", aspect_w=64, aspect_h=64, length=1.5}},
{name="infrastructure_boom_barrier_arm_h_anim_darkfirst.png",animation={type="vertical_frames", aspect_w=64, aspect_h=64, length=1.5}},
"infrastructure_boom_barrier_arm_h_bottom_front_back.png",
"infrastructure_boom_barrier_arm_h_bottom_front_back.png"
},
@ -415,7 +418,7 @@
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky = 1},
drop = "infrastructure:boom_barrier_arm_h_bright",
drop = "infrastructure:boom_barrier_arm_h_lightfirst",
node_box = {
type = "fixed",
fixed = {
@ -432,9 +435,44 @@
{-1/8, -1/2, -1/2, 1/8, -1/4, 1/2}
}
}
})
})
minetest.register_node("infrastructure:boom_barrier_arm_v", {
minetest.register_node("infrastructure:boom_barrier_arm_h_end", {
tiles = {
"infrastructure_boom_barrier_arm_h_top.png",
"infrastructure_boom_barrier_arm_h_bottom_front_back.png",
"infrastructure_boom_barrier_arm_h_left_right_bright.png",
"infrastructure_boom_barrier_arm_h_left_right_bright.png",
"infrastructure_boom_barrier_arm_h_bottom_front_back.png",
"infrastructure_boom_barrier_arm_h_bottom_front_back.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky = 1},
drop = "infrastructure:boom_barrier_arm_h_lightfirst",
node_box = {
type = "fixed",
fixed = {
{-1/8, -1/2, -1/2, 1/8, -7/16, 1/2},
{-1/8, -5/16, -1/2, 1/8, -1/4, 1/2},
{-1/8, -1/2, -1/2, -1/16, -1/4, 1/2},
{1/16, -1/2, -1/2, 1/8, -1/4, 1/2},
{0, -1/4, -1/8, 0, 0, 1/8}
}
},
selection_box = {
type = "fixed",
fixed = {
{-1/8, -1/2, -1/2, 1/8, -1/4, 1/2}
}
}
})
minetest.register_alias("infrastructure:boom_barrier_arm_h_dark","infrastructure:boom_barrier_arm_h_darkfirst")
minetest.register_alias("infrastructure:boom_barrier_arm_h_bright","infrastructure:boom_barrier_arm_h_lightfirst")
minetest.register_node("infrastructure:boom_barrier_arm_v", {
tiles = {
"infrastructure_boom_barrier_arm_h_bottom_front_back.png",
"infrastructure_boom_barrier_arm_h_bottom_front_back.png",
@ -447,7 +485,7 @@
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky = 1},
drop = "infrastructure:boom_barrier_arm_h_bright",
drop = "infrastructure:boom_barrier_arm_h_lightfirst",
node_box = {
type = "fixed",
fixed = {
@ -464,7 +502,7 @@
{-1/8, -1/2, -1/2, 1/8, 1/2, -1/4}
}
}
})
})
minetest.register_alias("infrastructure:boom_barrier_mechanism", "infrastructure:boom_barrier_top_h")
minetest.register_alias("infrastructure:boom_barrier_arm", "infrastructure:boom_barrier_arm_h_bright")
minetest.register_alias("infrastructure:boom_barrier_mechanism", "infrastructure:boom_barrier_top_h")
minetest.register_alias("infrastructure:boom_barrier_arm", "infrastructure:boom_barrier_arm_h_lightfirst")

Binary file not shown.

After

Width:  |  Height:  |  Size: 762 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 811 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 481 B