Improved World hacks, added fill

This commit is contained in:
Elias Fleckenstein 2020-08-16 16:39:29 +02:00
parent 248dedaba3
commit 73b89703f9

View File

@ -42,12 +42,12 @@ minetest.register_chatcommand("dig", {
minetest.register_globalstep(function() minetest.register_globalstep(function()
local player = minetest.localplayer local player = minetest.localplayer
if not player then return end if not player then return end
local pos = minetest.localplayer:get_pos() local pos = player:get_pos()
local wielditem = minetest.localplayer:get_wielded_item() local count = player:get_wielded_item():get_count()
if count > 0 then
if minetest.settings:get_bool("scaffold") then if minetest.settings:get_bool("scaffold") then
minetest.place_node(vector.add(pos, {x = 0, y = -0.6, z = 0})) minetest.place_node(vector.add(pos, {x = 0, y = -0.6, z = 0}))
end elseif minetest.settings:get_bool("highway_z") then
if minetest.settings:get_bool("highway_z") and wielditem then
local z = pos.z local z = pos.z
local positions = { local positions = {
{x = 0, y = 0, z = z}, {x = 0, y = 0, z = z},
@ -58,9 +58,19 @@ minetest.register_globalstep(function()
{x = -1, y = 0, z = z}, {x = -1, y = 0, z = z},
{x = 2, y = 0, z = z} {x = 2, y = 0, z = z}
} }
for _, p in pairs(positions) do for i, p in pairs(positions) do
local node = minetest.get_node_or_nil(p) if i > count then break end
if node and not minetest.get_node_def(node.name).walkable then minetest.place_node(p)
end
elseif minetest.settings:get_bool("destroy_liquids") then
local p = minetest.find_node_near(pos, 5, "mcl_core:water_source", true) or minetest.find_node_near(pos, 5, "mcl_core:water_floating", true)
if p then
minetest.place_node(p)
end
elseif minetest.settings:get_bool("fill") then
local positions = minetest.find_nodes_in_area(vector.add(pos, {x = 5, y = -0.6, z = 5}), vector.add(pos, {x = -5, y = -5.6, z = -5}), "air")
for i, p in pairs(positions) do
if i > count then break end
minetest.place_node(p) minetest.place_node(p)
end end
end end
@ -71,15 +81,10 @@ minetest.register_globalstep(function()
minetest.dig_node(p) minetest.dig_node(p)
end end
end end
if minetest.settings:get_bool("destroy_liquids") then
local p = minetest.find_node_near(pos, 5, "mcl_core:water_source", true) or minetest.find_node_near(pos, 5, "mcl_core:water_floating", true)
if p then
minetest.place_node(p)
end
end
end) end)
minetest.register_cheat("Scaffold", "World", "scaffold") minetest.register_cheat("Scaffold", "World", "scaffold")
minetest.register_cheat("HighwayZ", "World", "highway_z") minetest.register_cheat("HighwayZ", "World", "highway_z")
minetest.register_cheat("Fucker", "World", "fucker") minetest.register_cheat("Fucker", "World", "fucker")
minetest.register_cheat("BlockWater", "World", "destroy_liquids") minetest.register_cheat("BlockWater", "World", "destroy_liquids")
minetest.register_cheat("Fill", "World", "fill")