diff options
Diffstat (limited to 'builtin/client')
-rw-r--r-- | builtin/client/chatcommands.lua | 133 | ||||
-rw-r--r-- | builtin/client/cheats/chat.lua | 8 | ||||
-rw-r--r-- | builtin/client/cheats/init.lua (renamed from builtin/client/cheats.lua) | 38 | ||||
-rw-r--r-- | builtin/client/cheats/inventory.lua | 117 | ||||
-rw-r--r-- | builtin/client/cheats/movement.lua | 14 | ||||
-rw-r--r-- | builtin/client/cheats/player.lua | 39 | ||||
-rw-r--r-- | builtin/client/cheats/render.lua | 1 | ||||
-rw-r--r-- | builtin/client/cheats/world.lua | 53 | ||||
-rw-r--r-- | builtin/client/init.lua | 2 |
9 files changed, 398 insertions, 7 deletions
diff --git a/builtin/client/chatcommands.lua b/builtin/client/chatcommands.lua index 83b7f7b14..7c3dd521e 100644 --- a/builtin/client/chatcommands.lua +++ b/builtin/client/chatcommands.lua @@ -40,4 +40,137 @@ function core.run_server_chatcommand(cmd, param) core.send_chat_message("/" .. cmd .. " " .. param) end +core.register_chatcommand("say", { + description = "Send raw text", + func = function(text) + core.send_chat_message(text) + return true + end, +}) + +core.register_chatcommand("teleport", { + params = "<X>,<Y>,<Z>", + description = "Teleport to coordinates.", + 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, +}) + +core.register_chatcommand("teleportjump", { + params = "<X>,<Y>,<Z>", + description = "Teleport to relative coordinates.", + func = function(param) + local success, pos = core.parse_relative_pos(param) + if success then + core.localplayer:set_pos(pos) + return true, "Teleporting to " .. core.pos_to_string(pos) + end + return false, pos + end, +}) + +core.register_chatcommand("wielded", { + description = "Print itemstring of wieleded item", + func = function() + return true, core.localplayer:get_wielded_item():get_name() + end +}) + +core.register_chatcommand("disconnect", { + description = "Exit to main menu", + func = function(param) + core.disconnect() + end, +}) + +core.register_chatcommand("players", { + description = "List online players", + func = function(param) + return true, "Online players: " .. table.concat(core.get_player_names(), ", ") + end +}) + +core.register_chatcommand("kill", { + description = "Kill yourself", + func = function() + core.send_damage(10000) + end, +}) +core.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 + 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, +}) + +core.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, +}) + +core.register_chatcommand("place", { + params = "<X>,<Y>,<Z>", + description = "Place wielded item", + func = function(param) + local success, pos = core.parse_relative_pos(param) + if success then + cores.place_node(pos) + return true, "Node placed at " .. core.pos_to_string(pos) + end + return false, pos + end, +}) + +core.register_chatcommand("dig", { + params = "<X>,<Y>,<Z>", + description = "Dig node", + func = function(param) + local success, pos = core.parse_relative_pos(param) + if success then + core.dig_node(pos) + return true, "Node at " .. core.pos_to_string(pos) .. " dug" + end + return false, pos + end, +}) diff --git a/builtin/client/cheats/chat.lua b/builtin/client/cheats/chat.lua new file mode 100644 index 000000000..1b8094768 --- /dev/null +++ b/builtin/client/cheats/chat.lua @@ -0,0 +1,8 @@ +core.register_on_receiving_chat_message(function(message) + if message:sub(1, 1) == "#" and core.settings:get_bool("ignore_status_messages") ~= false then + return true + elseif message:find('\1b@mcl_death_messages\1b') and core.settings:get_bool("mark_deathmessages") ~= false then + core.display_chat_message(core.colorize("#F25819", "[Deathmessage] ") .. message) + return true + end +end) diff --git a/builtin/client/cheats.lua b/builtin/client/cheats/init.lua index 800784597..9eb2594a0 100644 --- a/builtin/client/cheats.lua +++ b/builtin/client/cheats/init.lua @@ -3,16 +3,16 @@ core.cheats = { ["Killaura"] = "killaura", ["AntiKnockback"] = "antiknockback", ["FastHit"] = "spamclick", + ["AttachmentFloat"] = "float_above_parent", }, ["Movement"] = { ["Freecam"] = "freecam", - ["PrivBypass"] = "priv_bypass", ["AutoForward"] = "continuous_forward", ["PitchMove"] = "pitch_move", ["AutoJump"] = "autojump", ["Jesus"] = "jesus", ["NoSlow"] = "no_slow", - + ["AutoSneak"] = "autosneak", }, ["Render"] = { ["Xray"] = "xray", @@ -23,7 +23,6 @@ core.cheats = { ["Coords"] = "coords", ["Tracers"] = "enable_tracers", ["ESP"] = "enable_esp", - ["AttachmentFloat"] = "float_above_parent", }, ["World"] = { ["FastDig"] = "fastdig", @@ -31,9 +30,11 @@ core.cheats = { ["AutoDig"] = "autodig", ["AutoPlace"] = "autoplace", ["InstantBreak"] = "instant_break", - ["IncreasedRange"] = "increase_tool_range", - ["UnlimitedRange"] = "increase_tool_range_plus", - ["PointLiquids"] = "point_liquids", + ["Scaffold"] = "scaffold", + ["ScaffoldPlus"] = "scaffold_plus", + ["BlockWater"] = "block_water", + ["PlaceOnTop"] = "autotnt", + ["Replace"] = "replace" }, ["Exploit"] = { ["EntitySpeed"] = "entity_speed", @@ -42,10 +43,35 @@ core.cheats = { ["Player"] = { ["NoFallDamage"] = "prevent_natural_damage", ["NoForceRotate"] = "no_force_rotate", + ["IncreasedRange"] = "increase_tool_range", + ["UnlimitedRange"] = "increase_tool_range_plus", + ["PointLiquids"] = "point_liquids", + ["PrivBypass"] = "priv_bypass", + ["AutoRespawn"] = "autorespawn", }, + ["Chat"] = { + ["IgnoreStatus"] = "ignore_status_messages", + ["Deathmessages"] = "mark_deathmessages" + }, + ["Inventory"] = { + ["AutoEject"] = "autoeject", + ["AutoTool"] = "autotool", + ["Enderchest"] = function() core.open_enderchest() end, + ["HandSlot"] = function() core.open_handslot() end, + ["NextItem"] = "next_item", + } } function core.register_cheat(cheatname, category, func) core.cheats[category] = core.cheats[category] or {} core.cheats[category][cheatname] = func end + +local cheatpath = core.get_builtin_path() .. "client" .. DIR_DELIM .. "cheats" .. DIR_DELIM + +dofile(cheatpath .. "chat.lua") +dofile(cheatpath .. "inventory.lua") +dofile(cheatpath .. "movement.lua") +dofile(cheatpath .. "player.lua") +dofile(cheatpath .. "render.lua") +dofile(cheatpath .. "world.lua") diff --git a/builtin/client/cheats/inventory.lua b/builtin/client/cheats/inventory.lua new file mode 100644 index 000000000..d12052d7c --- /dev/null +++ b/builtin/client/cheats/inventory.lua @@ -0,0 +1,117 @@ +local elapsed_time = 0 +local tick_time = 0.05 + +core.register_globalstep(function(dtime) + -- AutoEject + if core.settings:get_bool("autoeject") then + local player = core.localplayer + local list = (core.settings:get("eject_items") or ""):split(",") + local inventory = core.get_inventory("current_player") + for index, stack in pairs(inventory.main) do + if table.indexof(list, stack:get_name()) ~= -1 then + local old_index = player:get_wield_index() + player:set_wield_index(index - 1) + core.drop_selected_item() + player:set_wield_index(old_index) + return + end + end + end + -- NextItem + if core.settings:get_bool("next_item") then + elapsed_time = elapsed_time + dtime + if elapsed_time < tick_time then return end + local player = minetest.localplayer + if not player then return end + local item = player:get_wielded_item() + if item:get_count() == 0 then + local index = player:get_wield_index() + player:set_wield_index(index + 1) + end + elapsed_time = 0 + end +end) + +core.register_list_command("eject", "Configure AutoEject", "eject_items") + +-- AutoTool + +local function check_tool(stack, node_groups, old_best_time) + local toolcaps = stack:get_tool_capabilities() + if not toolcaps then return end + local best_time = old_best_time + for group, groupdef in pairs(toolcaps.groupcaps) do + local level = node_groups[group] + if level then + local this_time = groupdef.times[level] + if this_time < best_time then + best_time = this_time + end + end + end + return best_time < old_best_time, best_time +end + +core.register_on_punchnode(function(pos, node) + if not minetest.settings:get_bool("autotool") then return end + local player = minetest.localplayer + local inventory = minetest.get_inventory("current_player") + local node_groups = minetest.get_node_def(node.name).groups + local new_index = player:get_wield_index() + local is_better, best_time = false, math.huge + is_better, best_time = check_tool(player:get_wielded_item(), node_groups, best_time) + is_better, best_time = check_tool(inventory.hand[1], node_groups, best_time) + for index, stack in pairs(inventory.main) do + is_better, best_time = check_tool(stack, node_groups, best_time) + if is_better then + new_index = index - 1 + end + end + player:set_wield_index(new_index) +end) + +-- Enderchest + +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 enderchest_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 core.open_enderchest() + core.show_formspec("__builtin__:enderchest", enderchest_formspec) +end + +-- HandSlot + +local hand_formspec = "size[9,8.75]".. + "label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", "Hand")).."]".. + "list[current_player;hand;0,0.5;1,1;]".. + get_itemslot_bg(0,0.5,1,1).. + "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;hand]".. + "listring[current_player;main]" + +function core.open_handslot() + minetest.show_formspec("__builtin__:hand", hand_formspec) +end diff --git a/builtin/client/cheats/movement.lua b/builtin/client/cheats/movement.lua new file mode 100644 index 000000000..bd9b995ad --- /dev/null +++ b/builtin/client/cheats/movement.lua @@ -0,0 +1,14 @@ +-- autosneak + +local autosneak_was_enabled = false + +core.register_globalstep(function() + if core.settings:get_bool("autosneak") then + core.set_keypress("sneak", true) + autosneak_was_enabled = true + elseif autosneak_was_enabled then + autosneak_was_enabled = false + core.set_keypress("sneak", false) + end +end) + diff --git a/builtin/client/cheats/player.lua b/builtin/client/cheats/player.lua new file mode 100644 index 000000000..499ed47f3 --- /dev/null +++ b/builtin/client/cheats/player.lua @@ -0,0 +1,39 @@ +local death_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]" + +core.register_on_death(function() + core.display_chat_message("You died at " .. core.pos_to_string(vector.round(core.localplayer:get_pos())) .. ".") + if core.settings:get_bool("autorespawn") then + core.send_respawn() + else + core.show_formspec("__builtin__:death", death_formspec) + end +end) + +core.register_on_formspec_input(function(formname, fields) + if formname == "__builtin__: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 = "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/cheats/render.lua b/builtin/client/cheats/render.lua new file mode 100644 index 000000000..092c7fefc --- /dev/null +++ b/builtin/client/cheats/render.lua @@ -0,0 +1 @@ +core.register_list_command("xray", "Configure X-Ray", "xray_nodes") diff --git a/builtin/client/cheats/world.lua b/builtin/client/cheats/world.lua new file mode 100644 index 000000000..5b97b206b --- /dev/null +++ b/builtin/client/cheats/world.lua @@ -0,0 +1,53 @@ +core.register_on_dignode(function(pos) + if core.settings:get_bool("replace") then + core.after(0, minetest.place_node, pos) + end +end) + +local etime = 0 + +core.register_globalstep(function(dtime) + etime = etime + dtime + if etime < 1 then return end + local player = core.localplayer + if not player then return end + local pos = player:get_pos() + local item = player:get_wielded_item() + local def = core.get_item_def(item:get_name()) + local nodes_per_tick = tonumber(minetest.settings:get("nodes_per_tick")) or 8 + if item and item:get_count() > 0 and def and def.node_placement_prediction ~= "" then + if core.settings:get_bool("scaffold") then + core.place_node(vector.add(pos, {x = 0, y = -0.6, z = 0})) + elseif core.settings:get_bool("scaffold_plus") then + local z = pos.z + local positions = { + {x = 0, y = -0.6, z = 0}, + {x = 1, y = -0.6, z = 0}, + {x = -1, y = -0.6, z = 0}, + {x = -1, y = -0.6, z = -1}, + {x = 0, y = -0.6, z = -1}, + {x = 1, y = -0.6, z = -1}, + {x = -1, y = -0.6, z = 1}, + {x = 0, y = -0.6, z = 1}, + {x = 1, y = -0.6, z = 1} + } + for i, p in pairs(positions) do + core.place_node(vector.add(pos, p)) + end + elseif core.settings:get_bool("block_water") then + local positions = core.find_nodes_near(pos, 5, {"mcl_core:water_source", "mcl_core:water_floating"}, true) + for i, p in pairs(positions) do + if i > nodes_per_tick then return end + core.place_node(p) + end + elseif core.settings:get_bool("autotnt") then + local positions = core.find_nodes_near_under_air_except(pos, 5, item:get_name(), true) + for i, p in pairs(positions) do + if i > nodes_per_tick then return end + core.place_node(vector.add(p, {x = 0, y = 1, z = 0})) + end + end + end +end) + + diff --git a/builtin/client/init.lua b/builtin/client/init.lua index 44703a57c..40acf3b9b 100644 --- a/builtin/client/init.lua +++ b/builtin/client/init.lua @@ -9,5 +9,5 @@ dofile(commonpath .. "chatcommands.lua") dofile(commonpath .. "vector.lua") dofile(clientpath .. "util.lua") dofile(clientpath .. "chatcommands.lua") -dofile(clientpath .. "cheats.lua") +dofile(clientpath .. "cheats"..DIR_DELIM.."init.lua") |