From 45aa2516b2fc675df7049bc9ed713600c95b6423 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sat, 18 Jul 2020 13:20:08 +0200 Subject: Added settings --- clientmods/autofarm/init.lua | 11 ---- clientmods/buildbot/init.lua | 96 ----------------------------- clientmods/colorchat/LICENSE | 21 +++++++ clientmods/colorchat/init.lua | 91 ++++++++++++++++++++++++++++ clientmods/colorchat/mod.conf | 3 + clientmods/colour_chat/LICENSE | 21 ------- clientmods/colour_chat/README.md | 5 -- clientmods/colour_chat/init.lua | 121 ------------------------------------- clientmods/commands/init.lua | 109 ++++++++++++++++----------------- clientmods/commands/mod.conf | 3 + clientmods/destroyliquids/init.lua | 22 ------- clientmods/echest/init.lua | 28 --------- clientmods/enderchest/init.lua | 25 ++++++++ clientmods/enderchest/mod.conf | 3 + clientmods/mapbot/api.lua | 41 +++++++++++++ clientmods/mapbot/init.lua | 10 +++ clientmods/mapbot/mod.conf | 3 + clientmods/mapbot/simple_bots.lua | 30 +++++++++ clientmods/maputil/buildbot.lua | 57 +++++++++++++++++ clientmods/maputil/commands.lua | 42 +++++++++++++ clientmods/maputil/init.lua | 5 ++ clientmods/maputil/mod.conf | 3 + clientmods/misc/init.lua | 2 + clientmods/misc/mod.conf | 3 + clientmods/mods.conf | 9 --- clientmods/respawn/init.lua | 44 ++++++++++++++ clientmods/respawn/mod.conf | 4 ++ clientmods/set/init.lua | 33 ---------- clientmods/test/init.lua | 1 - clientmods/warp/init.lua | 69 +++++++++++++++++++++ clientmods/warp/mod.conf | 3 + 31 files changed, 517 insertions(+), 401 deletions(-) delete mode 100644 clientmods/autofarm/init.lua delete mode 100644 clientmods/buildbot/init.lua create mode 100644 clientmods/colorchat/LICENSE create mode 100644 clientmods/colorchat/init.lua create mode 100644 clientmods/colorchat/mod.conf delete mode 100644 clientmods/colour_chat/LICENSE delete mode 100644 clientmods/colour_chat/README.md delete mode 100644 clientmods/colour_chat/init.lua create mode 100644 clientmods/commands/mod.conf delete mode 100644 clientmods/destroyliquids/init.lua delete mode 100644 clientmods/echest/init.lua create mode 100644 clientmods/enderchest/init.lua create mode 100644 clientmods/enderchest/mod.conf create mode 100644 clientmods/mapbot/api.lua create mode 100644 clientmods/mapbot/init.lua create mode 100644 clientmods/mapbot/mod.conf create mode 100644 clientmods/mapbot/simple_bots.lua create mode 100644 clientmods/maputil/buildbot.lua create mode 100644 clientmods/maputil/commands.lua create mode 100644 clientmods/maputil/init.lua create mode 100644 clientmods/maputil/mod.conf create mode 100644 clientmods/misc/init.lua create mode 100644 clientmods/misc/mod.conf delete mode 100644 clientmods/mods.conf create mode 100644 clientmods/respawn/init.lua create mode 100644 clientmods/respawn/mod.conf delete mode 100644 clientmods/set/init.lua delete mode 100644 clientmods/test/init.lua create mode 100644 clientmods/warp/init.lua create mode 100644 clientmods/warp/mod.conf (limited to 'clientmods') diff --git a/clientmods/autofarm/init.lua b/clientmods/autofarm/init.lua deleted file mode 100644 index 3dff43416..000000000 --- a/clientmods/autofarm/init.lua +++ /dev/null @@ -1,11 +0,0 @@ -local function loop() - local item = minetest.get_wielded_item():get_name() - local pos = minetest.find_node_near(minetest.localplayer:get_pos(), 5, "mcl_farming:wheat", true) - if item == "mcl_farming:wheat_seeds" and pos then - minetest.dig_node(pos) - minetest.place_node(pos) - end - minetest.after(0.1, loop) -end - -minetest.register_on_connect(loop) diff --git a/clientmods/buildbot/init.lua b/clientmods/buildbot/init.lua deleted file mode 100644 index 6aedb7b3b..000000000 --- a/clientmods/buildbot/init.lua +++ /dev/null @@ -1,96 +0,0 @@ -buildbot = {} - -local function build_y(callback) - buildbot.pos.y = buildbot.pos.y - buildbot.step.y - local function step() - buildbot.pos.y = buildbot.pos.y + buildbot.step.y - minetest.after(0.25, (buildbot.pos.y == buildbot.goal.y) and callback or step) - minetest.place_node(buildbot.pos) - local player_pos = minetest.find_node_near(buildbot.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) - buildbot.pos.z = buildbot.pos.z - buildbot.step.z - local function step() - buildbot.start.y, buildbot.goal.y = buildbot.goal.y, buildbot.start.y - buildbot.step.y = (buildbot.goal.y > buildbot.pos.y) and 1 or -1 - buildbot.pos.z = buildbot.pos.z + buildbot.step.z - build_y((buildbot.pos.z == buildbot.goal.z) and callback or step) - end - minetest.after(0.25, step) -end - -local function build_x(callback) - buildbot.pos.x = buildbot.pos.x - buildbot.step.x - local function step() - buildbot.start.z, buildbot.goal.z = buildbot.goal.z, buildbot.start.z - buildbot.step.z = (buildbot.goal.z > buildbot.pos.z) and 1 or -1 - buildbot.pos.x = buildbot.pos.x + buildbot.step.x - build_z((buildbot.pos.x == buildbot.goal.x) and callback or step) - end - minetest.after(0.25, step) -end - -minetest.register_chatcommand("build", { - func = function(param) - local sucess - buildbot.start = vector.round(minetest.localplayer:get_pos()) - buildbot.pos = vector.new(buildbot.start) - success, buildbot.goal = minetest.parse_pos(param) - if success then - buildbot.step = {} - buildbot.step.x = (buildbot.goal.x > buildbot.start.x) and 1 or -1 - buildbot.start.z, buildbot.goal.z = buildbot.goal.z, buildbot.start.z - buildbot.start.y, buildbot.goal.y = buildbot.goal.y, buildbot.start.y - build_x(function() minetest.display_chat_message("Done.") end) - end - return false, buildbot.goal - end -}) - -local keep_digging = false - -core.register_chatcommand("keepdigging", { - params = ",,", - description = "Dig node again and again", - func = function(param) - local success, pos = core.parse_pos(param) - if success then - keep_digging = true - local function loop() - core.dig_node(pos) - if keep_digging then - core.after(0.1, loop) - end - end - loop() - end - end, -}) - -core.register_chatcommand("stopdigging", { - description = "Stop diggin", - func = function() - keep_digging = false - end, -}) - - -core.register_chatcommand("digaround", { - description = "Automatically dig nodes around you", - param = " [] ...", - func = function(param) - local nodes = param:split(" ") - local function loop() - local fpos = core.find_node_near(core.localplayer:get_pos(), 5, nodes, true) - if fpos then core.dig_node(fpos) end - core.after(0, loop) - end - loop() - end, -}) diff --git a/clientmods/colorchat/LICENSE b/clientmods/colorchat/LICENSE new file mode 100644 index 000000000..93f5629ca --- /dev/null +++ b/clientmods/colorchat/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 red-001 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/clientmods/colorchat/init.lua b/clientmods/colorchat/init.lua new file mode 100644 index 000000000..18e02ffe3 --- /dev/null +++ b/clientmods/colorchat/init.lua @@ -0,0 +1,91 @@ +local modstorage = minetest.get_mod_storage() + +local register_on_message = minetest.register_on_sending_chat_message +if minetest.register_on_sending_chat_messages then + register_on_message = minetest.register_on_sending_chat_messages +end + +local function rgb_to_hex(rgb) + local hexadecimal = '#' + + for key, value in pairs(rgb) do + local hex = '' + + while(value > 0)do + local index = math.fmod(value, 16) + 1 + value = math.floor(value / 16) + hex = string.sub('0123456789ABCDEF', index, index) .. hex + end + + if(string.len(hex) == 0)then + hex = '00' + + elseif(string.len(hex) == 1)then + hex = '0' .. hex + end + + hexadecimal = hexadecimal .. hex + end + + return hexadecimal +end + +local function color_from_hue(hue) + local h = hue / 60 + local c = 255 + local x = (1 - math.abs(h%2 - 1)) * 255 + + local i = math.floor(h); + if (i == 0) then + return rgb_to_hex({c, x, 0}) + elseif (i == 1) then + return rgb_to_hex({x, c, 0}) + elseif (i == 2) then + return rgb_to_hex({0, c, x}) + elseif (i == 3) then + return rgb_to_hex({0, x, c}); + elseif (i == 4) then + return rgb_to_hex({x, 0, c}); + else + return rgb_to_hex({c, 0, x}); + end +end + +register_on_message(function(message) + if message:sub(1,1) == "/" or modstorage:get_string("color") == "" or modstorage:get_string("color") == "white" then + return false + end + + minetest.send_chat_message(minetest.get_color_escape_sequence(modstorage:get_string("color")) .. message) + return true +end) + +minetest.register_chatcommand("set_color", { + description = minetest.gettext("Change chat color"), + func = function(colour) + modstorage:set_string("color", colour) + return true, "Chat color changed." + end, +}) + +minetest.register_chatcommand("rainbow", { + description = minetest.gettext("rainbow text"), + func = function(param) + local step = 360 / param:len() + local hue = 0 + -- iterate the whole 360 degrees + local output = "" + for i = 1, param:len() do + local char = param:sub(i,i) + if char:match("%s") then + output = output .. char + else + output = output .. minetest.get_color_escape_sequence(color_from_hue(hue)) .. char + end + hue = hue + step + end + minetest.send_chat_message(output) + return true +end, +}) + diff --git a/clientmods/colorchat/mod.conf b/clientmods/colorchat/mod.conf new file mode 100644 index 000000000..f152fc1ce --- /dev/null +++ b/clientmods/colorchat/mod.conf @@ -0,0 +1,3 @@ +name = colorchat +author = red-001, Fleckenstein +description = A minetest CSM mod for changing the color of text sent to the server. diff --git a/clientmods/colour_chat/LICENSE b/clientmods/colour_chat/LICENSE deleted file mode 100644 index 93f5629ca..000000000 --- a/clientmods/colour_chat/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 red-001 - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/clientmods/colour_chat/README.md b/clientmods/colour_chat/README.md deleted file mode 100644 index e746761df..000000000 --- a/clientmods/colour_chat/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# colour_chat -A minetest CSM mod for changing the colour of text sent to the server. - -### Usage -Use .set_colour to set the colour of chat sent to the server, you can use either HTML named colours or HTML hexdecimal colour codes. Use .rainbow to generate rainbow text diff --git a/clientmods/colour_chat/init.lua b/clientmods/colour_chat/init.lua deleted file mode 100644 index e3c82bf59..000000000 --- a/clientmods/colour_chat/init.lua +++ /dev/null @@ -1,121 +0,0 @@ -local modstorage = core.get_mod_storage() - -local register_on_message = core.register_on_sending_chat_message -if core.register_on_sending_chat_messages then - register_on_message = core.register_on_sending_chat_messages -end - -local function rgb_to_hex(rgb) - local hexadecimal = '#' - - for key, value in pairs(rgb) do - local hex = '' - - while(value > 0)do - local index = math.fmod(value, 16) + 1 - value = math.floor(value / 16) - hex = string.sub('0123456789ABCDEF', index, index) .. hex - end - - if(string.len(hex) == 0)then - hex = '00' - - elseif(string.len(hex) == 1)then - hex = '0' .. hex - end - - hexadecimal = hexadecimal .. hex - end - - return hexadecimal -end - -local function color_from_hue(hue) - local h = hue / 60 - local c = 255 - local x = (1 - math.abs(h%2 - 1)) * 255 - - local i = math.floor(h); - if (i == 0) then - return rgb_to_hex({c, x, 0}) - elseif (i == 1) then - return rgb_to_hex({x, c, 0}) - elseif (i == 2) then - return rgb_to_hex({0, c, x}) - elseif (i == 3) then - return rgb_to_hex({0, x, c}); - elseif (i == 4) then - return rgb_to_hex({x, 0, c}); - else - return rgb_to_hex({c, 0, x}); - end -end - -local function canTalk() - if core.get_privilege_list then - return core.get_privilege_list().shout - else - return true - end -end - -local function say(message) - if not canTalk() then - minetest.display_chat_message("You need 'shout' in order to talk") - return - end - minetest.send_chat_message(message) - if minetest.get_server_info().protocol_version < 29 then - local name = minetest.localplayer:get_name() - minetest.display_chat_message("<"..name.."> " .. message) - end -end - -register_on_message(function(message) - if message:sub(1,1) == "/" or modstorage:get_string("colour") == "" or modstorage:get_string("colour") == "white" then - return false - end - - say(core.get_color_escape_sequence(modstorage:get_string("colour")) .. message) - return true -end) - -core.register_chatcommand("set_colour", { - description = core.gettext("Change chat colour"), - func = function(colour) - modstorage:set_string("colour", colour) - return true, "Chat colour changed." - end, -}) - -core.register_chatcommand("rainbow", { - description = core.gettext("rainbow text"), - func = function(param) - if not canTalk() then - return false, "You need 'shout' in order to use this command" - end - local step = 360 / param:len() - local hue = 0 - -- iterate the whole 360 degrees - local output = "" - for i = 1, param:len() do - local char = param:sub(i,i) - if char:match("%s") then - output = output .. char - else - output = output .. core.get_color_escape_sequence(color_from_hue(hue)) .. char - end - hue = hue + step - end - say(output) - return true -end, -}) - -core.register_chatcommand("say", { - description = core.gettext("Send text without applying colour to it"), - func = function(text) - say(text) - return true - end, -}) diff --git a/clientmods/commands/init.lua b/clientmods/commands/init.lua index 6e2ea4ed6..4ea8d04f6 100644 --- a/clientmods/commands/init.lua +++ b/clientmods/commands/init.lua @@ -1,80 +1,81 @@ -core.register_chatcommand("place", { - params = ",,", - description = "Place wielded item", - func = function(param) - local success, pos = core.parse_pos(param) - if success then - core.place_node(pos) - return true, "Node placed at " .. core.pos_to_string(pos) - end - return false, pos +minetest.register_chatcommand("say", { + description = "Send raw text", + func = function(text) + minetest.send_chat_message(text) + return true end, }) -core.register_chatcommand("dig", { +minetest.register_chatcommand("teleport", { params = ",,", - description = "Dig node", + description = "Teleport to position. " .. (core.anticheat_protection and "Only works for short distances." or ""), func = function(param) local success, pos = core.parse_pos(param) if success then - core.dig_node(pos) - return true, "Node at " .. core.pos_to_string(pos) .. " dug" + core.localplayer:set_pos(pos) + return true, "Teleporting to " .. core.pos_to_string(pos) end return false, pos end, }) -core.register_chatcommand("kill", { - description = "Kill yourself", - func = function(param) - core.send_damage(core.localplayer:get_hp()) - end, +minetest.register_chatcommand("wielded", { + description = "Print itemstring of wieleded item", + func = function() + return true, minetest.get_wielded_item():get_name() + end }) -core.register_chatcommand("scan", { - description = "Scan for one or multible nodes in a radius around you", - param = " node1[,node2...]", +minetest.register_chatcommand("disconnect", { + description = "Exit to main menu", 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) + minetest.disconnect() end, }) -local function teleport(param) - local success, pos = core.parse_pos(param) - if success then - core.localplayer:set_pos(pos) - return true, "Teleporting to " .. core.pos_to_string(pos) +minetest.register_chatcommand("players", { + description = "List online players", + func = function(param) + return true, "Online players: " .. table.concat(minetest.get_player_names(), ", ") end - return false, pos -end +}) -core.register_chatcommand("teleport", { - params = ",,", - description = "Teleport to position", - func = function(param) - return teleport(param) +minetest.register_chatcommand("kill", { + description = "Kill yourself", + func = function() + minetest.send_damage(minetest.localplayer:get_hp()) end, }) -core.register_chatcommand("tpoff", { - params = ",,", - description = "Teleport to position and log out immediately", +minetest.register_chatcommand("set", { + params = "([-n] ) | ", + description = "Set or read client configuration setting", func = function(param) - teleport(param) - minetest.disconnect() - end, -}) + local arg, setname, setvalue = string.match(param, "(-[n]) ([^ ]+) (.+)") + if arg and arg == "-n" and setname and setvalue then + minetest.settings:set(setname, setvalue) + return true, setname .. " = " .. setvalue + end -minetest.register_chatcommand("wielded", { - description = "Print itemstring of wieleded item", - func = function() - return true, minetest.get_wielded_item():get_name() - end + setname, setvalue = string.match(param, "([^ ]+) (.+)") + if setname and setvalue then + if not minetest.settings:get(setname) then + return false, "Failed. Use '.set -n ' to create a new setting." + end + minetest.settings:set(setname, setvalue) + return true, setname .. " = " .. setvalue + end + + setname = string.match(param, "([^ ]+)") + if setname then + setvalue = minetest.settings:get(setname) + if not setvalue then + setvalue = "" + end + return true, setname .. " = " .. setvalue + end + + return false, "Invalid parameters (see .help set)." + end, }) + diff --git a/clientmods/commands/mod.conf b/clientmods/commands/mod.conf new file mode 100644 index 000000000..48f2d6f25 --- /dev/null +++ b/clientmods/commands/mod.conf @@ -0,0 +1,3 @@ +name = commands +author = Fleckenstein +description = Misc cheat commands diff --git a/clientmods/destroyliquids/init.lua b/clientmods/destroyliquids/init.lua deleted file mode 100644 index 711754167..000000000 --- a/clientmods/destroyliquids/init.lua +++ /dev/null @@ -1,22 +0,0 @@ -minetest.override_item("air", {liquids_pointable = true}) -local destroy_water = false - -local function loop() - if destroy_water then - local pos = minetest.find_node_near(minetest.localplayer:get_pos(), 5, "mcl_core:water_source", true) - if pos then - minetest.place_node(pos) - end - end - minetest.after(0, loop) -end - -minetest.after(1, loop) - -minetest.register_chatcommand("destroywater", { - param = "true|false", - description = "Turn destroy water on/off", - func = function(param) - destroy_water = minetest.is_yes(param) - end -}) diff --git a/clientmods/echest/init.lua b/clientmods/echest/init.lua deleted file mode 100644 index ad7e4c9e9..000000000 --- a/clientmods/echest/init.lua +++ /dev/null @@ -1,28 +0,0 @@ - -function get_itemslot_bg(x, y, w, h) - local out = "" - for i = 0, w - 1, 1 do - for j = 0, h - 1, 1 do - out = out .."image["..x+i..","..y+j..";1,1;mcl_formspec_itemslot.png]" - end - end - return out -end - -local formspec_ender_chest = "size[9,8.75]".. - "label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", "Ender Chest")).."]".. - "list[current_player;enderchest;0,0.5;9,3;]".. - get_itemslot_bg(0,0.5,9,3).. - "label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", "Inventory")).."]".. - "list[current_player;main;0,4.5;9,3;9]".. - get_itemslot_bg(0,4.5,9,3).. - "list[current_player;main;0,7.74;9,1;]".. - get_itemslot_bg(0,7.74,9,1).. - "listring[current_player;enderchest]".. - "listring[current_player;main]" - -minetest.register_chatcommand("echest", { - func = function() - minetest.show_formspec("echest:enderchest", formspec_ender_chest) - end -}) diff --git a/clientmods/enderchest/init.lua b/clientmods/enderchest/init.lua new file mode 100644 index 000000000..458854d05 --- /dev/null +++ b/clientmods/enderchest/init.lua @@ -0,0 +1,25 @@ +function get_itemslot_bg(x, y, w, h) + local out = "" + for i = 0, w - 1, 1 do + for j = 0, h - 1, 1 do + out = out .."image["..x+i..","..y+j..";1,1;mcl_formspec_itemslot.png]" + end + end + return out +end + +local formspec = "size[9,8.75]".. + "label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", "Ender Chest")).."]".. + "list[current_player;enderchest;0,0.5;9,3;]".. + get_itemslot_bg(0,0.5,9,3).. + "label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", "Inventory")).."]".. + "list[current_player;main;0,4.5;9,3;9]".. + get_itemslot_bg(0,4.5,9,3).. + "list[current_player;main;0,7.74;9,1;]".. + get_itemslot_bg(0,7.74,9,1).. + "listring[current_player;enderchest]".. + "listring[current_player;main]" + +function minetest.show_extra_inventory() + minetest.show_formspec("enderchest:enderchest", formspec) +end diff --git a/clientmods/enderchest/mod.conf b/clientmods/enderchest/mod.conf new file mode 100644 index 000000000..f3c30ea3e --- /dev/null +++ b/clientmods/enderchest/mod.conf @@ -0,0 +1,3 @@ +name = enderchest +author = Fleckenstein +description = You can use this mod in MineClone2 to view you Enderinventory without an Ender Chest. diff --git a/clientmods/mapbot/api.lua b/clientmods/mapbot/api.lua new file mode 100644 index 000000000..8d7398b56 --- /dev/null +++ b/clientmods/mapbot/api.lua @@ -0,0 +1,41 @@ +mapbot.bots = {} + +mapbot.paramtypes = { + ["pos"] = { + ",,", + function (param) + local _, pos = minetest.parse_relative_pos(param) + return pos + end + }, + ["nodes"] = { + " [] ...", + function (param) + return param:split(" ") + end + }, +} + +function mapbot.register_bot(name, description, paramtype, func) + local pt = mapbot.paramtypes[paramtype] + if not pt then return end + minetest.register_chatcommand(name, { + param = pt[1], + description = description .. " Empty parameter to stop.", + func = function(param) + mapbot.storage:set_string(name, param) + return true, "Changed " .. name .. " config." + end + }) + table.insert(mapbot.bots, {name, pt, func}) +end + +function mapbot.loop() + for _, bot in pairs(mapbot.bots) do + local param = mapbot.storage:get_string(bot[1]) + param = (param == "") and nil or bot[2][2](param) + if param and bot[3](param) end + end +end + +minetest.register_on_connect(mapbot.loop) diff --git a/clientmods/mapbot/init.lua b/clientmods/mapbot/init.lua new file mode 100644 index 000000000..4b2a73fe4 --- /dev/null +++ b/clientmods/mapbot/init.lua @@ -0,0 +1,10 @@ +mapbot = {} + +local modname = minetest.get_modname() +local modpath = minetest.get_modpath(modname) +mapbot.storage = minetest.get_mod_storage() + +dofile(modpath .. "/api.lua") +dofile(modpath .. "/simple_bots.lua") + + diff --git a/clientmods/mapbot/mod.conf b/clientmods/mapbot/mod.conf new file mode 100644 index 000000000..63c81f480 --- /dev/null +++ b/clientmods/mapbot/mod.conf @@ -0,0 +1,3 @@ +name = misc +author = Fleckenstein +description = An API to create simple bots, optimized for map interaction diff --git a/clientmods/mapbot/simple_bots.lua b/clientmods/mapbot/simple_bots.lua new file mode 100644 index 000000000..30b44f81b --- /dev/null +++ b/clientmods/mapbot/simple_bots.lua @@ -0,0 +1,30 @@ +mapbot.register_bot("place_into", "Automatically place wielditem into specified nodes.", "nodes", function(nodes) + local pos = minetest.find_node_near(minetest.localplayer:get_pos(), 5, nodes, true) + if pos then + minetest.place_node(pos) + end +end) + +mapbot.register_bot("dig_nodes", "Automatically dig specified nodes.", "nodes", function(nodes) + local pos = minetest.find_node_near(minetest.localplayer:get_pos(), 5, nodes, true) + if pos then + minetest.dig_node(pos) + end +end) + +mapbot.register_bot("place_into_pos", "Automatically place wielditem at specified pos.", "pos", minetest.place_node) + +mapbot.register_bot("dig_pos", "Automatically dig node at specified pos.", "pos", minetest.dig_node) + +mapbot.register_bot("dig_place_nodes", "Automatically dig specified nodes and immediately place wielditem there.", "nodes", function (nodes) + local pos = minetest.find_node_near(minetest.localplayer:get_pos(), 5, nodes, true) + if pos then + minetest.dig_node(pos) + minetest.place_node(pos) + end +end) + +mapbot.register_bot("dig_place_pos", "Automatically dig node at specified pos and immediately place wielditem there.", "pos", function (pos) + minetest.dig_node(pos) + minetest.place_node(pos) +end) 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 = " [,...]", + 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 = ",,", + 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 = ",,", + 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 diff --git a/clientmods/misc/init.lua b/clientmods/misc/init.lua new file mode 100644 index 000000000..7d43f4325 --- /dev/null +++ b/clientmods/misc/init.lua @@ -0,0 +1,2 @@ +minetest.override_item("air", {liquids_pointable = true}) + diff --git a/clientmods/misc/mod.conf b/clientmods/misc/mod.conf new file mode 100644 index 000000000..da48a676b --- /dev/null +++ b/clientmods/misc/mod.conf @@ -0,0 +1,3 @@ +name = misc +author = Fleckenstein +description = Misc cheats diff --git a/clientmods/mods.conf b/clientmods/mods.conf deleted file mode 100644 index 22367f1b9..000000000 --- a/clientmods/mods.conf +++ /dev/null @@ -1,9 +0,0 @@ -load_mod_set = true -load_mod_buildbot = true -load_mod_colour_chat = true -load_mod_custom = true -load_mod_echest = true -load_mod_commands = true -load_mod_test = false -load_mod_destroyliquids = true -load_mod_autofarm = false diff --git a/clientmods/respawn/init.lua b/clientmods/respawn/init.lua new file mode 100644 index 000000000..2a3566684 --- /dev/null +++ b/clientmods/respawn/init.lua @@ -0,0 +1,44 @@ +local warp = warp or {set_here = function() return false end} + +local formspec = "" + .. "size[11,5.5]" + .. "bgcolor[#320000b4;true]" + .. "label[4.85,1.35;" .. "You died" .. "]" + .. "button_exit[2,3;3,0.5;btn_respawn;" .. "Respawn" .. "]" + .. "button_exit[6,3;3,0.5;btn_ghost_mode;" .. "Ghost Mode" .. "]" + .. "set_focus[btn_respawn;true]" + +minetest.register_on_death(function() + local warp_success, warp_msg = warp.set_here("death") + if warp_success then + minetest.display_chat_message(warp_msg) + else + minetest.display_chat_message("You died at " .. minetest.pos_to_string(minetest.localplayer:get_pos()) .. ".") + end + if minetest.settings:get_bool("autorespawn") then + minetest.send_respawn() + else + minetest.show_formspec("respawn:death", formspec) +end) + +minetest.register_on_formspec_input(function(formname, fields) + if formname == "respawn:death" then + if fields.btn_ghost_mode then + minetest.display_chat_message("You are in ghost mode. Use .respawn to Respawn.") + else + minetest.send_respawn() + end + end +end) + +minetest.register_chatcommand("respawn", { + description = "Respawn when in ghost mode", + func = function() + if minetest.localplayer:get_hp() == 0 then + minetest.send_respawn() + minetest.display_chat_message("Respawned.") + else + minetest.display_chat_message("You are not in ghost mode.") + end + end +}) diff --git a/clientmods/respawn/mod.conf b/clientmods/respawn/mod.conf new file mode 100644 index 000000000..8f93a9576 --- /dev/null +++ b/clientmods/respawn/mod.conf @@ -0,0 +1,4 @@ +name = respawn +author = Fleckenstein +description = Extended respawn behaviour +optional_depends = warp diff --git a/clientmods/set/init.lua b/clientmods/set/init.lua deleted file mode 100644 index 7eb1d9d6d..000000000 --- a/clientmods/set/init.lua +++ /dev/null @@ -1,33 +0,0 @@ -core.register_chatcommand("set", { - params = "([-n] ) | ", - description = "Set or read client configuration setting", - privs = {server=true}, - func = function(param) - local arg, setname, setvalue = string.match(param, "(-[n]) ([^ ]+) (.+)") - if arg and arg == "-n" and setname and setvalue then - core.settings:set(setname, setvalue) - return true, setname .. " = " .. setvalue - end - - setname, setvalue = string.match(param, "([^ ]+) (.+)") - if setname and setvalue then - if not core.settings:get(setname) then - return false, "Failed. Use '.set -n ' to create a new setting." - end - core.settings:set(setname, setvalue) - return true, setname .. " = " .. setvalue - end - - setname = string.match(param, "([^ ]+)") - if setname then - setvalue = core.settings:get(setname) - if not setvalue then - setvalue = "" - end - return true, setname .. " = " .. setvalue - end - - return false, "Invalid parameters (see .help set)." - end, -}) - diff --git a/clientmods/test/init.lua b/clientmods/test/init.lua deleted file mode 100644 index 5d7e2285e..000000000 --- a/clientmods/test/init.lua +++ /dev/null @@ -1 +0,0 @@ -minetest.override_item("air", {liquids_pointable = true}) diff --git a/clientmods/warp/init.lua b/clientmods/warp/init.lua new file mode 100644 index 000000000..d74e023c3 --- /dev/null +++ b/clientmods/warp/init.lua @@ -0,0 +1,69 @@ +warp = {} + +local storage = minetest.get_mod_storage() + +function warp.set(warp, pos) + if warp == "" or not pos then return false, "Missing parameter." end + local posstr = minetest.pos_to_string(pos) + storage:set_string(warp, posstr) + return true, "Warp " .. warp .. " set to " .. posstr .. "." +end + +function warp.set_here(param) + local success, message = warp.set(param, vector.round(minetest.localplayer:get_pos())) + return success, message +end + +function warp.get(param) + if param == "" then return false, "Missing parameter." end + local pos = storage:get_string(param) + if pos == "" then return false, "Warp " .. param .. " not set." end + return true, "Warp " .. param .. " is set to " .. pos .. ".", minetest.string_to_pos(pos) +end + +function warp.delete(param) + if param == "" then return false, "Missing parameter." end + storage:set_string(param, "") + return true, "Deleted warp " .. param .. "." +end + +minetest.register_chatcommand("setwarp", { + params = "", + description = "Set a warp to your current position.", + func = warp.set_here, +}) + +minetest.register_chatcommand("readwarp", { + params = "", + description = "Print the coordinates of a warp.", + func = warp.get, +}) + +minetest.register_chatcommand("deletewarp", { + params = "", + description = "Delete a warp.", + func = warp.delete, +}) + +minetest.register_chatcommand("warp", { + params = "|", + description = "Warp to a set warp or a position. " .. (core.anticheat_protection and "You have to be attached for this to work (sitting in a boat or similar) and you will be disconnected and have to rejoin." or ""), + func = function(param) + if param == "" then return false, "Missing parameter." end + local success, pos = minetest.parse_pos(param) + if not success then + local msg + success, msg, pos = warp.get(param) + if not success then + return false, msg + end + end + minetest.localplayer:set_pos(pos) + if core.anticheat_protection then + minetest.disconnect() + end + return true, "Warped to " .. minetest.pos_to_string(pos) + end +}) + + diff --git a/clientmods/warp/mod.conf b/clientmods/warp/mod.conf new file mode 100644 index 000000000..d014d7566 --- /dev/null +++ b/clientmods/warp/mod.conf @@ -0,0 +1,3 @@ +name = warp +author = Fleckenstein +description = Set custom warps and use the teleport exploit -- cgit v1.2.3