scaffold:add TBM; turtle: add getdir()
parent
26c66e89be
commit
b0bad30dc5
|
@ -100,12 +100,14 @@ function scaffold.place_if_able(pos)
|
|||
end
|
||||
|
||||
function scaffold.dig(pos)
|
||||
local n = minetest.get_node_def(minetest.get_node_or_nil(pos).name)
|
||||
-- there's a diggable attrib i think
|
||||
local nd=minetest.get_node_or_nil(pos)
|
||||
if not nd then return false end
|
||||
local n = minetest.get_node_def(nd.name)
|
||||
if n and n.diggable then
|
||||
minetest.select_best_tool(n.name)
|
||||
minetest.select_best_tool(nd.name)
|
||||
return minetest.dig_node(pos)
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
|
@ -140,7 +142,41 @@ scaffold.register_template_scaffold("WaterSpam", "scaffold_spamwater", function(
|
|||
}, pos)
|
||||
--end
|
||||
end)
|
||||
local function checknode(pos)
|
||||
local node = minetest.get_node_or_nil(pos)
|
||||
if node then return true end
|
||||
return false
|
||||
end
|
||||
|
||||
if turtle then
|
||||
scaffold.register_template_scaffold("TBM", "scaffold_tbm", function(pos)
|
||||
scaffold.dig(turtle.dircoord(1,1,0))
|
||||
scaffold.dig(turtle.dircoord(1,0,0))
|
||||
end)
|
||||
|
||||
scaffold.register_template_scaffold("LanternTBM", "scaffold_ltbm", function(pos)
|
||||
--scaffold.dig(turtle.dircoord(1,1,0)) -- let lTBM just be additionally place lanterns mode - useful for rail too.
|
||||
--scaffold.dig(turtle.dircoord(1,0,0))
|
||||
local dir=turtle.getdir()
|
||||
local pl=false
|
||||
if dir == "north" or dir == "south" then
|
||||
if pos.z % 8 == 0 then
|
||||
pl=true
|
||||
end
|
||||
else
|
||||
if pos.x % 8 == 0 then
|
||||
pl=true
|
||||
end
|
||||
end
|
||||
if pl then
|
||||
local lpos=turtle.dircoord(0,2,0)
|
||||
local nd=minetest.get_node_or_nil(lpos)
|
||||
if nd and nd.name ~= 'mcl_ocean:sea_lantern' then
|
||||
scaffold.dig(lpos)
|
||||
minetest.after("0.1",function() scaffold.place_if_needed({'mcl_ocean:sea_lantern'},lpos) end)
|
||||
end
|
||||
end
|
||||
end)
|
||||
scaffold.register_template_scaffold("TriScaffold", "scaffold_three_wide", function(pos)
|
||||
scaffold.place_if_able(pos)
|
||||
scaffold.place_if_able(turtle.dircoord(0, -1, 1))
|
||||
|
|
|
@ -72,7 +72,7 @@ function turtle.relativize(c1, c2)
|
|||
local c2z = turtle.zeroidx(c2)
|
||||
|
||||
local rel = turtle.coord(c2z.x - c1z.x, c2z.y - c1z.y, c2z.z - c1z.z)
|
||||
|
||||
|
||||
return c1, rel
|
||||
end
|
||||
|
||||
|
@ -137,21 +137,33 @@ local function between(x, y, z) -- x is between y and z (inclusive)
|
|||
return y <= x and x <= z
|
||||
end
|
||||
|
||||
function turtle.dircoord(f, y, r)
|
||||
function turtle.getdir() --
|
||||
local rot = minetest.localplayer:get_yaw() % 360
|
||||
if between(rot, 315, 360) or between(rot, 0, 45) then
|
||||
return "north"
|
||||
elseif between(rot, 135, 225) then
|
||||
return "south"
|
||||
elseif between(rot, 225, 315) then
|
||||
return "east"
|
||||
elseif between(rot, 45, 135) then
|
||||
return "west"
|
||||
end
|
||||
end
|
||||
|
||||
function turtle.dircoord(f, y, r)
|
||||
local dir=turtle.getdir()
|
||||
local coord = turtle.optcoord(f, y, r)
|
||||
local f = coord.x
|
||||
local y = coord.y
|
||||
local r = coord.z
|
||||
|
||||
if between(rot, 315, 360) or between(rot, 0, 45) then -- north
|
||||
if dir == "north" then -- north
|
||||
return turtle.relcoord(r, y, f)
|
||||
elseif between(rot, 135, 225) then -- south
|
||||
elseif dir == "south" then -- south
|
||||
return turtle.relcoord(-r, y, -f)
|
||||
elseif between(rot, 225, 315) then -- east
|
||||
elseif dir == "east" then -- east
|
||||
return turtle.relcoord(f, y, -r)
|
||||
elseif between(rot, 45, 135) then -- west
|
||||
elseif dir== "west" then -- west
|
||||
return turtle.relcoord(-f, y, r)
|
||||
end
|
||||
return turtle.relcoord(0, 0, 0)
|
||||
|
|
Loading…
Reference in New Issue