]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
UI Update; Added AutoTool
authorElias Fleckenstein <eliasfleckenstein@web.de>
Sat, 15 Aug 2020 13:45:28 +0000 (15:45 +0200)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Sat, 15 Aug 2020 13:45:28 +0000 (15:45 +0200)
27 files changed:
builtin/client/cheats.lua
clientmods/chat/init.lua [new file with mode: 0644]
clientmods/chat/rainbow.lua [new file with mode: 0644]
clientmods/colorchat/LICENSE [deleted file]
clientmods/colorchat/init.lua [deleted file]
clientmods/colorchat/mod.conf [deleted file]
clientmods/enderchest/init.lua [deleted file]
clientmods/enderchest/mod.conf [deleted file]
clientmods/inventory/enderchest.lua [new file with mode: 0644]
clientmods/inventory/init.lua [new file with mode: 0644]
clientmods/inventory/invhack.lua [new file with mode: 0644]
clientmods/mapbot/api.lua [deleted file]
clientmods/mapbot/init.lua [deleted file]
clientmods/mapbot/mod.conf [deleted file]
clientmods/mapbot/simple_bots.lua [deleted file]
clientmods/maputil/buildbot.lua [deleted file]
clientmods/maputil/commands.lua [deleted file]
clientmods/maputil/init.lua [deleted file]
clientmods/maputil/mod.conf [deleted file]
clientmods/misc/init.lua [deleted file]
clientmods/misc/mod.conf [deleted file]
clientmods/mods.conf
clientmods/world/init.lua [new file with mode: 0644]
clientmods/worldhacks/init.lua [deleted file]
src/client/game.cpp
src/script/lua_api/l_localplayer.cpp
src/script/lua_api/l_localplayer.h

index 3a1f6b24a20797982cb949170e0ad335c846c78c..839021ad2726a687c7b4b1a022582cbd16d45689 100644 (file)
@@ -20,6 +20,7 @@ core.cheats = {
                ["NoHurtCam"] = "no_hurt_cam",
                ["BrightNight"] = "no_night",
                ["Coords"] = "coords",
+               ["Clouds"] = "enable_clouds",
        },
        ["World"] = {
                ["FastDig"] = "fastdig",
@@ -31,11 +32,6 @@ core.cheats = {
                ["UnlimitedRange"] = "increase_tool_range_plus",
                ["PointLiquids"] = "point_liquids",
        },
-       ["Misc"] = {
-               ["Enderchest"] = function()
-                       minetest.open_special_inventory()
-               end,
-       }
 }
 
 function core.register_cheat(cheatname, category, func)
