move dragonfire legacy world code to scaffold mod
after another crash in the old df world mod finally move all the "old" world functions to scaffold and port them to use ws.rg instead of register_globalstep
This commit is contained in:
parent
987276fde6
commit
482514e57c
@ -1,8 +1,3 @@
|
|||||||
function sleep(s)
|
|
||||||
local ntime = os.clock() + s/10
|
|
||||||
repeat until os.clock() > ntime
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_chatcommand("findnodes", {
|
minetest.register_chatcommand("findnodes", {
|
||||||
description = "Scan for one or multible nodes in a radius around you",
|
description = "Scan for one or multible nodes in a radius around you",
|
||||||
param = "<radius> <node1>[,<node2>...]",
|
param = "<radius> <node1>[,<node2>...]",
|
||||||
@ -30,12 +25,6 @@ minetest.register_chatcommand("place", {
|
|||||||
return false, pos
|
return false, pos
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
minetest.register_chatcommand("screenshot", {
|
|
||||||
description = "asdf",
|
|
||||||
func = function()
|
|
||||||
minetest.take_screenshot()
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_chatcommand("dig", {
|
minetest.register_chatcommand("dig", {
|
||||||
params = "<X>,<Y>,<Z>",
|
params = "<X>,<Y>,<Z>",
|
||||||
@ -56,115 +45,4 @@ minetest.register_on_dignode(function(pos)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local etime = 0
|
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
|
||||||
etime = etime + dtime
|
|
||||||
if etime < 1 then return end
|
|
||||||
local player = minetest.localplayer
|
|
||||||
if not player then return end
|
|
||||||
local pos = player:get_pos()
|
|
||||||
local item = player:get_wielded_item()
|
|
||||||
local def = minetest.get_item_def(item:get_name())
|
|
||||||
local nodes_per_tick = tonumber(minetest.settings:get("nodes_per_tick")) or 8
|
|
||||||
if item:get_count() > 0 and def.node_placement_prediction ~= "" then
|
|
||||||
if minetest.settings:get_bool("scaffold") then
|
|
||||||
local p = vector.round(vector.add(pos, {x = 0, y = -0.6, z = 0}))
|
|
||||||
local node = minetest.get_node_or_nil(p)
|
|
||||||
if not node or minetest.get_node_def(node.name).buildable_to then
|
|
||||||
minetest.place_node(p)
|
|
||||||
end
|
|
||||||
elseif minetest.settings:get_bool("mscaffold") then
|
|
||||||
--local z = pos.z
|
|
||||||
local positions = {
|
|
||||||
{x = 0, y = -0.6, z = 0},
|
|
||||||
{x = 1, y = -0.6, z = 0},
|
|
||||||
{x = -1, y = -0.6, z = 0},
|
|
||||||
|
|
||||||
{x = -1, y = -0.6, z = -1},
|
|
||||||
{x = 0, y = -0.6, z = -1},
|
|
||||||
{x = 1, y = -0.6, z = -1},
|
|
||||||
|
|
||||||
{x = -1, y = -0.6, z = 1},
|
|
||||||
{x = 0, y = -0.6, z = 1},
|
|
||||||
{x = 1, y = -0.6, z = 1}
|
|
||||||
|
|
||||||
}
|
|
||||||
for i, p in pairs(positions) do
|
|
||||||
if i > nodes_per_tick then return end
|
|
||||||
minetest.place_node(vector.add(pos,p))
|
|
||||||
end
|
|
||||||
|
|
||||||
elseif minetest.settings:get_bool("highway_z") then
|
|
||||||
local z = pos.z
|
|
||||||
local positions = {
|
|
||||||
{x = 0, y = 0, z = z},
|
|
||||||
{x = 1, y = 0, z = z},
|
|
||||||
{x = 2, y = 1, z = z},
|
|
||||||
{x = -2, y = 1, z = z},
|
|
||||||
{x = -2, y = 0, z = z},
|
|
||||||
{x = -1, y = 0, z = z},
|
|
||||||
{x = 2, y = 0, z = z}
|
|
||||||
}
|
|
||||||
for i, p in pairs(positions) do
|
|
||||||
if i > nodes_per_tick then break end
|
|
||||||
minetest.place_node(p)
|
|
||||||
end
|
|
||||||
elseif minetest.settings:get_bool("block_water") then
|
|
||||||
local positions = minetest.find_nodes_near(pos, 5, {"mcl_core:water_source", "mcl_core:water_flowing"}, true)
|
|
||||||
for i, p in pairs(positions) do
|
|
||||||
if i > nodes_per_tick then return end
|
|
||||||
minetest.place_node(p)
|
|
||||||
end
|
|
||||||
elseif minetest.settings:get_bool("block_lava") then
|
|
||||||
local positions = minetest.find_nodes_near(pos, 5, {"mcl_core:lava_source", "mcl_core:lava_flowing"}, true)
|
|
||||||
for i, p in pairs(positions) do
|
|
||||||
if i > nodes_per_tick then return end
|
|
||||||
minetest.place_node(p)
|
|
||||||
end
|
|
||||||
elseif minetest.settings:get_bool("block_sources") then
|
|
||||||
local positions = minetest.find_nodes_near(pos, 5, {"mcl_core:lava_source","mcl_nether:nether_lava_source","mcl_core:water_source"}, true)
|
|
||||||
for i, p in pairs(positions) do
|
|
||||||
if p.y<2 then
|
|
||||||
if p.x>500 and p.z>500 then return end
|
|
||||||
end
|
|
||||||
|
|
||||||
if i > nodes_per_tick then return end
|
|
||||||
minetest.place_node(p)
|
|
||||||
end
|
|
||||||
elseif minetest.settings:get_bool("autotnt") then
|
|
||||||
local positions = minetest.find_nodes_near_under_air_except(pos, 5, item:get_name(), true)
|
|
||||||
for i, p in pairs(positions) do
|
|
||||||
if i > nodes_per_tick then break end
|
|
||||||
minetest.place_node(vector.add(p, {x = 0, y = 1, z = 0}))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if minetest.settings:get_bool("nuke") then
|
|
||||||
local i = 0
|
|
||||||
for x = pos.x - 4, pos.x + 4 do
|
|
||||||
for y = pos.y - 4, pos.y + 4 do
|
|
||||||
for z = pos.z - 4, pos.z + 4 do
|
|
||||||
local p = vector.new(x, y, z)
|
|
||||||
local node = minetest.get_node_or_nil(p)
|
|
||||||
local def = node and minetest.get_node_def(node.name)
|
|
||||||
if def and def.diggable then
|
|
||||||
if i > nodes_per_tick then return end
|
|
||||||
minetest.dig_node(p)
|
|
||||||
i = i + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
minetest.register_cheat("mScaffold", "World", "mscaffold")
|
|
||||||
minetest.register_cheat("Scaffold", "World", "scaffold")
|
|
||||||
minetest.register_cheat("HighwayZ", "World", "highway_z")
|
|
||||||
minetest.register_cheat("BlockWater", "World", "block_water")
|
|
||||||
minetest.register_cheat("BlockLava", "World", "block_lava")
|
|
||||||
minetest.register_cheat("BlockSrc", "World", "block_sources")
|
|
||||||
minetest.register_cheat("PlaceOnTop", "World", "autotnt")
|
|
||||||
minetest.register_cheat("Replace", "World", "replace")
|
minetest.register_cheat("Replace", "World", "replace")
|
||||||
minetest.register_cheat("Nuke", "World", "nuke")
|
|
||||||
|
@ -3,20 +3,25 @@
|
|||||||
local category = "Scaffold"
|
local category = "Scaffold"
|
||||||
|
|
||||||
scaffold = {}
|
scaffold = {}
|
||||||
scaffold.registered_scaffolds = {}
|
|
||||||
scaffold.lockdir = false
|
scaffold.lockdir = false
|
||||||
scaffold.locky = false
|
scaffold.locky = false
|
||||||
scaffold.constrain1 = false
|
scaffold.constrain1 = false
|
||||||
scaffold.constrain2 = false
|
scaffold.constrain2 = false
|
||||||
local hwps={}
|
local hwps={}
|
||||||
|
|
||||||
|
local multiscaff_width=5
|
||||||
|
local multiscaff_depth=1
|
||||||
|
local multiscaff_above=0
|
||||||
|
local multiscaff_mod=1
|
||||||
|
|
||||||
local storage=minetest.get_mod_storage()
|
local storage=minetest.get_mod_storage()
|
||||||
|
|
||||||
scaffold.wason = {}
|
|
||||||
|
|
||||||
local nextact = {}
|
local nodes_per_tick = 8
|
||||||
|
|
||||||
local towerbot_height = 75
|
local function setnpt()
|
||||||
|
nodes_per_tick = tonumber(minetest.settings:get("nodes_per_tick")) or 8
|
||||||
|
end
|
||||||
|
|
||||||
function scaffold.template(setting, func, offset, funcstop )
|
function scaffold.template(setting, func, offset, funcstop )
|
||||||
offset = offset or {x = 0, y = -1, z = 0}
|
offset = offset or {x = 0, y = -1, z = 0}
|
||||||
@ -216,138 +221,90 @@ dofile(mpath .. "/wallbot.lua")
|
|||||||
dofile(mpath .. "/ow2bot.lua")
|
dofile(mpath .. "/ow2bot.lua")
|
||||||
dofile(mpath .. "/atower.lua")
|
dofile(mpath .. "/atower.lua")
|
||||||
--dofile(mpath .. "/squarry.lua")
|
--dofile(mpath .. "/squarry.lua")
|
||||||
local snapdir="north"
|
|
||||||
ws.rg('DigHead','Player','dighead',function() ws.dig(ws.dircoord(0,1,0)) end)
|
ws.rg('DigHead','Player','dighead',function() ws.dig(ws.dircoord(0,1,0)) end)
|
||||||
ws.rg('SnapYaw','Bots','snapyaw',function() ws.setdir(snapdir) end,function() snapdir=ws.getdir() end)
|
|
||||||
|
|
||||||
|
|
||||||
scaffold.register_template_scaffold("Constrain", "scaffold_constrain", function()end,false,function() scaffold.reset() end)
|
|
||||||
|
|
||||||
ws.rg("LockYaw","Scaffold", "scaffold_lockyaw", function(pos)
|
|
||||||
if minetest.settings:get_bool("freecam") then return end
|
|
||||||
local y=minetest.localplayer:get_yaw()
|
|
||||||
local yy=nil
|
|
||||||
if ( y < 45 or y > 315 ) then
|
|
||||||
yy=0
|
|
||||||
elseif (y < 135) then
|
|
||||||
yy=90
|
|
||||||
elseif (y < 225 ) then
|
|
||||||
yy=180
|
|
||||||
elseif ( y < 315 ) then
|
|
||||||
yy=270
|
|
||||||
end
|
|
||||||
if yy ~= nil then
|
|
||||||
minetest.localplayer:set_yaw(yy)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
|
|
||||||
scaffold.register_template_scaffold("CheckScaffold", "scaffold_check", function(pos)
|
|
||||||
scaffold.place_if_able(pos)
|
|
||||||
end)
|
|
||||||
|
|
||||||
scaffold.register_template_scaffold("HereScaffold", "scaffold_here", function(pos)
|
|
||||||
scaffold.place_if_able(pos)
|
|
||||||
end, {x = 0, y = 0, z = 0})
|
|
||||||
|
|
||||||
scaffold.register_template_scaffold("WaterScaffold", "scaffold_water", function(pos)
|
|
||||||
if (pos.x % 2 + pos.z % 2) == 0 then
|
|
||||||
scaffold.place_if_needed({
|
|
||||||
"mcl_buckets:bucket_water",
|
|
||||||
"mcl_core:water_source"
|
|
||||||
}, pos)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
scaffold.register_template_scaffold("WaterSpam", "scaffold_spamwater", function()
|
|
||||||
ws.do_area(3,function(pos)
|
|
||||||
scaffold.place_if_needed({
|
|
||||||
"mcl_buckets:bucket_water",
|
|
||||||
"mcl_core:water_source"
|
|
||||||
}, pos)
|
|
||||||
end,true)
|
|
||||||
|
|
||||||
end)
|
|
||||||
local function checknode(pos)
|
local function checknode(pos)
|
||||||
local node = minetest.get_node_or_nil(pos)
|
local node = minetest.get_node_or_nil(pos)
|
||||||
if node then return true end
|
if node then return true end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
scaffold.register_template_scaffold("TBM", "scaffold_tbm", function(pos)
|
minetest.register_chatcommand('scaffw', {
|
||||||
scaffold.dig(ws.dircoord(1,1,0))
|
func = function(param) multiscaff_width=tonumber(param) end
|
||||||
scaffold.dig(ws.dircoord(1,0,0))
|
})
|
||||||
end)
|
minetest.register_chatcommand('scaffd', {
|
||||||
scaffold.register_template_scaffold("TallTBM", "scaffold_ttbm", function(pos)
|
func = function(param) multiscaff_depth=tonumber(param) end
|
||||||
pos = {
|
})
|
||||||
|
minetest.register_chatcommand('scaffa', {
|
||||||
|
func = function(param) multiscaff_above=tonumber(param) end
|
||||||
|
})
|
||||||
|
minetest.register_chatcommand('scaffm', {
|
||||||
|
func = function(param) multiscaff_mod=tonumber(param) end
|
||||||
|
})
|
||||||
|
|
||||||
ws.dircoord(1,4,2),
|
local multiscaff_node=nil
|
||||||
ws.dircoord(1,3,2),
|
ws.rg('MultiScaff','Scaffold','scaffold',function()
|
||||||
ws.dircoord(1,2,2),
|
if not multiscaff_node then return end
|
||||||
ws.dircoord(1,1,2),
|
local n=math.floor(multiscaff_width/2)
|
||||||
ws.dircoord(1,0,2),
|
for i=-n,n do
|
||||||
|
for j=(multiscaff_depth * -1), -1 do
|
||||||
ws.dircoord(1,4,-2),
|
local p=ws.dircoord(0,j,i)
|
||||||
ws.dircoord(1,3,-2),
|
local nd=minetest.get_node_or_nil(p)
|
||||||
ws.dircoord(1,2,-2),
|
ws.place(p,{multiscaff_node})
|
||||||
ws.dircoord(1,1,-2),
|
|
||||||
ws.dircoord(1,0,-2),
|
|
||||||
|
|
||||||
|
|
||||||
ws.dircoord(1,4,1),
|
|
||||||
ws.dircoord(1,3,1),
|
|
||||||
ws.dircoord(1,2,1),
|
|
||||||
ws.dircoord(1,1,1),
|
|
||||||
ws.dircoord(1,0,1),
|
|
||||||
|
|
||||||
ws.dircoord(1,4,-1),
|
|
||||||
ws.dircoord(1,3,-1),
|
|
||||||
ws.dircoord(1,2,-1),
|
|
||||||
ws.dircoord(1,1,-1),
|
|
||||||
ws.dircoord(1,0,-1),
|
|
||||||
|
|
||||||
ws.dircoord(1,4,0),
|
|
||||||
ws.dircoord(1,3,0),
|
|
||||||
ws.dircoord(1,2,0),
|
|
||||||
ws.dircoord(1,1,0),
|
|
||||||
ws.dircoord(1,0,0)
|
|
||||||
}
|
|
||||||
ws.dignodes(pos)
|
|
||||||
|
|
||||||
minetest.settings:set_bool('continuous_forward',true)
|
|
||||||
for k,v in pairs(pos) do
|
|
||||||
local n=minetest.get_node_or_nil(v)
|
|
||||||
if not n or n.name ~= "air" then
|
|
||||||
minetest.settings:set_bool('continuous_forward',false)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end,function()
|
||||||
|
multiscaff_node=minetest.localplayer:get_wielded_item():get_name()
|
||||||
|
ws.dcm("Multiscaff started. Width: "..multiscaff_width..', depth:'..multiscaff_depth..' Selected node: '..multiscaff_node)
|
||||||
|
end,function()
|
||||||
|
ws.dcm("Multiscaff stopped")
|
||||||
|
end)
|
||||||
|
|
||||||
|
ws.rg('MScaffModulo','Scaffold','multiscaffm',function()
|
||||||
|
if not multiscaff_node then return end
|
||||||
|
ws.switch_to_item(multiscaff_node)
|
||||||
|
local n=math.floor(multiscaff_width/2)
|
||||||
|
for i=-n,n do
|
||||||
|
for j=(multiscaff_depth * -1), -1 do
|
||||||
|
local p=vector.round(ws.dircoord(0,j,i))
|
||||||
|
if p.z % multiscaff_mod == 0 then
|
||||||
|
if p.x % multiscaff_mod ~=0 then
|
||||||
|
core.place_node(p)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if p.x % multiscaff_mod == 0 then
|
||||||
|
core.place_node(p)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,function()
|
||||||
|
multiscaff_node=minetest.localplayer:get_wielded_item():get_name()
|
||||||
|
ws.dcm("ModuloScaff started. Width: "..multiscaff_width..', depth:'..multiscaff_depth..' Selected node: '..multiscaff_node)
|
||||||
|
end,function()
|
||||||
|
ws.dcm("Moduloscaff stopped")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
scaffold.register_template_scaffold("WallScaffold", "scaffold_five_down", function(pos)
|
||||||
scaffold.register_template_scaffold("TriScaffold", "scaffold_three_wide", function(pos)
|
scaffold.place_if_able(ws.dircoord(0, -1, 0))
|
||||||
scaffold.place_if_able(pos)
|
scaffold.place_if_able(ws.dircoord(0, -2, 0))
|
||||||
scaffold.place_if_able(ws.dircoord(0, -1, 1))
|
scaffold.place_if_able(ws.dircoord(0, -3, 0))
|
||||||
scaffold.place_if_able(ws.dircoord(0, -1, -1))
|
scaffold.place_if_able(ws.dircoord(0, -4, 0))
|
||||||
|
scaffold.place_if_able(ws.dircoord(0, -5, 0))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
scaffold.register_template_scaffold("headTriScaff", "scaffold_three_wide_head", function(pos)
|
scaffold.register_template_scaffold("headTriScaff", "scaffold_three_wide_head", function(pos)
|
||||||
scaffold.place_if_able(ws.dircoord(0, 3, 0))
|
scaffold.place_if_able(ws.dircoord(0, 3, 0))
|
||||||
scaffold.place_if_able(ws.dircoord(0, 3, 1))
|
scaffold.place_if_able(ws.dircoord(0, 3, 1))
|
||||||
scaffold.place_if_able(ws.dircoord(0, 3, -1))
|
scaffold.place_if_able(ws.dircoord(0, 3, -1))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
scaffold.register_template_scaffold("QuintScaffold", "scaffold_five_wide", function(pos)
|
scaffold.register_template_scaffold("RandomScaff", "scaffold_rnd", function(below)
|
||||||
scaffold.place_if_able(pos)
|
|
||||||
scaffold.place_if_able(ws.dircoord(0, -1, 1))
|
|
||||||
scaffold.place_if_able(ws.dircoord(0, -1, -1))
|
|
||||||
scaffold.place_if_able(ws.dircoord(0, -1, 2))
|
|
||||||
scaffold.place_if_able(ws.dircoord(0, -1, -2))
|
|
||||||
end)
|
|
||||||
|
|
||||||
|
|
||||||
if nlist then
|
|
||||||
scaffold.register_template_scaffold("RandomScaff", "scaffold_rnd", function(below)
|
|
||||||
local n = minetest.get_node_or_nil(below)
|
local n = minetest.get_node_or_nil(below)
|
||||||
local nl=nlist.get('randomscaffold')
|
local nl=nlist.get('randomscaffold')
|
||||||
table.shuffle(nl)
|
table.shuffle(nl)
|
||||||
@ -355,5 +312,76 @@ if nlist then
|
|||||||
scaffold.dig(below)
|
scaffold.dig(below)
|
||||||
scaffold.place_if_needed(nl, below)
|
scaffold.place_if_needed(nl, below)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
|
||||||
|
|
||||||
|
ws.rg("HighwayZ","World","highwayz",function()
|
||||||
|
local positions = {
|
||||||
|
{x = 0, y = 0, z = z},
|
||||||
|
{x = 1, y = 0, z = z},
|
||||||
|
{x = 2, y = 1, z = z},
|
||||||
|
{x = -2, y = 1, z = z},
|
||||||
|
{x = -2, y = 0, z = z},
|
||||||
|
{x = -1, y = 0, z = z},
|
||||||
|
{x = 2, y = 0, z = z}
|
||||||
|
}
|
||||||
|
for i, p in pairs(positions) do
|
||||||
|
if i > nodes_per_tick then break end
|
||||||
|
minetest.place_node(p)
|
||||||
|
end
|
||||||
|
|
||||||
|
end, setnpt)
|
||||||
|
|
||||||
|
ws.rg("BlockWater","World","block_water",function()
|
||||||
|
local positions = minetest.find_nodes_near(pos, 5, {"mcl_core:water_source", "mcl_core:water_flowing"}, true)
|
||||||
|
for i, p in pairs(positions) do
|
||||||
|
if i > nodes_per_tick then return end
|
||||||
|
minetest.place_node(p)
|
||||||
|
end
|
||||||
|
end,setnpt)
|
||||||
|
|
||||||
|
ws.rg("BlockLava","World","block_lava",function()
|
||||||
|
local positions = minetest.find_nodes_near(pos, 5, {"mcl_core:lava_source", "mcl_core:lava_flowing"}, true)
|
||||||
|
for i, p in pairs(positions) do
|
||||||
|
if i > nodes_per_tick then return end
|
||||||
|
minetest.place_node(p)
|
||||||
|
end
|
||||||
|
end,setnpt)
|
||||||
|
|
||||||
|
ws.rg("BlockSources","World","block_sources",function()
|
||||||
|
local positions = minetest.find_nodes_near(pos, 5, {"mcl_core:lava_source","mcl_nether:nether_lava_source","mcl_core:water_source"}, true)
|
||||||
|
for i, p in pairs(positions) do
|
||||||
|
if p.y<2 then
|
||||||
|
if p.x>500 and p.z>500 then return end
|
||||||
|
end
|
||||||
|
|
||||||
|
if i > nodes_per_tick then return end
|
||||||
|
minetest.place_node(p)
|
||||||
|
end
|
||||||
|
end,setnpt)
|
||||||
|
|
||||||
|
ws.rg("PlaceOnTop","World","place_on_top",function()
|
||||||
|
local positions = minetest.find_nodes_near_under_air_except(pos, 5, item:get_name(), true)
|
||||||
|
for i, p in pairs(positions) do
|
||||||
|
if i > nodes_per_tick then break end
|
||||||
|
minetest.place_node(vector.add(p, {x = 0, y = 1, z = 0}))
|
||||||
|
end
|
||||||
|
end,setnpt)
|
||||||
|
|
||||||
|
ws.rg("Nuke","World","nuke",function()
|
||||||
|
local i = 0
|
||||||
|
for x = pos.x - 4, pos.x + 4 do
|
||||||
|
for y = pos.y - 4, pos.y + 4 do
|
||||||
|
for z = pos.z - 4, pos.z + 4 do
|
||||||
|
local p = vector.new(x, y, z)
|
||||||
|
local node = minetest.get_node_or_nil(p)
|
||||||
|
local def = node and minetest.get_node_def(node.name)
|
||||||
|
if def and def.diggable then
|
||||||
|
if i > nodes_per_tick then return end
|
||||||
|
minetest.dig_node(p)
|
||||||
|
i = i + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,setnpt)
|
@ -4,7 +4,7 @@
|
|||||||
--west:-x,1.5,-5
|
--west:-x,1.5,-5
|
||||||
--east:-x,1.5,5
|
--east:-x,1.5,5
|
||||||
-- north 5,1.5(3096:2.5,25025:1.5),z
|
-- north 5,1.5(3096:2.5,25025:1.5),z
|
||||||
--#local storage = minetest.get_mod_storage()
|
local direction = ""
|
||||||
local ground = {
|
local ground = {
|
||||||
"mesecons_torch:redstoneblock"
|
"mesecons_torch:redstoneblock"
|
||||||
}
|
}
|
||||||
@ -46,7 +46,7 @@ local function get_railnode(pos)
|
|||||||
if is_rail(pos) then
|
if is_rail(pos) then
|
||||||
return "mcl_minecarts:golden_rail"
|
return "mcl_minecarts:golden_rail"
|
||||||
end
|
end
|
||||||
if is_rail(vector.add(pos,{x=0,y=1,x=0})) then
|
if is_rail(vector.add(pos,{x=0,y=-1,x=0})) then
|
||||||
return "mesecons_torch:redstoneblock"
|
return "mesecons_torch:redstoneblock"
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
@ -67,34 +67,72 @@ local function is_lantern(pos)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
ws.rg('RailTool','Scaffold','railtool',function()
|
|
||||||
local poss=ws.get_reachable_positions(5)
|
|
||||||
for k,p in pairs(poss) do
|
|
||||||
local n=get_railnode(p)
|
|
||||||
if n then ws.place(p,n) end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_cheat("RailT",'Bots','scaffold_railtunnel')
|
|
||||||
local function checknode(pos)
|
local function checknode(pos)
|
||||||
|
local lp = ws.dircoord(0,0,0)
|
||||||
local node = minetest.get_node_or_nil(pos)
|
local node = minetest.get_node_or_nil(pos)
|
||||||
if node and node.name ~="mesecons_torch:redstoneblock" and not node.name:find("_rail") then return true end
|
if pos.y == lp.y then
|
||||||
|
if node and not node.name:find("_rail") then return true end
|
||||||
|
elseif node and node.name ~="mesecons_torch:redstoneblock" then return true
|
||||||
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local function dignodes(poss)
|
local function dignodes(poss)
|
||||||
for k,v in pairs(poss) do
|
for k,v in pairs(poss) do
|
||||||
if checknode(v) then ws.dig(v) end
|
if checknode(v) then ws.dig(v) end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local function blockliquids()
|
|
||||||
local lp=ws.lp:get_pos()
|
local function findliquids(pos,range)
|
||||||
local liquids={'mcl_core:lava_source','mcl_core:water_source','mcl_core:lava_flowing','mcl_core:water_flowing'}
|
range = range or 1
|
||||||
local bn=minetest.find_nodes_near(lp, 1, liquids, true)
|
if not pos then return end
|
||||||
|
local liquids={'mcl_core:lava_source','mcl_core:water_source','mcl_core:lava_flowing','mcl_core:water_flowing','mcl_nether:nether_lava_source','mcl_nether:nether_lava_flowing'}
|
||||||
|
local bn=minetest.find_nodes_near(pos, range, liquids, true)
|
||||||
|
if #bn < 0 then return bn end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local function blockliquids(pos)
|
||||||
|
if not pos then return end
|
||||||
|
local lp=ws.dircoord(0,0,0)
|
||||||
|
local liquids={'mcl_core:lava_source','mcl_core:water_source','mcl_core:lava_flowing','mcl_core:water_flowing','mcl_nether:nether_lava_source','mcl_nether:nether_lava_flowing'}
|
||||||
|
local bn=minetest.find_nodes_near(pos, 1, liquids, true)
|
||||||
|
local rt=false
|
||||||
|
if not bn then return rt end
|
||||||
for kk,vv in pairs(bn) do
|
for kk,vv in pairs(bn) do
|
||||||
if vv.y > lp.y then scaffold.place_if_needed(tunnelmaterial,vv) end
|
if vv.y > lp.y - 1 or vv.y < -40 then
|
||||||
|
rt=true
|
||||||
|
scaffold.place_if_needed(tunnelmaterial,vv)
|
||||||
|
for i=-4,5,1 do
|
||||||
|
local tpos=vector.new(pos.x,lp.y,pos.z)
|
||||||
|
scaffold.place_if_needed(tunnelmaterial,ws.dircoord(i,2,0,tpos))
|
||||||
|
scaffold.place_if_needed(tunnelmaterial,ws.dircoord(i,0,1,tpos))
|
||||||
|
scaffold.place_if_needed(tunnelmaterial,ws.dircoord(i,1,1,tpos))
|
||||||
|
scaffold.place_if_needed(tunnelmaterial,ws.dircoord(i,0,-1,tpos))
|
||||||
|
scaffold.place_if_needed(tunnelmaterial,ws.dircoord(i,1,-1,tpos))
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return rt
|
||||||
|
end
|
||||||
|
|
||||||
|
local function digob(sc)
|
||||||
|
local obpos={
|
||||||
|
ws.dircoord(0,1,2,sc),
|
||||||
|
ws.dircoord(0,1,-2,sc),
|
||||||
|
ws.dircoord(0,1,1,sc),
|
||||||
|
ws.dircoord(0,1,-1,sc),
|
||||||
|
ws.dircoord(0,0,1,sc),
|
||||||
|
ws.dircoord(0,0,-1,sc)
|
||||||
|
}
|
||||||
|
ws.dignodes(obpos,function(pos)
|
||||||
|
local nd=minetest.get_node_or_nil(pos)
|
||||||
|
if nd and (nd.name == "mcl_core:obsidian" or nd.name == "mcl_minecarts:golden_rail_on" or nd.name == "mcl_minecarts:golden_rail" )then return true end
|
||||||
|
return false
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function invcheck(item)
|
local function invcheck(item)
|
||||||
@ -102,59 +140,164 @@ local function invcheck(item)
|
|||||||
refill.refill_at(ws.dircoord(1,1,0),'railkit')
|
refill.refill_at(ws.dircoord(1,1,0),'railkit')
|
||||||
end
|
end
|
||||||
|
|
||||||
local direction="north"
|
local function invcheck(item)
|
||||||
|
if mintetest.switch_to_item(item) then return true end
|
||||||
|
refill.refill_at(ws.dircoord(1,1,0),'railkit')
|
||||||
|
end
|
||||||
|
local function rnd(n)
|
||||||
|
return math.ceil(n)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function fmt(c)
|
||||||
|
return tostring(rnd(c.x))..","..tostring(rnd(c.y))..","..tostring(rnd(c.z))
|
||||||
|
end
|
||||||
|
local function map_pos(value)
|
||||||
|
if value.x then
|
||||||
|
return value
|
||||||
|
else
|
||||||
|
return {x = value[1], y = value[2], z = value[3]}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function invparse(location)
|
||||||
|
if type(location) == "string" then
|
||||||
|
if string.match(location, "^[-]?[0-9]+,[-]?[0-9]+,[-]?[0-9]+$") then
|
||||||
|
return "nodemeta:" .. location
|
||||||
|
else
|
||||||
|
return location
|
||||||
|
end
|
||||||
|
elseif type(location) == "table" then
|
||||||
|
return "nodemeta:" .. fmt(map_pos(location))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function take_railkit(pos)
|
||||||
|
local plinv = minetest.get_inventory(invparse(pos))
|
||||||
|
local epos=ws.find_named(plinv,'railkit')
|
||||||
|
local mv = InventoryAction("move")
|
||||||
|
mv:from(invparse(pos), "main", epos)
|
||||||
|
mv:to("current_player", "main", 8)
|
||||||
|
mv:apply()
|
||||||
|
minetest.localplayer:set_wield_index(8)
|
||||||
|
return true
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
local restashing=false
|
||||||
|
function scaffold.restash()
|
||||||
|
if restashing then return end
|
||||||
|
restashing=true
|
||||||
|
ws.dig(ws.dircoord(1,0,1))
|
||||||
|
ws.dig(ws.dircoord(1,1,1))
|
||||||
|
ws.dig(ws.dircoord(2,0,1))
|
||||||
|
ws.dig(ws.dircoord(2,1,1))
|
||||||
|
|
||||||
|
ws.place(ws.dircoord(1,0,1),{'mcl_chests:chest_small','mcl_chests:chest'})
|
||||||
|
ws.place(ws.dircoord(1,1,1),{'railroad'})
|
||||||
|
take_railkit(ws.dircoord(1,1,1))
|
||||||
|
minetest.after("0.5",function()
|
||||||
|
ws.place(ws.dircoord(2,0,1),{'railkit'})
|
||||||
|
ws.dig(ws.dircoord(1,1,1))
|
||||||
|
end)
|
||||||
|
minetest.after("1.0",function()
|
||||||
|
autodupe.invtake(ws.dircoord(2,0,1))
|
||||||
|
restashing=false
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function slowdown(s)
|
||||||
|
minetest.localplayer:set_velocity(vector.new(0,0,0))
|
||||||
|
minetest.settings:set('movement_speed_fast',math.abs(s))
|
||||||
|
end
|
||||||
|
local fullspeed=100
|
||||||
|
local function speedup()
|
||||||
|
minetest.settings:set('movement_speed_fast',fullspeed)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
ws.rg("RailBot","Bots", "railbot", function()
|
ws.rg("RailBot","Bots", "railbot", function()
|
||||||
local lp = ws.dircoord(0,0,0)
|
local oldi=500
|
||||||
local below = ws.dircoord(0,-1,0)
|
for i=-50,50,1 do
|
||||||
blockliquids()
|
local lpos=ws.dircoord(i,2,0)
|
||||||
|
local lpn=minetest.get_node_or_nil(ws.dircoord(i,0,0))
|
||||||
|
local bln=minetest.get_node_or_nil(ws.dircoord(i,-1,0))
|
||||||
|
local ltpn=minetest.get_node_or_nil(lpos)
|
||||||
|
if not bln or not lpn or not ltpn then
|
||||||
|
speedup()
|
||||||
|
elseif ( is_lantern(lpos) and ltpn.name ~= lightblock ) then
|
||||||
|
if (oldi > i) then
|
||||||
|
slowdown(8)
|
||||||
|
oldi=i
|
||||||
|
end
|
||||||
|
elseif bln.name=="mesecons_torch:redstoneblock" and lpn.name == "mcl_minecarts:golden_rail_on" then
|
||||||
|
speedup()
|
||||||
|
else
|
||||||
|
if (oldi > i) then
|
||||||
|
slowdown(8)
|
||||||
|
oldi=i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local goon=true
|
local goon=false
|
||||||
for i=-4,4,1 do
|
for i=-4,4,1 do
|
||||||
|
local lpos=ws.dircoord(i,2,0)
|
||||||
|
local lpn=minetest.get_node_or_nil(ws.dircoord(i,0,0))
|
||||||
|
local bln=minetest.get_node_or_nil(ws.dircoord(i,-1,0))
|
||||||
|
local lpos=ws.dircoord(i,2,0)
|
||||||
|
|
||||||
|
if not ( bln and bln.name=="mesecons_torch:redstoneblock" and lpn and lpn.name == "mcl_minecarts:golden_rail_on" ) then
|
||||||
|
goon=false
|
||||||
|
else
|
||||||
|
goon=true
|
||||||
|
end
|
||||||
|
|
||||||
|
digob(ws.dircoord(i,0,0))
|
||||||
|
|
||||||
|
blockliquids(ws.dircoord(i,1,0))
|
||||||
|
blockliquids(ws.dircoord(i,0,0))
|
||||||
ws.dig(ws.dircoord(i,1,0))
|
ws.dig(ws.dircoord(i,1,0))
|
||||||
if checknode(ws.dircoord(i,0,0)) then ws.dig(ws.dircoord(i,0,0)) end
|
if checknode(ws.dircoord(i,0,0)) then ws.dig(ws.dircoord(i,0,0)) end
|
||||||
if checknode(ws.dircoord(i,-1,0)) then ws.dig(ws.dircoord(i,-1,0)) end
|
if checknode(ws.dircoord(i,-1,0)) then ws.dig(ws.dircoord(i,-1,0)) end
|
||||||
scaffold.place_if_needed(ground, ws.dircoord(i,-1,0))
|
ws.place(ws.dircoord(i,-1,0),ground,7)
|
||||||
scaffold.place_if_needed(rails, ws.dircoord(i,0,0))
|
ws.place(ws.dircoord(i,0,0),rails,6)
|
||||||
|
|
||||||
local lpn=minetest.get_node_or_nil(ws.dircoord(i,0,0))
|
|
||||||
local bln=minetest.get_node_or_nil(ws.dircoord(i,-1,0))
|
|
||||||
if not ( bln and bln.name=="mesecons_torch:redstoneblock" and lpn and lpn.name == "mcl_minecarts:golden_rail_on" ) then
|
|
||||||
goon=false
|
|
||||||
end
|
|
||||||
local lpos=ws.dircoord(i,2,0)
|
local lpos=ws.dircoord(i,2,0)
|
||||||
if is_lantern(lpos) then
|
if is_lantern(lpos) then
|
||||||
local ln=minetest.get_node_or_nil(lpos)
|
local ln=minetest.get_node_or_nil(lpos)
|
||||||
if not ln or ln.name ~= 'mcl_ocean:sea_lantern' then
|
if not ln or ln.name ~= lightblock then
|
||||||
goon=false
|
goon=false
|
||||||
ws.dig(lpos)
|
ws.dig(lpos)
|
||||||
scaffold.place_if_needed({'mcl_ocean:sea_lantern'}, lpos)
|
ws.place(lpos,{lightblock},5)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if (goon) then minetest.settings:set_bool('continuous_forward',true)
|
if (goon) then
|
||||||
else minetest.settings:set_bool('continuous_forward',false) end
|
local dir=ws.getdir()
|
||||||
|
local lp=minetest.localplayer:get_pos()
|
||||||
|
local rlp=vector.round(lp)
|
||||||
|
minetest.localplayer:set_pos(vector.new(rlp.x,lp.y,rlp.z))
|
||||||
|
minetest.settings:set_bool('continuous_forward',true)
|
||||||
|
else
|
||||||
|
slowdown(5)
|
||||||
|
minetest.localplayer:set_velocity(vector.new(0,0,0))
|
||||||
|
minetest.settings:set_bool('continuous_forward',false)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
end,
|
end,
|
||||||
function()--startfunc
|
function()--startfunc
|
||||||
direction=ws.get_dir()
|
minetest.settings:set('movement_speed_fast',500)
|
||||||
storage:set_string('BOTDIR', direction)
|
minetest.settings:set_bool('continuous_forward',false)
|
||||||
end,function() --stopfunc
|
end,function() --stopfunc
|
||||||
direction=""
|
minetest.localplayer:set_velocity(vector.new(0,0,0))
|
||||||
storage:set_string('BOTDIR',direction)
|
minetest.settings:set('movement_speed_fast',20)
|
||||||
end,{'afly_axissnap','continuous_forward','autorefill'}) --'scaffold_ltbm'
|
minetest.settings:set_bool('continuous_forward',false)
|
||||||
|
end,{'afly_snap','autorefill'}) --'scaffold_ltbm'
|
||||||
|
|
||||||
|
|
||||||
ws.on_connect(function()
|
|
||||||
sdir=storage:get_string('BOTDIR')
|
|
||||||
if sdir ~= "" then
|
|
||||||
ws.set_dir(sdir)
|
|
||||||
else
|
|
||||||
minetest.settings:set_bool('railbot',false)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
scaffold.register_template_scaffold("LanternTBM", "scaffold_ltbm", function()
|
scaffold.register_template_scaffold("LanternTBM", "scaffold_ltbm", function()
|
||||||
local dir=ws.getdir()
|
local dir=ws.getdir()
|
||||||
@ -163,12 +306,9 @@ scaffold.register_template_scaffold("LanternTBM", "scaffold_ltbm", function()
|
|||||||
if pl then
|
if pl then
|
||||||
local lpos=ws.dircoord(0,2,0)
|
local lpos=ws.dircoord(0,2,0)
|
||||||
local nd=minetest.get_node_or_nil(lpos)
|
local nd=minetest.get_node_or_nil(lpos)
|
||||||
if nd and nd.name ~= 'mcl_ocean:sea_lantern' then
|
if nd and nd.name ~= lightblock then
|
||||||
ws.dig(lpos)
|
ws.dig(lpos)
|
||||||
minetest.after("0",function()
|
ws.place(lpos,lightblock,5)
|
||||||
scaffold.place_if_needed({'mcl_ocean:sea_lantern'}, lpos)
|
|
||||||
ws.place(lpos,'mcl_ocean:sea_lantern')
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
Loading…
x
Reference in New Issue
Block a user