From 73b89703f9b49ed5c0e7463f1a7be2bbe64ec344 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sun, 16 Aug 2020 16:39:29 +0200 Subject: [PATCH] Improved World hacks, added fill --- clientmods/world/init.lua | 55 +++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/clientmods/world/init.lua b/clientmods/world/init.lua index 2e7409b73..198bc597f 100644 --- a/clientmods/world/init.lua +++ b/clientmods/world/init.lua @@ -42,25 +42,35 @@ minetest.register_chatcommand("dig", { minetest.register_globalstep(function() local player = minetest.localplayer if not player then return end - local pos = minetest.localplayer:get_pos() - local wielditem = minetest.localplayer:get_wielded_item() - if minetest.settings:get_bool("scaffold") then - minetest.place_node(vector.add(pos, {x = 0, y = -0.6, z = 0})) - end - if minetest.settings:get_bool("highway_z") and wielditem 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 _, p in pairs(positions) do - local node = minetest.get_node_or_nil(p) - if node and not minetest.get_node_def(node.name).walkable then + local pos = player:get_pos() + local count = player:get_wielded_item():get_count() + if count > 0 then + if minetest.settings:get_bool("scaffold") then + minetest.place_node(vector.add(pos, {x = 0, y = -0.6, z = 0})) + 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 > count then break end + 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) end end @@ -71,15 +81,10 @@ minetest.register_globalstep(function() minetest.dig_node(p) 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) minetest.register_cheat("Scaffold", "World", "scaffold") minetest.register_cheat("HighwayZ", "World", "highway_z") minetest.register_cheat("Fucker", "World", "fucker") minetest.register_cheat("BlockWater", "World", "destroy_liquids") +minetest.register_cheat("Fill", "World", "fill")