Compare commits

...

2 Commits

Author SHA1 Message Date
Pascal Abresch 9b30c79e04 simplified struts 2019-09-30 19:15:13 +02:00
Pascal Abresch 841dde100b added easier strut_line_dir functions 2019-09-30 18:24:12 +02:00
1 changed files with 50 additions and 37 deletions

View File

@ -36,6 +36,14 @@ local function marker_construct(pos, player)
on_marker_placed(pos, quarry_pos, player)
end
local function order(x, y)
if x <= y then
return x, y
else
return y,x
end
end
local function clear_area(pos, pos2)
local minx = pos.x
local maxx = pos2.x
@ -69,34 +77,38 @@ local function clear_area(pos, pos2)
end
end
local function struct_line(pos, pos2)
local minx = pos.x
local maxx = pos2.x
if pos2.x < pos.x then
minx = pos2.x
maxx = pos.x
local function place_strut(x, y, z)
local position = { x=x, y=y, z=z }
if minetest.get_node(position).name == "air" then
minetest.set_node(position, { name = NAME .. ":static_strut"})
end
local miny = pos.y
local maxy = pos2.y
if pos2.y < pos.y then
miny = pos2.y
maxy = pos.y
end
local function strut_line_x(x, y, z, x2)
local minx, maxx = order(x, x2)
minetest.debug(" x:" .. minx .. ":" .. maxx)
for x3=minx, maxx do
minetest.debug("x")
place_strut(x3, y, z)
end
local minz = pos.z
local maxz = pos2.z
if pos2.z < pos.z then
minz = pos2.z
maxz = pos.z
end
local function strut_line_y(x, y, z, y2)
local miny, maxy = order(y, y2)
minetest.debug(" y:" .. miny .. ":" .. maxy)
for y3=miny, maxy do
minetest.debug("y")
place_strut(x, y3, z)
end
for x=minx , maxx do
for y=miny, maxy do
for z=minz, maxz do
local p = {x=x, y=y, z=z}
if minetest.get_node(p).name == "air" then
minetest.set_node(p, {name = NAME .. ":static_strut"})
end
end
end
end
local function strut_line_z(x, y, z, z2)
local minz, maxz = order(z, z2)
minetest.debug(" z:" .. minz .. ":" .. maxz)
for z3=minz, maxz do
minetest.debug("z")
place_strut(x, y, z3)
end
end
@ -115,32 +127,33 @@ local function timer_trigger(pos, elapsed)
if framenum == 13 then -- stripmine area
clear_area(pos, marker_pos)
elseif framenum == 12 then
struct_line(pos, { x = marker_pos.x, y = pos.y, z = pos.z })
strut_line_x(pos.x, pos.y, pos.z, marker_pos.x)
elseif framenum == 11 then
struct_line(pos, { x = pos.x, y = marker_pos.y, z = pos.z })
strut_line_x(pos.x, marker_pos.y, pos.z, marker_pos.x)
elseif framenum == 10 then
struct_line( { x = pos.x, y = marker_pos.y, z = pos.z }, { x = pos.x, y = marker_pos.y, z = marker_pos.z })
strut_line_x(pos.x, pos.y, marker_pos.z, marker_pos.x)
elseif framenum == 9 then
struct_line( { x = pos.x, y = marker_pos.y, z = pos.z }, { x = marker_pos.x, y = marker_pos.y, z = pos.z })
strut_line_x(pos.x, marker_pos.y, marker_pos.z, marker_pos.x)
elseif framenum == 8 then
struct_line(pos, { x = pos.x, y = pos.y, z = marker_pos.z })
strut_line_z(pos.x, pos.y, pos.z, marker_pos.z)
elseif framenum == 7 then
struct_line( { x = marker_pos.x, y = pos.y, z = pos.z }, { x = marker_pos.x, y = pos.y, z = marker_pos.z })
strut_line_z(marker_pos.x, pos.y, pos.z, marker_pos.z)
elseif framenum == 6 then
struct_line( { x = marker_pos.x, y = marker_pos.y, z = pos.z }, { x = marker_pos.x, y = pos.y, z = pos.z })
strut_line_z(pos.x, marker_pos.y, pos.z, marker_pos.z)
elseif framenum == 5 then
struct_line( { x = marker_pos.x, y = marker_pos.y, z = pos.z }, marker_pos)
strut_line_z(marker_pos.x, marker_pos.y, pos.z, marker_pos.z)
elseif framenum == 4 then
struct_line( { x = pos.x, y = pos.y, z = marker_pos.z }, { x = marker_pos.x, y = pos.y, z = marker_pos.z })
strut_line_y(marker_pos.x, pos.y, marker_pos.z, marker_pos.y)
elseif framenum == 3 then
struct_line( { x = pos.x, y = pos.y, z = marker_pos.z }, { x = pos.x, y = marker_pos.y, z = marker_pos.z })
strut_line_y(pos.x, pos.y, marker_pos.z, marker_pos.y)
elseif framenum == 2 then
struct_line( { x = marker_pos.x, y = pos.y, z = marker_pos.z }, marker_pos)
strut_line_y(marker_pos.x, pos.y, pos.z, marker_pos.y)
elseif framenum == 1 then
struct_line( { x = pos.x, y = marker_pos.y, z = marker_pos.z }, marker_pos)
strut_line_y(pos.x, pos.y, pos.z, marker_pos.y)
elseif framenum == 0 then
--shrink the operational area here to a 2d space with one piece of border taken away to drill there
end
minetest.debug(framenum)
end
meta:set_int("current_frame", framenum -1)