diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-10-17 11:11:22 +0200 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-10-17 11:11:22 +0200 |
commit | bbcd2495444225fd16f61f8a830185ed5b8cf77f (patch) | |
tree | adbf984c13414abd959b23022ca8b8f5a0916972 /builtin | |
parent | 80f416d51449ffc6907f7e2b6d1ef935abee5611 (diff) | |
download | dragonfireclient-bbcd2495444225fd16f61f8a830185ed5b8cf77f.tar.xz |
New Mod System
Diffstat (limited to 'builtin')
-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 | ||||
-rw-r--r-- | builtin/common/chatcommands.lua | 43 | ||||
-rw-r--r-- | builtin/common/misc_helpers.lua | 61 | ||||
-rw-r--r-- | builtin/mainmenu/tab_credits.lua | 6 | ||||
-rw-r--r-- | builtin/settingtypes.txt | 34 |
13 files changed, 534 insertions, 15 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") diff --git a/builtin/common/chatcommands.lua b/builtin/common/chatcommands.lua index 52edda659..3d04391fb 100644 --- a/builtin/common/chatcommands.lua +++ b/builtin/common/chatcommands.lua @@ -29,6 +29,49 @@ function core.override_chatcommand(name, redefinition) core.registered_chatcommands[name] = chatcommand end +function core.register_list_command(command, desc, setting) + local def = {} + def.description = desc + def.params = "del <item> | add <item> | list" + function def.func(param) + local list = (minetest.settings:get(setting) or ""):split(",") + if param == "list" then + return true, table.concat(list, ", ") + else + local sparam = param:split(" ") + local cmd = sparam[1] + local item = sparam[2] + if cmd == "del" then + if not item then + return false, "Missing item." + end + local i = table.indexof(list, item) + if i == -1 then + return false, item .. " is not on the list." + else + table.remove(list, i) + core.settings:set(setting, table.concat(list, ",")) + return true, "Removed " .. item .. " from the list." + end + elseif cmd == "add" then + if not item then + return false, "Missing item." + end + local i = table.indexof(list, item) + if i ~= -1 then + return false, item .. " is already on the list." + else + table.insert(list, item) + core.settings:set(setting, table.concat(list, ",")) + return true, "Added " .. item .. " to the list." + end + end + end + return false, "Invalid usage. (See /help " .. command .. ")" + end + core.register_chatcommand(command, def) +end + local cmd_marker = "/" local function gettext(...) diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua index bd27a01dc..f6ceda54d 100644 --- a/builtin/common/misc_helpers.lua +++ b/builtin/common/misc_helpers.lua @@ -594,6 +594,67 @@ function core.colorize(color, message) return table.concat(lines, "\n") .. core.get_color_escape_sequence("#ffffff") 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 + +function core.rainbow(input) + local step = 360 / input:len() + local hue = 0 + local output = "" + for i = 1, input:len() do + local char = input: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 + return output +end function core.strip_foreground_colors(str) return (str:gsub(ESCAPE_CHAR .. "%(c@[^)]+%)", "")) diff --git a/builtin/mainmenu/tab_credits.lua b/builtin/mainmenu/tab_credits.lua index c568eddb5..4f9f835f7 100644 --- a/builtin/mainmenu/tab_credits.lua +++ b/builtin/mainmenu/tab_credits.lua @@ -17,8 +17,10 @@ -------------------------------------------------------------------------------- local dragonfire_team = { - "Elias Fleckenstein <eliasfleckenstein@web.de> [Main Developer]", - "DerZombiiie [Bots, User Support]", + "Elias Fleckenstein", + "cora", + "system32", + "DerZombiiie", } local core_developers = { diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index a4991cb94..13603c726 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -2217,13 +2217,10 @@ contentdb_flag_blacklist (ContentDB Flag Blacklist) string nonfree, desktop_defa fullbright (Fullbright) bool false -# Enable xray, requires fullbright -xray (X-Ray) bool false +xray (XRay) bool false -# Node to apply xray -xray_node (X-RayTexture) string default:stone +xray_nodes (XRay Nodes) string default:stone,mcl_core:stone -# Make the Client think it has all privs priv_bypass (PrivBypass) bool true fastdig (FastDig) bool false @@ -2246,7 +2243,6 @@ increase_tool_range (IncreasedRange) bool true increase_tool_range_plus (IncreasedRangePlus) bool true -# HUD Flags Bypass hud_flags_bypass (HUDBypass) bool true antiknockback (AntiKnockback) bool false @@ -2274,3 +2270,29 @@ enable_tracers (Tracers) bool false enable_esp (ESP) bool false no_slow (NoSlow) bool false + +ignore_status_messages (IgnoreStatus) bool true + +mark_deathmessages (Deathmessages) bool true + +autosneak (AutoSneak) bool false + +autoeject (AutoEject) bool false + +eject_items (AutoEject Items) string + +autotool (AutoTool) bool false + +autorespawn (AutoRespawn) bool false + +next_item (NextItem) bool false + +scaffold (Scaffold) bool false + +scaffold_plus (ScaffoldPlus) bool false + +block_water (BlockWater) bool false + +autotnt (PlaceOnTop) bool false + +replace (Replace) bool false |