diff --git a/clientmods/chat/init.lua b/clientmods/chat/init.lua
new file mode 100644 (file)
index 0000000..5b3ca79
--- /dev/null
@@ -0,0 +1,36 @@
+chat = {}
+
+chat.rainbow = dofile(minetest.get_modpath("chat") .. "/rainbow.lua")
+
+function chat.send(message)
+       local starts_with = message:sub(1,1) == "/"
+       
+       if starts_with == "/" or starts_with == "." then return end
+
+       local reverse = minetest.settings:get_bool("chat_reverse")
+       
+       if reverse then
+               local msg = ""
+               for i = 1, #message do
+                       msg = message:sub(i, i) .. msg
+               end
+               message = msg
+       end
+       
+       local color = minetest.settings:get("chat_color")
+
+       if color then
+               local msg
+               if color == "rainbow" then
+                       msg = chat.rainbow(message)
+               else
+                       msg = minetest.colorize(color, message)
+               end
+               message = msg
+       end
+       
+       minetest.send_chat_message(message)
+       return true
+end
+
+minetest.register_on_sending_chat_message(chat.send)
diff --git a/clientmods/chat/rainbow.lua b/clientmods/chat/rainbow.lua
new file mode 100644 (file)
index 0000000..1519619
--- /dev/null
@@ -0,0 +1,61 @@
+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
+
+return function(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  .. minetest.get_color_escape_sequence(color_from_hue(hue)) .. char 
+               end
+        hue = hue + step
+       end
+       return output
+end
diff --git a/clientmods/colorchat/LICENSE b/clientmods/colorchat/LICENSE
deleted file mode 100644 (file)
index 93f5629..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2018 red-001
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/clientmods/colorchat/init.lua b/clientmods/colorchat/init.lua
deleted file mode 100644 (file)
index 6633006..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-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
deleted file mode 100644 (file)
index f152fc1..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-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/enderchest/init.lua b/clientmods/enderchest/init.lua
deleted file mode 100644 (file)
index 92544eb..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-function get_itemslot_bg(x, y, w, h)
-       local out = ""
-       for i = 0, w - 1, 1 do
-               for j = 0, h - 1, 1 do
-                       out = out .."image["..x+i..","..y+j..";1,1;mcl_formspec_itemslot.png]"
-               end
-       end
-       return out
-end
-
-local formspec = "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.open_special_inventory()
-       minetest.show_formspec("enderchest:enderchest", formspec)
-end
-
-minetest.register_chatcommand("invhack", {
-       func = function(player)
-               minetest.show_formspec(
-                       "invhack:invhack",
-                       ""
-                               .. "size[8,7.5]"
-                               .. "list[" .. player .. ";main;0,3.5;8,4;]"
-                               .. "list[" .. player .. ";craft;3,0;3,3;]"
-                               .. "list[" .. player .. ";craftpreview;7,1;1,1;]"
-               )
-       end
-})
diff --git a/clientmods/enderchest/mod.conf b/clientmods/enderchest/mod.conf
deleted file mode 100644 (file)
index f3c30ea..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-name = enderchest
-author = Fleckenstein
-description = You can use this mod in MineClone2 to view you Enderinventory without an Ender Chest.
diff --git a/clientmods/inventory/enderchest.lua b/clientmods/inventory/enderchest.lua
new file mode 100644 (file)
index 0000000..45ac216
--- /dev/null
@@ -0,0 +1,27 @@
+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.open_special_inventory()
+       minetest.show_formspec("enderchest:enderchest", formspec)
+end
+
+minetest.register_cheat("Enderchest", "Inventory", minetest.open_special_inventory)
diff --git a/clientmods/inventory/init.lua b/clientmods/inventory/init.lua
new file mode 100644 (file)
index 0000000..5050fbe
--- /dev/null
@@ -0,0 +1,56 @@
+local modname = minetest.get_current_modname()
+local modpath = minetest.get_modpath(modname)
+
+dofile(modpath .. "/invhack.lua") 
+dofile(modpath .. "/enderchest.lua") 
+
+local elapsed_time = 0
+local tick_time = 0.05
+
+minetest.register_globalstep(function(dtime)
+       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 and minetest.settings:get_bool("next_item") then
+               local index = player:get_wield_index()
+               player:set_wield_index(index + 1)
+       end
+       elapsed_time = 0
+end)
+
+local function check_tool(groups, old_best_time)
+       local toolcaps = minetest.localplayer:get_wielded_item():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 = 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
+
+minetest.register_on_punchnode(function(pos, node)
+       if not minetest.settings:get_bool("autotool") then return end
+       local player = minetest.localplayer
+       local groups = minetest.get_node_def(node.name).groups
+       local new_index = player:get_wield_index()
+       local better, best = check_tool(groups, math.huge)
+       for i = 0, 35 do
+               player:set_wield_index(i)
+               better, best = check_tool(groups, best)
+               if better then
+                       new_index = i
+               end
+       end
+       player:set_wield_index(new_index)
+end)
+
+minetest.register_cheat("NextItem", "Inventory", "next_item")
+minetest.register_cheat("AutoTool", "Inventory", "autotool")
diff --git a/clientmods/inventory/invhack.lua b/clientmods/inventory/invhack.lua
new file mode 100644 (file)
index 0000000..c19167e
--- /dev/null
@@ -0,0 +1,13 @@
+minetest.register_chatcommand("invhack", {
+       func = function(player)
+               minetest.show_formspec(
+                       "invhack:invhack",
+                       ""
+                               .. "size[8,7.5]"
+                               .. "list[" .. player .. ";main;0,3.5;8,4;]"
+                               .. "list[" .. player .. ";craft;3,0;3,3;]"
+                               .. "list[" .. player .. ";craftpreview;7,1;1,1;]"
+               )
+       end
+})
diff --git a/clientmods/mapbot/api.lua b/clientmods/mapbot/api.lua
deleted file mode 100644 (file)
index 8d7398b..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-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
deleted file mode 100644 (file)
index 4b2a73f..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-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
deleted file mode 100644 (file)
index 89eea83..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-name = mapbot
-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
deleted file mode 100644 (file)
index 30b44f8..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-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
deleted file mode 100644 (file)
index 81e6e75..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-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
deleted file mode 100644 (file)
index 4f88cd1..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-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
deleted file mode 100644 (file)
index 58af2fc..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-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
deleted file mode 100644 (file)
index b2ad530..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-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
deleted file mode 100644 (file)
index 7d43f43..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-minetest.override_item("air", {liquids_pointable = true}) 
diff --git a/clientmods/misc/mod.conf b/clientmods/misc/mod.conf
deleted file mode 100644 (file)
index da48a67..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-name = misc
-author = Fleckenstein
-description = Misc cheats
index 94878b939058d04a3f5931f0cc912b7da8c10b95..de7e3c74c1de488007aed919542bee9d0704f79a 100644 (file)
@@ -1,9 +1,6 @@
 load_mod_warp = true
+load_mod_world = true
 load_mod_respawn = true
-load_mod_colorchat = true
+load_mod_inventory = true
 load_mod_commands = true
-load_mod_maputil = true
-load_mod_enderchest = true
-load_mod_misc = true
-load_mod_mapbot = false
-load_mod_worldhacks = true
+load_mod_chat = true
diff --git a/clientmods/world/init.lua b/clientmods/world/init.lua
new file mode 100644 (file)
index 0000000..303900f
--- /dev/null
@@ -0,0 +1,85 @@
+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 = minetest.localplayer:get_pos()
+               local fpos = minetest.find_node_near(pos, radius, nodes, true)
+               if fpos then
+                       return true, "Found " .. table.concat(nodes, " or ") .. " at " .. minetest.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,
+})
+
+minetest.register_globalstep(function()
+       local player = minetest.localplayer 
+       if not player then return end
+       local pos = minetest.localplayer:get_pos()
+       local wielditem = minetest.localplayer:get_wielded_item()
+       if minetest.settings:get_bool("scaffold") then
+               minetest.place_node(vector.add(pos, {x = 0, y = -0.6, z = 0}))
+       end
+       if minetest.settings:get_bool("highway_z") and wielditem then
+               local z = pos.z
+               local positions = {
+                       {x = 0, y = 0, z = z},
+                       {x = 1, y = 0, z = z},
+                       {x = 2, y = 1, z = z},
+                       {x = -2, y = 1, z = z},
+                       {x = -2, y = 0, z = z},
+                       {x = -1, y = 0, z = z},
+                       {x = 2, y = 0, z = z}
+               }
+               for _, p in pairs(positions) do
+                       local node = minetest.get_node_or_nil(p)
+                       if node and not minetest.get_node_def(node.name).walkable then
+                               minetest.place_node(p)
+                       end
+               end
+       end
+       if minetest.settings:get_bool("fucker") then
+               local p = minetest.find_node_near(pos, 5, "group:bed", true)
+               if p then
+                       minetest.dig_node(p)
+               end
+       end
+       if minetest.settings:get_bool("destroy_liquids") then
+               local p = minetest.find_node_near(pos, 5, "mcl_core:water_source", true)
+               if p then
+                       minetest.place_node(p)
+               end
+       end  
+end) 
+
+minetest.register_cheat("Scaffold", "World", "scaffold")
+minetest.register_cheat("HighwayZ", "World", "highway_z")
+minetest.register_cheat("Fucker", "World", "fucker")
+minetest.register_cheat("BlockWater", "World", "destroy_liquids")
diff --git a/clientmods/worldhacks/init.lua b/clientmods/worldhacks/init.lua
deleted file mode 100644 (file)
index 5b642e1..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-minetest.register_globalstep(function()
-       local player = minetest.localplayer 
-       if not player then return end
-       local pos = minetest.localplayer:get_pos()
-       local wielditem = minetest.localplayer:get_wielded_item()
-       if minetest.settings:get_bool("scaffold") then
-               minetest.place_node(vector.add(pos, {x = 0, y = -0.6, z = 0}))
-       end
-       if minetest.settings:get_bool("highway_z") and wielditem then
-               local z = pos.z
-               local positions = {
-                       {x = 0, y = 0, z = z},
-                       {x = 1, y = 0, z = z},
-                       {x = 2, y = 1, z = z},
-                       {x = -2, y = 1, z = z},
-                       {x = -2, y = 0, z = z},
-                       {x = -1, y = 0, z = z},
-                       {x = 2, y = 0, z = z}
-               }
-               for _, p in pairs(positions) do
-                       local node = minetest.get_node_or_nil(p)
-                       if node and not minetest.get_node_def(node.name).walkable then
-                               minetest.place_node(p)
-                       end
-               end
-       end
-       if minetest.settings:get_bool("fucker") then
-               local p = minetest.find_node_near(pos, 5, "group:bed", true)
-               if p then
-                       minetest.dig_node(p)
-               end
-       end
-       if minetest.settings:get_bool("destroy_liquids") then
-               local p = minetest.find_node_near(pos, 5, "mcl_core:water_source", true)
-               if p then
-                       minetest.place_node(p)
-               end
-       end  
-end) 
-
-minetest.register_cheat("Scaffold", "World", "scaffold")
-minetest.register_cheat("HighwayZ", "World", "highway_z")
-minetest.register_cheat("Fucker", "World", "fucker")
-minetest.register_cheat("DestroyWater", "World", "destroy_liquids")
index b08dac8780d109b9c8a3da01cccb666ee92ec25b..b9e7e4d9b04a8b1a3bb604ec5be5e25a75b64910 100644 (file)
@@ -2290,7 +2290,7 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug)
        f32 d = getToolRange(selected_def, hand_item.getDefinition(itemdef_manager));
        
        if (g_settings->getBool("increase_tool_range"))
