fat xmas scaffold commit
This commit is contained in:
parent
00e605c0f9
commit
88c2c9449f
@ -4,6 +4,34 @@ local category = "Scaffold"
|
||||
|
||||
scaffold = {}
|
||||
scaffold.registered_scaffolds = {}
|
||||
scaffold.lockdir = false
|
||||
scaffold.locky = false
|
||||
local storage=minetest.get_mod_storage()
|
||||
|
||||
local wason = {}
|
||||
|
||||
|
||||
|
||||
|
||||
local function get_locks()
|
||||
scaffold.lockdir = storage:get_string('lockdir')
|
||||
scaffold.locky = storage:get_string('locky')
|
||||
if scaffold.lockdir or scaffold.locky then return true end
|
||||
return false
|
||||
end
|
||||
local function set_locks()
|
||||
storage:set_string('lockdir', scaffold.lockdir)
|
||||
storage:set_string('locky', scaffold.locky)
|
||||
end
|
||||
local function del_locks()
|
||||
storage:set_string('lockdir','')
|
||||
storage:set_string('locky','')
|
||||
end
|
||||
|
||||
if get_locks() then
|
||||
if scaffold.lockdir then wason.scaffold_lockyaw = true end
|
||||
if scaffold.locky then wason.scaffold_locky = true end
|
||||
end
|
||||
|
||||
function scaffold.register_scaffold(func)
|
||||
table.insert(scaffold.registered_scaffolds, func)
|
||||
@ -23,6 +51,9 @@ function scaffold.template(setting, func, offset)
|
||||
local lp = minetest.localplayer:get_pos()
|
||||
local tgt = vector.round(vector.add(lp, offset))
|
||||
func(tgt)
|
||||
if not wason[setting] then wason[setting] = true end
|
||||
elseif wason[setting] then
|
||||
wason[setting] = false
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -61,6 +92,7 @@ function scaffold.find_any_swap(items)
|
||||
end
|
||||
|
||||
function scaffold.in_list(val, list)
|
||||
if type(list) ~= "table" then return false end
|
||||
for i, v in ipairs(list) do
|
||||
if v == val then
|
||||
return true
|
||||
@ -118,6 +150,18 @@ dofile(mpath .. "/autofarm.lua")
|
||||
dofile(mpath .. "/railscaffold.lua")
|
||||
|
||||
|
||||
scaffold.register_template_scaffold("LockYaw", "scaffold_lockyaw", function(pos)
|
||||
if not wason.scaffold_lockyaw then scaffold.lockdir=turtle.getdir() end
|
||||
if scaffold.lockdir then turtle.setdir(scaffold.lockdir) end
|
||||
end)
|
||||
|
||||
scaffold.register_template_scaffold("LockY", "scaffold_locky", function(pos)
|
||||
local lp=minetest.localplayer:get_pos()
|
||||
if not wason.scaffold_locky then scaffold.locky = lp.y end
|
||||
if scaffold.locky and lp.y ~= scaffold.locky then
|
||||
minetest.localplayer:set_pos(vector.add(lp,{x=0,y=scaffold.locky,z=0}))
|
||||
end
|
||||
end)
|
||||
scaffold.register_template_scaffold("CheckScaffold", "scaffold_check", function(pos)
|
||||
scaffold.place_if_able(pos)
|
||||
end)
|
||||
@ -169,7 +213,7 @@ if turtle then
|
||||
end
|
||||
end
|
||||
if pl then
|
||||
local lpos=turtle.dircoord(0,2,0)
|
||||
local lpos=turtle.dircoord(0,3,0)
|
||||
local nd=minetest.get_node_or_nil(lpos)
|
||||
if nd and nd.name ~= 'mcl_ocean:sea_lantern' then
|
||||
scaffold.dig(lpos)
|
||||
@ -200,6 +244,7 @@ end
|
||||
|
||||
if nlist then
|
||||
scaffold.register_template_scaffold("RandomScaff", "scaffold_rnd", function(below)
|
||||
if true then return false end
|
||||
local n = minetest.get_node_or_nil(below)
|
||||
-- n == nil is ignore
|
||||
if n and not scaffold.in_list(n.name, nlist.get('randomscaffold')) then
|
||||
|
@ -10,12 +10,16 @@ local rails = {
|
||||
}
|
||||
|
||||
local tunnelmaterial = {
|
||||
'mcl_core:glass_light_blue',
|
||||
'mcl_core:cobble',
|
||||
'mcl_nether:netherrack',
|
||||
'mcl_core:dirt',
|
||||
'mcl_core:andesite',
|
||||
'mcl_core:diorite',
|
||||
'mcl_core:granite',
|
||||
'mcl_core:dirt'
|
||||
'mcl_core:granite'
|
||||
}
|
||||
|
||||
local setdir=false;
|
||||
minetest.register_cheat("RailT",'Scaffold','scaffold_railtunnel')
|
||||
local function checknode(pos)
|
||||
local node = minetest.get_node_or_nil(pos)
|
||||
@ -26,24 +30,46 @@ end
|
||||
scaffold.register_template_scaffold("RailScaffold", "scaffold_rails", function(below)
|
||||
local lp = vector.round(minetest.localplayer:get_pos())
|
||||
|
||||
local fpos1=turtle.dircoord(1,1,0)
|
||||
local fpos2=turtle.dircoord(1,0,0)
|
||||
local fpos3=turtle.dircoord(1,-1,0)
|
||||
local fpos1=turtle.dircoord(1,2,0)
|
||||
local fpos2=turtle.dircoord(1,1,0)
|
||||
local fpos3=turtle.dircoord(1,0,0)
|
||||
|
||||
local fpos4=turtle.dircoord(2,1,0)
|
||||
local fpos5=turtle.dircoord(2,0,0)
|
||||
local fpos6=turtle.dircoord(2,-1,0)
|
||||
|
||||
if checknode(fpos2) then scaffold.dig(fpos2) end
|
||||
if checknode(fpos3) then scaffold.dig(fpos3) end
|
||||
if checknode(fpos1) then scaffold.dig(fpos1) end
|
||||
if checknode(fpos3) then scaffold.dig(fpos3) end
|
||||
if checknode(fpos2) then scaffold.dig(fpos2) end
|
||||
|
||||
local lp=minetest.localplayer:get_pos()
|
||||
local pos1=vector.add(lp,{x=-2,y=0,z=-2})
|
||||
local pos2=vector.add(lp,{x=2,y=4,z=2})
|
||||
local liquids={'mcl_core:lava_source','mcl_core:water_source','mcl_core:lava_flowing','mcl_core:water_flowing'}
|
||||
local liquids={'mcl_core:lava_source','mcl_core:water_source'}
|
||||
|
||||
local bn,cnt=minetest.find_nodes_in_area(pos1,pos2,liquids,false)
|
||||
for kk,vv in pairs(bn) do
|
||||
minetest.switch_to_item("mcl_nether:netherrack")
|
||||
minetest.place_node(vv)
|
||||
end
|
||||
|
||||
minetest.after("0.1",function()
|
||||
if scaffold.place_if_needed(ground, below) then
|
||||
scaffold.place_if_needed(rails, lp)
|
||||
end
|
||||
local frpos=turtle.dircoord(1,1,0)
|
||||
local fgpos=turtle.dircoord(1,0,0)
|
||||
local it = core.find_item("mesecons_torch:redstoneblock")
|
||||
if not it then minetest.settings:set_bool('continuous_forward',false) end
|
||||
scaffold.place_if_needed(ground, below)
|
||||
scaffold.place_if_needed(rails, lp)
|
||||
scaffold.place_if_needed(ground, fgpos)
|
||||
scaffold.place_if_needed(rails, frpos)
|
||||
|
||||
end)
|
||||
if minetest.settings:get_bool('scaffold_railtunnel') then
|
||||
scaffold.place_if_needed(tunnelmaterial, turtle.dircoord(0,2,0))
|
||||
scaffold.place_if_needed(tunnelmaterial, turtle.dircoord(0,0,1))
|
||||
scaffold.place_if_needed(tunnelmaterial, turtle.dircoord(0,3,0))
|
||||
scaffold.place_if_needed(tunnelmaterial, turtle.dircoord(0,2,1))
|
||||
scaffold.place_if_needed(tunnelmaterial, turtle.dircoord(0,1,1))
|
||||
scaffold.place_if_needed(tunnelmaterial, turtle.dircoord(0,0,-1))
|
||||
scaffold.place_if_needed(tunnelmaterial, turtle.dircoord(0,2,-1))
|
||||
scaffold.place_if_needed(tunnelmaterial, turtle.dircoord(0,1,-1))
|
||||
end
|
||||
end)
|
||||
|
@ -130,6 +130,7 @@ end
|
||||
|
||||
function turtle.relcoord(x, y, z)
|
||||
local pos = minetest.localplayer:get_pos()
|
||||
if pos.y > -5000 then pos.y=pos.y-1 end
|
||||
return turtle.cadd(pos, turtle.optcoord(x, y, z))
|
||||
end
|
||||
|
||||
@ -149,6 +150,17 @@ function turtle.getdir() --
|
||||
return "west"
|
||||
end
|
||||
end
|
||||
function turtle.setdir(dir) --
|
||||
if dir == "north" then
|
||||
minetest.localplayer:set_yaw(0)
|
||||
elseif dir == "south" then
|
||||
minetest.localplayer:set_yaw(180)
|
||||
elseif dir == "east" then
|
||||
minetest.localplayer:set_yaw(270)
|
||||
elseif dir == "west" then
|
||||
minetest.localplayer:set_yaw(90)
|
||||
end
|
||||
end
|
||||
|
||||
function turtle.dircoord(f, y, r)
|
||||
local dir=turtle.getdir()
|
||||
@ -156,16 +168,17 @@ function turtle.dircoord(f, y, r)
|
||||
local f = coord.x
|
||||
local y = coord.y
|
||||
local r = coord.z
|
||||
|
||||
if dir == "north" then -- north
|
||||
local lp=minetest.localplayer:get_pos()
|
||||
if dir == "north" then
|
||||
return turtle.relcoord(r, y, f)
|
||||
elseif dir == "south" then -- south
|
||||
elseif dir == "south" then
|
||||
return turtle.relcoord(-r, y, -f)
|
||||
elseif dir == "east" then -- east
|
||||
elseif dir == "east" then
|
||||
return turtle.relcoord(f, y, -r)
|
||||
elseif dir== "west" then -- west
|
||||
elseif dir== "west" then
|
||||
return turtle.relcoord(-f, y, r)
|
||||
end
|
||||
|
||||
return turtle.relcoord(0, 0, 0)
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user