]> git.lizzy.rs Git - dragonfireclient.git/blob - clientmods/world/init.lua
idk
[dragonfireclient.git] / clientmods / world / init.lua
1 minetest.register_chatcommand("findnodes", {
2         description = "Scan for one or multible nodes in a radius around you",
3         param = "<radius> <node1>[,<node2>...]",
4         func = function(param)
5                 local radius = tonumber(param:split(" ")[1])
6                 local nodes = param:split(" ")[2]:split(",")
7                 local pos = minetest.localplayer:get_pos()
8                 local fpos = minetest.find_node_near(pos, radius, nodes, true)
9                 if fpos then
10                         return true, "Found " .. table.concat(nodes, " or ") .. " at " .. minetest.pos_to_string(fpos)
11                 end
12                 return false, "None of " .. table.concat(nodes, " or ") .. " found in a radius of " .. tostring(radius)
13         end,
14 }) 
15
16 minetest.register_chatcommand("place", {
17         params = "<X>,<Y>,<Z>",
18         description = "Place wielded item",
19         func = function(param)
20                 local success, pos = minetest.parse_relative_pos(param)
21                 if success then
22                         minetest.place_node(pos)
23                         return true, "Node placed at " .. minetest.pos_to_string(pos)
24                 end
25                 return false, pos
26         end,
27 })
28
29 minetest.register_chatcommand("dig", {
30         params = "<X>,<Y>,<Z>",
31         description = "Dig node",
32         func = function(param)
33                 local success, pos = minetest.parse_relative_pos(param)
34                 if success then
35                         minetest.dig_node(pos)
36                         return true, "Node at " .. minetest.pos_to_string(pos) .. " dug"
37                 end
38                 return false, pos
39         end,
40 })
41
42 local etime = 0
43
44 minetest.register_globalstep(function(dtime)
45         etime = etime + dtime
46         if etime < 1 then return end
47         local player = minetest.localplayer
48         if not player then return end
49         local pos = player:get_pos()
50         local item = player:get_wielded_item()
51         local def = minetest.get_item_def(item:get_name())
52         if item:get_count() > 0 and def.node_placement_prediction ~= "" then
53                 if minetest.settings:get_bool("scaffold") then
54                         minetest.place_node(vector.add(pos, {x = 0, y = -0.6, z = 0}))
55                 elseif minetest.settings:get_bool("highway_z") then
56                         local z = pos.z
57                         local positions = {
58                                 {x = 0, y = 0, z = z},
59                                 {x = 1, y = 0, z = z},
60                                 {x = 2, y = 1, z = z},
61                                 {x = -2, y = 1, z = z},
62                                 {x = -2, y = 0, z = z},
63                                 {x = -1, y = 0, z = z},
64                                 {x = 2, y = 0, z = z}
65                         }
66                         for i, p in pairs(positions) do
67                                 minetest.place_node(p)
68                         end
69                 elseif minetest.settings:get_bool("destroy_liquids") then
70                         local positions = minetest.find_nodes_near(pos, 5, {"mcl_core:water_source", "mcl_core:water_floating"}, true)
71                         for _, p in pairs(positions) do
72                                 minetest.place_node(p)
73                         end
74                 elseif minetest.settings:get_bool("autotnt") then
75                         local positions = minetest.find_nodes_near_under_air_except(pos, 5, item:get_name(), true)
76                         for i, p in pairs(positions) do
77                                 if i > 8 then break end
78                                 minetest.place_node(vector.add(p, {x = 0, y = 1, z = 0}))
79                         end
80                 end
81         end
82 end) 
83
84 minetest.register_cheat("Scaffold", "World", "scaffold")
85 minetest.register_cheat("HighwayZ", "World", "highway_z")
86 minetest.register_cheat("BlockWater", "World", "destroy_liquids")
87 minetest.register_cheat("AutoTNT", "World", "autotnt")