diff options
Diffstat (limited to 'clientmods')
-rw-r--r-- | clientmods/colorchat/LICENSE | 21 | ||||
-rw-r--r-- | clientmods/colorchat/init.lua | 91 | ||||
-rw-r--r-- | clientmods/colorchat/mod.conf | 3 | ||||
-rw-r--r-- | clientmods/commands/init.lua | 81 | ||||
-rw-r--r-- | clientmods/commands/mod.conf | 3 | ||||
-rw-r--r-- | clientmods/enderchest/init.lua | 25 | ||||
-rw-r--r-- | clientmods/enderchest/mod.conf | 3 | ||||
-rw-r--r-- | clientmods/mapbot/api.lua | 41 | ||||
-rw-r--r-- | clientmods/mapbot/init.lua | 10 | ||||
-rw-r--r-- | clientmods/mapbot/mod.conf | 3 | ||||
-rw-r--r-- | clientmods/mapbot/simple_bots.lua | 30 | ||||
-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 | ||||
-rw-r--r-- | clientmods/misc/init.lua | 2 | ||||
-rw-r--r-- | clientmods/misc/mod.conf | 3 | ||||
-rw-r--r-- | clientmods/preview/example.lua | 2 | ||||
-rw-r--r-- | clientmods/preview/examples/first.lua | 1 | ||||
-rw-r--r-- | clientmods/preview/init.lua | 199 | ||||
-rw-r--r-- | clientmods/respawn/init.lua | 44 | ||||
-rw-r--r-- | clientmods/respawn/mod.conf | 4 | ||||
-rw-r--r-- | clientmods/warp/init.lua | 69 | ||||
-rw-r--r-- | clientmods/warp/mod.conf | 3 |
24 files changed, 543 insertions, 202 deletions
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/commands/init.lua b/clientmods/commands/init.lua new file mode 100644 index 000000000..4ea8d04f6 --- /dev/null +++ b/clientmods/commands/init.lua @@ -0,0 +1,81 @@ +minetest.register_chatcommand("say", { + description = "Send raw text", + func = function(text) + minetest.send_chat_message(text) + return true + end, +}) + +minetest.register_chatcommand("teleport", { + params = "<X>,<Y>,<Z>", + 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.localplayer:set_pos(pos) + return true, "Teleporting to " .. core.pos_to_string(pos) + end + return false, pos + end, +}) + +minetest.register_chatcommand("wielded", { + description = "Print itemstring of wieleded item", + func = function() + return true, minetest.get_wielded_item():get_name() + end +}) + +minetest.register_chatcommand("disconnect", { + description = "Exit to main menu", + func = function(param) + minetest.disconnect() + end, +}) + +minetest.register_chatcommand("players", { + description = "List online players", + func = function(param) + return true, "Online players: " .. table.concat(minetest.get_player_names(), ", ") + end +}) + +minetest.register_chatcommand("kill", { + description = "Kill yourself", + func = function() + minetest.send_damage(minetest.localplayer:get_hp()) + end, +}) + +minetest.register_chatcommand("set", { + params = "([-n] <name> <value>) | <name>", + description = "Set or read client configuration setting", + func = function(param) + 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 + + 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/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"] = { + "<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/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/preview/example.lua b/clientmods/preview/example.lua deleted file mode 100644 index 2f42eef64..000000000 --- a/clientmods/preview/example.lua +++ /dev/null @@ -1,2 +0,0 @@ -print("Loaded example file!, loading more examples") -dofile(core.get_modpath(core.get_current_modname()) .. "/examples/first.lua") diff --git a/clientmods/preview/examples/first.lua b/clientmods/preview/examples/first.lua deleted file mode 100644 index c24f461e6..000000000 --- a/clientmods/preview/examples/first.lua +++ /dev/null @@ -1 +0,0 @@ -print("loaded first.lua example file") diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua deleted file mode 100644 index 089955d2f..000000000 --- a/clientmods/preview/init.lua +++ /dev/null @@ -1,199 +0,0 @@ -local modname = assert(core.get_current_modname()) -local modstorage = core.get_mod_storage() -local mod_channel - -dofile(core.get_modpath(modname) .. "example.lua") - -core.register_on_shutdown(function() - print("[PREVIEW] shutdown client") -end) -local id = nil - -do - local server_info = core.get_server_info() - print("Server version: " .. server_info.protocol_version) - print("Server ip: " .. server_info.ip) - print("Server address: " .. server_info.address) - print("Server port: " .. server_info.port) - - print("CSM restrictions: " .. dump(core.get_csm_restrictions())) - - local l1, l2 = core.get_language() - print("Configured language: " .. l1 .. " / " .. l2) -end - -mod_channel = core.mod_channel_join("experimental_preview") - -core.after(4, function() - if mod_channel:is_writeable() then - mod_channel:send_all("preview talk to experimental") - end -end) - -core.after(1, function() - print("armor: " .. dump(core.localplayer:get_armor_groups())) - id = core.localplayer:hud_add({ - hud_elem_type = "text", - name = "example", - number = 0xff0000, - position = {x=0, y=1}, - offset = {x=8, y=-8}, - text = "You are using the preview mod", - scale = {x=200, y=60}, - alignment = {x=1, y=-1}, - }) -end) - -core.register_on_modchannel_message(function(channel, sender, message) - print("[PREVIEW][modchannels] Received message `" .. message .. "` on channel `" - .. channel .. "` from sender `" .. sender .. "`") - core.after(1, function() - mod_channel:send_all("CSM preview received " .. message) - end) -end) - -core.register_on_modchannel_signal(function(channel, signal) - print("[PREVIEW][modchannels] Received signal id `" .. signal .. "` on channel `" - .. channel) -end) - -core.register_on_inventory_open(function(inventory) - print("INVENTORY OPEN") - print(dump(inventory)) - return false -end) - -core.register_on_placenode(function(pointed_thing, node) - print("The local player place a node!") - print("pointed_thing :" .. dump(pointed_thing)) - print("node placed :" .. dump(node)) - return false -end) - -core.register_on_item_use(function(itemstack, pointed_thing) - print("The local player used an item!") - print("pointed_thing :" .. dump(pointed_thing)) - print("item = " .. itemstack:get_name()) - - if not itemstack:is_empty() then - return false - end - - local pos = core.camera:get_pos() - local pos2 = vector.add(pos, vector.multiply(core.camera:get_look_dir(), 100)) - - local rc = core.raycast(pos, pos2) - local i = rc:next() - print("[PREVIEW] raycast next: " .. dump(i)) - if i then - print("[PREVIEW] line of sight: " .. (core.line_of_sight(pos, i.above) and "yes" or "no")) - - local n1 = core.find_nodes_in_area(pos, i.under, {"default:stone"}) - local n2 = core.find_nodes_in_area_under_air(pos, i.under, {"default:stone"}) - print(("[PREVIEW] found %s nodes, %s nodes under air"):format( - n1 and #n1 or "?", n2 and #n2 or "?")) - end - - return false -end) - --- This is an example function to ensure it's working properly, should be removed before merge -core.register_on_receiving_chat_message(function(message) - print("[PREVIEW] Received message " .. message) - return false -end) - --- This is an example function to ensure it's working properly, should be removed before merge -core.register_on_sending_chat_message(function(message) - print("[PREVIEW] Sending message " .. message) - return false -end) - --- This is an example function to ensure it's working properly, should be removed before merge -core.register_on_hp_modification(function(hp) - print("[PREVIEW] HP modified " .. hp) -end) - --- This is an example function to ensure it's working properly, should be removed before merge -core.register_on_damage_taken(function(hp) - print("[PREVIEW] Damage taken " .. hp) -end) - --- This is an example function to ensure it's working properly, should be removed before merge -core.register_chatcommand("dump", { - func = function(param) - return true, dump(_G) - end, -}) - -local function preview_minimap() - local minimap = core.ui.minimap - if not minimap then - print("[PREVIEW] Minimap is disabled. Skipping.") - return - end - minimap:set_mode(4) - minimap:show() - minimap:set_pos({x=5, y=50, z=5}) - minimap:set_shape(math.random(0, 1)) - - print("[PREVIEW] Minimap: mode => " .. dump(minimap:get_mode()) .. - " position => " .. dump(minimap:get_pos()) .. - " angle => " .. dump(minimap:get_angle())) -end - -core.after(2, function() - print("[PREVIEW] loaded " .. modname .. " mod") - modstorage:set_string("current_mod", modname) - assert(modstorage:get_string("current_mod") == modname) - preview_minimap() -end) - -core.after(5, function() - if core.ui.minimap then - core.ui.minimap:show() - end - - print("[PREVIEW] Time of day " .. core.get_timeofday()) - - print("[PREVIEW] Node level: " .. core.get_node_level({x=0, y=20, z=0}) .. - " max level " .. core.get_node_max_level({x=0, y=20, z=0})) - - print("[PREVIEW] Find node near: " .. dump(core.find_node_near({x=0, y=20, z=0}, 10, - {"group:tree", "default:dirt", "default:stone"}))) -end) - -core.register_on_dignode(function(pos, node) - print("The local player dug a node!") - print("pos:" .. dump(pos)) - print("node:" .. dump(node)) - return false -end) - -core.register_on_punchnode(function(pos, node) - print("The local player punched a node!") - local itemstack = core.localplayer:get_wielded_item() - print(dump(itemstack:to_table())) - print("pos:" .. dump(pos)) - print("node:" .. dump(node)) - local meta = core.get_meta(pos) - print("punched meta: " .. (meta and dump(meta:to_table()) or "(missing)")) - return false -end) - -core.register_chatcommand("privs", { - func = function(param) - return true, core.privs_to_string(minetest.get_privilege_list()) - end, -}) - -core.register_chatcommand("text", { - func = function(param) - return core.localplayer:hud_change(id, "text", param) - end, -}) - - -core.register_on_mods_loaded(function() - core.log("Yeah preview mod is loaded with other CSM mods.") -end) 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/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 |