diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-07-18 13:20:08 +0200 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-07-18 13:20:08 +0200 |
commit | 45aa2516b2fc675df7049bc9ed713600c95b6423 (patch) | |
tree | cd7d1f377789e56cfe624d8db542f32c7dd0bca4 | |
parent | f22339ed891afddca53f7442c63aedd7aecc566d (diff) | |
download | dragonfireclient-45aa2516b2fc675df7049bc9ed713600c95b6423.tar.xz |
Added settings
34 files changed, 509 insertions, 441 deletions
diff --git a/.gitignore b/.gitignore index 6b2561ac5..0f47efafa 100644 --- a/.gitignore +++ b/.gitignore @@ -48,8 +48,6 @@ gtags.files !/mods/minetest/mods_here.txt /worlds /world/ -/clientmods/custom -!/clientmods/preview/ /client/mod_storage/ ## Configuration/log files diff --git a/builtin/client/chatcommands.lua b/builtin/client/chatcommands.lua index f514f754b..83b7f7b14 100644 --- a/builtin/client/chatcommands.lua +++ b/builtin/client/chatcommands.lua @@ -1,6 +1,5 @@ -- Minetest: builtin/client/chatcommands.lua - core.register_on_sending_chat_message(function(message) if message:sub(1,2) == ".." then return false @@ -37,34 +36,8 @@ core.register_on_sending_chat_message(function(message) return true end) -core.register_chatcommand("players", { - description = core.gettext("List online players"), - func = function(param) - local player_names = core.get_player_names() - if not player_names then - return false, core.gettext("This command is disabled by server.") - end - - local players = table.concat(player_names, ", ") - return true, core.gettext("Online players: ") .. players - end -}) - -core.register_chatcommand("disconnect", { - description = core.gettext("Exit to main menu"), - func = function(param) - core.disconnect() - end, -}) - -core.register_chatcommand("clear_chat_queue", { - description = core.gettext("Clear the out chat queue"), - func = function(param) - core.clear_out_chat_queue() - return true, core.gettext("The out chat queue is now empty") - end, -}) - function core.run_server_chatcommand(cmd, param) core.send_chat_message("/" .. cmd .. " " .. param) end + + diff --git a/builtin/client/death_formspec.lua b/builtin/client/death_formspec.lua deleted file mode 100644 index 0a4a98ea3..000000000 --- a/builtin/client/death_formspec.lua +++ /dev/null @@ -1,33 +0,0 @@ --- CSM death formspec. Only used when clientside modding is enabled, otherwise --- handled by the engine. - -core.register_on_death(function() - core.display_chat_message("You died.") - local formspec = "size[11,5.5]bgcolor[#320000b4;true]" .. - "label[4.85,1.35;" .. fgettext("You died") .. - "]button_exit[2,3;3,0.5;btn_respawn;".. fgettext("Respawn") .. - "]button_exit[6,3;3,0.5;btn_ghost_mode;".. fgettext("Ghost Mode") .."]" - core.show_formspec("bultin:death", formspec) -end) - -core.register_on_formspec_input(function(formname, fields) - if formname == "bultin:death" then - if fields.btn_ghost_mode then - core.display_chat_message("You are in ghost mode. Use .respawn to Respawn") - else - core.send_respawn() - end - end -end) - -core.register_chatcommand("respawn", { - description = core.gettext("Respawn when in ghost mode"), - func = function() - if core.localplayer:get_hp() == 0 then - core.send_respawn() - core.display_chat_message("Respawned.") - else - core.display_chat_message("You are not in ghost mode.") - end - end -}) diff --git a/builtin/client/init.lua b/builtin/client/init.lua index f3c1a4c82..ee344e7bc 100644 --- a/builtin/client/init.lua +++ b/builtin/client/init.lua @@ -7,7 +7,6 @@ dofile(clientpath .. "register.lua") dofile(commonpath .. "after.lua") dofile(commonpath .. "chatcommands.lua") dofile(commonpath .. "vector.lua") -dofile(clientpath .. "death_formspec.lua") +dofile(clientpath .. "util.lua") dofile(clientpath .. "chatcommands.lua") -dofile(clientpath .. "pos.lua") diff --git a/builtin/client/pos.lua b/builtin/client/util.lua index 618c142e7..595922262 100644 --- a/builtin/client/pos.lua +++ b/builtin/client/util.lua @@ -3,17 +3,21 @@ function core.parse_pos(param) p.x, p.y, p.z = string.match(param, "^([~|%d.-]+)[, ] *([~|%d.-]+)[, ] *([~|%d.-]+)$") for k, v in pairs(p) do if p[k] == "~" then - p[k] = core.localplayer:get_pos()[k] + p[k] = 0 else p[k] = tonumber(v) end end if p.x and p.y and p.z then - local lm = 31000 - if p.x < -lm or p.x > lm or p.y < -lm or p.y > lm or p.z < -lm or p.z > lm then - return false, "Position out of Map bounds." - end return true, p end return false, "Invalid position (" .. param .. ")" end + +function core.parse_relative_pos(param) + local success, pos = core.parse_pos(param) + if success then pos = vector.round(vector.add(core.localplayer:get_pos(), pos)) end + return success, pos +end + +core.anticheat_protection = minetest.settings:get_bool("anticheat_protection") diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 4137625cc..1f48a7a13 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -2138,26 +2138,37 @@ contentdb_flag_blacklist (ContentDB Flag Blacklist) string nonfree, desktop_defa [Cheats] -fullbright (Enable fullbright) bool false +fullbright (Fullbright) bool false -xray (Enable xray, requires fullbright) bool false +# Enable xray, requires fullbright +xray (Xray) bool false -xray_node (Texture to apply xray) string default:stone +# Texture to apply xray +xray_node (XrayTexture) string default:stone -priv_bypass (Make the Client think it has all privs) bool true +# Make the Client think it has all privs +priv_bypass (PrivBypass) bool true -fastdig (Fast Dig) bool false +fastdig (FastDig) bool false -prevent_natural_damage (Prevent Fall Damage) bool true +prevent_natural_damage (NoFallDamage) bool true -freecam (Move around freely) bool false +freecam (Freecam) bool false -killaura (Enable Killaura) bool false +killaura (Killaura) bool false -no_hurt_cam (No Hurt Cam) bool false +no_hurt_cam (NoHurtCam) bool false -increase_tool_range (Increase Tool Range) bool true +increase_tool_range (Range) bool true -hud_flags_bypass (Enable HUD Flags Bypass) bool true +# HUD Flags Bypass +hud_flags_bypass (HUDBypass) bool true -antiknockback (Anti Knockback) bool false +antiknockback (AntiKnockback) bool false + +# Set to true if AntiCheat is enabled on server +anticheat_protection (AnticheatProtection) bool true + +autorespawn (AutoRespawn) bool false + +show_cheat_hud (CheatHUD) bool true 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 = "<X>,<Y>,<Z>", - 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 = "<node1> [<node2>] ...", - 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/colour_chat/LICENSE b/clientmods/colorchat/LICENSE index 93f5629ca..93f5629ca 100644 --- a/clientmods/colour_chat/LICENSE +++ b/clientmods/colorchat/LICENSE 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/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 = "<X>,<Y>,<Z>", - 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 = "<X>,<Y>,<Z>", - 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 = "<radius> 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 = "<X>,<Y>,<Z>", - 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 = "<X>,<Y>,<Z>", - description = "Teleport to position and log out immediately", +minetest.register_chatcommand("set", { + params = "([-n] <name> <value>) | <name>", + 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 <name> <value>' 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 = "<not set>" + 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/enderchest/init.lua index ad7e4c9e9..458854d05 100644 --- a/clientmods/echest/init.lua +++ b/clientmods/enderchest/init.lua @@ -1,4 +1,3 @@ - function get_itemslot_bg(x, y, w, h) local out = "" for i = 0, w - 1, 1 do @@ -9,7 +8,7 @@ function get_itemslot_bg(x, y, w, h) return out end -local formspec_ender_chest = "size[9,8.75]".. +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).. @@ -21,8 +20,6 @@ local formspec_ender_chest = "size[9,8.75]".. "listring[current_player;enderchest]".. "listring[current_player;main]" -minetest.register_chatcommand("echest", { - func = function() - minetest.show_formspec("echest:enderchest", formspec_ender_chest) - end -}) +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"] = { + "<X>,<Y>,<Z>", + function (param) + local _, pos = minetest.parse_relative_pos(param) + return pos + end + }, + ["nodes"] = { + "<node1> [<node2>] ...", + 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 = "<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 diff --git a/clientmods/test/init.lua b/clientmods/misc/init.lua index 5d7e2285e..7d43f4325 100644 --- a/clientmods/test/init.lua +++ b/clientmods/misc/init.lua @@ -1 +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] <name> <value>) | <name>", - 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 <name> <value>' 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 = "<not set>" - end - return true, setname .. " = " .. setvalue - end - - return false, "Invalid parameters (see .help set)." - end, -}) - 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 = "<warp>", + description = "Set a warp to your current position.", + func = warp.set_here, +}) + +minetest.register_chatcommand("readwarp", { + params = "<warp>", + description = "Print the coordinates of a warp.", + func = warp.get, +}) + +minetest.register_chatcommand("deletewarp", { + params = "<warp>", + description = "Delete a warp.", + func = warp.delete, +}) + +minetest.register_chatcommand("warp", { + params = "<pos>|<warp>", + 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 |