1 -- CC0/Unlicense Emilia/cora 2020
4 "mesecons_torch:redstoneblock"
8 "mcl_minecarts:golden_rail",
12 local tunnelmaterial
= {
13 'mcl_core:glass_light_blue',
15 'mcl_nether:netherrack',
23 minetest
.register_cheat("RailT",'Scaffold','scaffold_railtunnel')
24 local function checknode(pos
)
25 local node
= minetest
.get_node_or_nil(pos
)
26 if node
and node
.name
~="mesecons_torch:redstoneblock" and not node
.name
:find("_rail") then return true end
30 scaffold
.register_template_scaffold("RailBot", "scaffold_rails", function(below
)
31 if not scaffold
.wason
.scaffold_rails
then
32 minetest
.settings
:set_bool('continuous_forward',true)
33 --minetest.settings:set_bool('scaffold_locky',true)
34 minetest
.settings
:set_bool('scaffold_lockyaw',true)
35 minetest
.settings
:set_bool('scaffold_ltbm',true)
37 local lp
= vector
.round(minetest
.localplayer
:get_pos())
39 local fpos1
=turtle
.dircoord(1,2,0)
40 local fpos2
=turtle
.dircoord(1,1,0)
41 local fpos3
=turtle
.dircoord(1,0,0)
43 local fpos4
=turtle
.dircoord(0,0,0)
45 if checknode(fpos1
) then scaffold
.dig(fpos1
) end
46 if checknode(fpos3
) then scaffold
.dig(fpos3
) end
47 if checknode(fpos2
) then scaffold
.dig(fpos2
) end
48 if checknode(fpos4
) then scaffold
.dig(fpos4
) end
50 local lp
=minetest
.localplayer
:get_pos()
51 local pos1
=vector
.add(lp
,{x
=-2,y
=0,z
=-2})
52 local pos2
=vector
.add(lp
,{x
=2,y
=4,z
=2})
53 local liquids
={'mcl_core:lava_source','mcl_core:water_source','mcl_core:lava_flowing','mcl_core:water_flowing'}
54 local liquids
={'mcl_core:lava_source','mcl_core:water_source'}
56 local bn
,cnt
=minetest
.find_nodes_in_area(pos1
,pos2
,liquids
,false)
57 for kk
,vv
in pairs(bn
) do
58 minetest
.switch_to_item("mcl_nether:netherrack")
59 minetest
.place_node(vv
)
61 local bln
=minetest
.get_node_or_nil(below
)
62 local lpn
=minetest
.get_node_or_nil(lp
)
64 if bln
and lpn
and lpn
.name
== "mcl_minecarts:golden_rail_on" then
65 --bln.name == "mesecons_torch:redstoneblock" and
66 --minetest.settings:set_bool('continuous_forward',true)
68 if lpn
.name
~= "air" and not lp
.name
:find('rail') then
71 minetest
.settings
:set_bool('continuous_forward',false)
74 minetest
.after("0.1",function()
75 local frpos
=turtle
.dircoord(1,1,0)
76 local fgpos
=turtle
.dircoord(1,0,0)
77 local it
= core
.find_item("mesecons_torch:redstoneblock")
78 if not it
then minetest
.settings
:set_bool('continuous_forward',false) end
79 scaffold
.place_if_needed(ground
, below
)
80 scaffold
.place_if_needed(rails
, lp
)
81 scaffold
.place_if_needed(ground
, fgpos
)
82 scaffold
.place_if_needed(rails
, frpos
)
85 if minetest
.settings
:get_bool('scaffold_railtunnel') then
86 scaffold
.place_if_needed(tunnelmaterial
, turtle
.dircoord(0,3,0))
87 scaffold
.place_if_needed(tunnelmaterial
, turtle
.dircoord(0,2,1))
88 scaffold
.place_if_needed(tunnelmaterial
, turtle
.dircoord(0,1,1))
89 scaffold
.place_if_needed(tunnelmaterial
, turtle
.dircoord(0,2,-1))
90 scaffold
.place_if_needed(tunnelmaterial
, turtle
.dircoord(0,1,-1))
93 minetest
.settings
:set_bool('continuous_forward',false)
94 minetest
.settings
:set_bool('scaffold_locky',false)
95 minetest
.settings
:set_bool('scaffold_lockyaw',false)
96 minetest
.settings
:set_bool('scaffold_ltbm',false)