1 -- CC0/Unlicense Emilia/cora 2020
6 -- north 5,1.5(3096:2.5,25025:1.5),z
7 --#local storage = minetest.get_mod_storage()
9 "mesecons_torch:redstoneblock"
13 "mcl_minecarts:golden_rail",
17 local tunnelmaterial
= {
18 'mcl_core:glass_light_blue',
21 'mcl_nether:netherrack',
26 --"mesecons_torch:redstoneblock"
29 local function is_rail(pos
)
31 if pos
.y
~= 1 then return false end
33 if pos
.x
== -5 then return "north" end
34 elseif pos
.z
< -5 then
35 if pos
.x
== 5 then return "south" end
38 if pos
.z
== 5 then return "east" end
39 elseif pos
.x
< -5 then
40 if pos
.z
== -5 then return "west" end
45 local function get_railnode(pos
)
47 return "mcl_minecarts:golden_rail"
49 if is_rail(vector
.add(pos
,{x
=0,y
=1,x
=0})) then
50 return "mesecons_torch:redstoneblock"
55 local function is_lantern(pos
)
58 if dir
== "north" or dir
== "south" then
59 if pos
.z
% 8 == 0 then
63 if pos
.x
% 8 == 0 then
70 ws
.rg('RailTool','Scaffold','railtool',function()
71 local poss
=ws
.get_reachable_positions(5)
72 for k
,p
in pairs(poss
) do
73 local n
=get_railnode(p
)
74 if n
then ws
.place(p
,n
) end
80 minetest
.register_cheat("RailT",'Bots','scaffold_railtunnel')
81 local function checknode(pos
)
82 local node
= minetest
.get_node_or_nil(pos
)
83 if node
and node
.name
~="mesecons_torch:redstoneblock" and not node
.name
:find("_rail") then return true end
86 local function dignodes(poss
)
87 for k
,v
in pairs(poss
) do
88 if checknode(v
) then ws
.dig(v
) end
91 local function blockliquids()
92 local lp
=ws
.lp
:get_pos()
93 local liquids
={'mcl_core:lava_source','mcl_core:water_source','mcl_core:lava_flowing','mcl_core:water_flowing'}
94 local bn
=minetest
.find_nodes_near(lp
, 1, liquids
, true)
95 for kk
,vv
in pairs(bn
) do
96 if vv
.y
> lp
.y
then scaffold
.place_if_needed(tunnelmaterial
,vv
) end
100 local function invcheck(item
)
101 if mintetest
.switch_to_item(item
) then return true end
102 refill
.refill_at(ws
.dircoord(1,1,0),'railkit')
105 local direction
="north"
107 ws
.rg("RailBot","Bots", "railbot", function()
108 local lp
= ws
.dircoord(0,0,0)
109 local below
= ws
.dircoord(0,-1,0)
115 ws
.dig(ws
.dircoord(i
,1,0))
116 if checknode(ws
.dircoord(i
,0,0)) then ws
.dig(ws
.dircoord(i
,0,0)) end
117 if checknode(ws
.dircoord(i
,-1,0)) then ws
.dig(ws
.dircoord(i
,-1,0)) end
118 scaffold
.place_if_needed(ground
, ws
.dircoord(i
,-1,0))
119 scaffold
.place_if_needed(rails
, ws
.dircoord(i
,0,0))
121 local lpn
=minetest
.get_node_or_nil(ws
.dircoord(i
,0,0))
122 local bln
=minetest
.get_node_or_nil(ws
.dircoord(i
,-1,0))
123 if not ( bln
and bln
.name
=="mesecons_torch:redstoneblock" and lpn
and lpn
.name
== "mcl_minecarts:golden_rail_on" ) then
126 local lpos
=ws
.dircoord(i
,2,0)
127 if is_lantern(lpos
) then
128 local ln
=minetest
.get_node_or_nil(lpos
)
129 if not ln
or ln
.name
~= 'mcl_ocean:sea_lantern' then
132 scaffold
.place_if_needed({'mcl_ocean:sea_lantern'}, lpos
)
137 if (goon
) then minetest
.settings
:set_bool('continuous_forward',true)
138 else minetest
.settings
:set_bool('continuous_forward',false) end
142 function()--startfunc
143 direction
=ws
.get_dir()
144 storage
:set_string('BOTDIR', direction
)
145 end,function() --stopfunc
147 storage
:set_string('BOTDIR',direction
)
148 end,{'afly_axissnap','continuous_forward','autorefill'}) --'scaffold_ltbm'
150 ws
.on_connect(function()
151 sdir
=storage
:get_string('BOTDIR')
155 minetest
.settings
:set_bool('railbot',false)
159 scaffold
.register_template_scaffold("LanternTBM", "scaffold_ltbm", function()
160 local dir
=ws
.getdir()
161 local lp
=vector
.round(ws
.dircoord(0,0,0))
162 local pl
=is_lantern(lp
)
164 local lpos
=ws
.dircoord(0,2,0)
165 local nd
=minetest
.get_node_or_nil(lpos
)
166 if nd
and nd
.name
~= 'mcl_ocean:sea_lantern' then
168 minetest
.after("0",function()
169 scaffold
.place_if_needed({'mcl_ocean:sea_lantern'}, lpos
)
170 ws
.place(lpos
,'mcl_ocean:sea_lantern')