diff options
Diffstat (limited to 'clientmods/maputil')
-rw-r--r-- | clientmods/maputil/buildbot.lua | 57 | ||||
-rw-r--r-- | clientmods/maputil/commands.lua | 42 | ||||
-rw-r--r-- | clientmods/maputil/init.lua | 5 | ||||
-rw-r--r-- | clientmods/maputil/mod.conf | 3 |
4 files changed, 107 insertions, 0 deletions
diff --git a/clientmods/maputil/buildbot.lua b/clientmods/maputil/buildbot.lua new file mode 100644 index 000000000..81e6e75e0 --- /dev/null +++ b/clientmods/maputil/buildbot.lua @@ -0,0 +1,57 @@ +local build = {} + +local function build_y(callback) + build.pos.y = build.pos.y - build.step.y + local function step() + build.pos.y = build.pos.y + build.step.y + minetest.after(0.25, (build.pos.y == build.goal.y) and callback or step) + minetest.place_node(build.pos) + local player_pos = minetest.find_node_near(build.pos, 2, "air") + if player_pos then + minetest.localplayer:set_pos(player_pos) + end + end + minetest.after(0.25, step) +end + +local function build_z(callback) + build.pos.z = build.pos.z - build.step.z + local function step() + build.start.y, build.goal.y = build.goal.y, build.start.y + build.step.y = (build.goal.y > build.pos.y) and 1 or -1 + build.pos.z = build.pos.z + build.step.z + build_y((build.pos.z == build.goal.z) and callback or step) + end + minetest.after(0.25, step) +end + +local function build_x(callback) + build.pos.x = build.pos.x - build.step.x + local function step() + build.start.z, build.goal.z = build.goal.z, build.start.z + build.step.z = (build.goal.z > build.pos.z) and 1 or -1 + build.pos.x = build.pos.x + build.step.x + build_z((build.pos.x == build.goal.x) and callback or step) + end + minetest.after(0.25, step) +end + +minetest.register_chatcommand("build", { + func = function(param) + local sucess + build.start = vector.round(minetest.localplayer:get_pos()) + build.pos = vector.new(build.start) + success, build.goal = minetest.parse_relative_pos(param) + if success then + build.step = {} + build.step.x = (build.goal.x > build.start.x) and 1 or -1 + build.start.z, build.goal.z = build.goal.z, build.start.z + build.start.y, build.goal.y = build.goal.y, build.start.y + build_x(function() minetest.display_chat_message("Done.") end) + end + return false, build.goal + end +}) + + + diff --git a/clientmods/maputil/commands.lua b/clientmods/maputil/commands.lua new file mode 100644 index 000000000..4f88cd145 --- /dev/null +++ b/clientmods/maputil/commands.lua @@ -0,0 +1,42 @@ +minetest.register_chatcommand("findnodes", { + description = "Scan for one or multible nodes in a radius around you", + param = "<radius> <node1>[,<node2>...]", + func = function(param) + local radius = tonumber(param:split(" ")[1]) + local nodes = param:split(" ")[2]:split(",") + local pos = core.localplayer:get_pos() + local fpos = core.find_node_near(pos, radius, nodes, true) + if fpos then + return true, "Found " .. table.concat(nodes, " or ") .. " at " .. core.pos_to_string(fpos) + end + return false, "None of " .. table.concat(nodes, " or ") .. " found in a radius of " .. tostring(radius) + end, +}) + +minetest.register_chatcommand("place", { + params = "<X>,<Y>,<Z>", + description = "Place wielded item", + func = function(param) + local success, pos = minetest.parse_relative_pos(param) + if success then + minetest.place_node(pos) + return true, "Node placed at " .. minetest.pos_to_string(pos) + end + return false, pos + end, +}) + +minetest.register_chatcommand("dig", { + params = "<X>,<Y>,<Z>", + description = "Dig node", + func = function(param) + local success, pos = minetest.parse_relative_pos(param) + if success then + minetest.dig_node(pos) + return true, "Node at " .. minetest.pos_to_string(pos) .. " dug" + end + return false, pos + end, +}) + + diff --git a/clientmods/maputil/init.lua b/clientmods/maputil/init.lua new file mode 100644 index 000000000..58af2fcb9 --- /dev/null +++ b/clientmods/maputil/init.lua @@ -0,0 +1,5 @@ +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) + +dofile(modpath .. "/commands.lua") +dofile(modpath .. "/buildbot.lua") diff --git a/clientmods/maputil/mod.conf b/clientmods/maputil/mod.conf new file mode 100644 index 000000000..b2ad5305d --- /dev/null +++ b/clientmods/maputil/mod.conf @@ -0,0 +1,3 @@ +name = maputil +author = Fleckenstein +description = Includes commands and a advanced bot for map interaction |