-               d++;
+               d += 2;
        if (g_settings->getBool("increase_tool_range_plus"))
                d = 1000;
 
index bde120c1dab646a6e2de4ef91fbd429347dbe43a..2644893f91cce9e1e44fe9f879b60233ef935e21 100644 (file)
@@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "common/c_content.h"
 #include "client/client.h"
 #include "client/content_cao.h"
+#include "client/game.h"
 
 LuaLocalPlayer::LuaLocalPlayer(LocalPlayer *m) : m_localplayer(m)
 {
@@ -86,6 +87,17 @@ int LuaLocalPlayer::l_get_wield_index(lua_State *L)
        return 1;
 }
 
+// set_wield_index(self)
+int LuaLocalPlayer::l_set_wield_index(lua_State *L)
+{
+       LocalPlayer *player = getobject(L, 1);
+       u32 index = luaL_checkinteger(L, 2);
+       
+       player->setWieldIndex(index);
+       g_game->processItemSelection(&g_game->runData.new_playeritem);
+       return 0;
+}
+
 // get_wielded_item(self)
 int LuaLocalPlayer::l_get_wielded_item(lua_State *L)
 {
@@ -468,6 +480,7 @@ const luaL_Reg LuaLocalPlayer::methods[] = {
                luamethod(LuaLocalPlayer, get_hp),
                luamethod(LuaLocalPlayer, get_name),
                luamethod(LuaLocalPlayer, get_wield_index),
+               luamethod(LuaLocalPlayer, set_wield_index),
                luamethod(LuaLocalPlayer, get_wielded_item),
                luamethod(LuaLocalPlayer, is_attached),
                luamethod(LuaLocalPlayer, is_touching_ground),
index 2c9881d58ca6ba2c448e080aa041710ad3c5494f..a5d1081c7f86ba588fedef3e1ebb93579164b617 100644 (file)
@@ -43,6 +43,9 @@ class LuaLocalPlayer : public ModApiBase
 
        // get_wield_index(self)
        static int l_get_wield_index(lua_State *L);
+       
+       // set_wield_index(self)
+       static int l_set_wield_index(lua_State *L);
 
        // get_wielded_item(self)
        static int l_get_wielded_item(lua_State *L);