diff --git a/minetestforfun_game/mods/screwdriver/init.lua b/minetestforfun_game/mods/screwdriver/init.lua old mode 100755 new mode 100644 index 6e560388..42958288 --- a/minetestforfun_game/mods/screwdriver/init.lua +++ b/minetestforfun_game/mods/screwdriver/init.lua @@ -1,52 +1,3 @@ - -local mode_text = { - {"Change rotation, Don't change axisdir."}, - {"Keep choosen face in front then rotate it."}, - {"Change axis dir, Reset rotation."}, - {"Bring top in front then rotate it."}, -} - -local opposite_faces = { - [0] = 5, - [1] = 2, - [2] = 1, - [3] = 4, - [4] = 3, - [5] = 0, -} - -local function screwdriver_setmode(user,itemstack) - local player_name = user:get_player_name() - local item = itemstack:to_table() - local mode = tonumber(itemstack:get_metadata()) - if not mode then - minetest.chat_send_player(player_name, "Use while sneaking to change screwdriwer modes.") - mode = 0 - end - mode = mode + 1 - if mode == 5 then - mode = 1 - end - minetest.chat_send_player(player_name, "Screwdriver mode : "..mode.." - "..mode_text[mode][1] ) - itemstack:set_name("screwdriver:screwdriver"..mode) - itemstack:set_metadata(mode) - return itemstack -end - -local function get_node_face(pointed_thing) - local ax, ay, az = pointed_thing.above.x, pointed_thing.above.y, pointed_thing.above.z - local ux, uy, uz = pointed_thing.under.x, pointed_thing.under.y, pointed_thing.under.z - if ay > uy then return 0 -- Top - elseif az > uz then return 1 -- Z+ side - elseif az < uz then return 2 -- Z- side - elseif ax > ux then return 3 -- X+ side - elseif ax < ux then return 4 -- X- side - elseif ay < uy then return 5 -- Bottom - else - error("pointed_thing.above and under are the same!") - end -end - local function nextrange(x, max) x = x + 1 if x > max then @@ -55,21 +6,21 @@ local function nextrange(x, max) return x end -local function screwdriver_handler(itemstack, user, pointed_thing) +-- Handles rotation +local function screwdriver_handler(itemstack, user, pointed_thing, mode) if pointed_thing.type ~= "node" then return end + local pos = pointed_thing.under local keys = user:get_player_control() local player_name = user:get_player_name() - local mode = tonumber(itemstack:get_metadata()) - if not mode or keys["sneak"] == true then - return screwdriver_setmode(user, itemstack) - end + if minetest.is_protected(pos, user:get_player_name()) then minetest.record_protection_violation(pos, user:get_player_name()) return end + local node = minetest.get_node(pos) local ndef = minetest.registered_nodes[node.name] if not ndef or not ndef.paramtype2 == "facedir" or @@ -78,47 +29,22 @@ local function screwdriver_handler(itemstack, user, pointed_thing) node.param2 == nil then return end - -- Get ready to set the param2 + + -- Set param2 local n = node.param2 local axisdir = math.floor(n / 4) local rotation = n - axisdir * 4 if mode == 1 then n = axisdir * 4 + nextrange(rotation, 3) - elseif mode == 2 then - -- If you are pointing at the axisdir face or the - -- opposite one then you can just rotate the node. - -- Otherwise change the axisdir, avoiding the facing - -- and opposite axes. - local face = get_node_face(pointed_thing) - if axisdir == face or axisdir == opposite_faces[face] then - n = axisdir * 4 + nextrange(rotation, 3) - else - axisdir = nextrange(axisdir, 5) - -- This is repeated because switching from the face - -- can move to to the opposite and vice-versa - if axisdir == face or axisdir == opposite_faces[face] then - axisdir = nextrange(axisdir, 5) - end - if axisdir == face or axisdir == opposite_faces[face] then - axisdir = nextrange(axisdir, 5) - end - n = axisdir * 4 - end elseif mode == 3 then n = nextrange(axisdir, 5) * 4 - elseif mode == 4 then - local face = get_node_face(pointed_thing) - if axisdir == face then - n = axisdir * 4 + nextrange(rotation, 3) - else - n = face * 4 - end end - --print (dump(axisdir..", "..rotation)) + node.param2 = n minetest.swap_node(pos, node) + local item_wear = tonumber(itemstack:get_wear()) - item_wear = item_wear + 327 + item_wear = item_wear + 300 -- was 327 if item_wear > 65535 then itemstack:clear() return itemstack @@ -127,6 +53,21 @@ local function screwdriver_handler(itemstack, user, pointed_thing) return itemstack end +-- Screwdriver +minetest.register_tool("screwdriver:screwdriver", { + description = "Screwdriver (left-click rotates face, right-click rotates axis)", + inventory_image = "screwdriver.png", + on_use = function(itemstack, user, pointed_thing) + screwdriver_handler(itemstack, user, pointed_thing, 1) + return itemstack + end, + on_place = function(itemstack, user, pointed_thing) + screwdriver_handler(itemstack, user, pointed_thing, 3) + return itemstack + end, +}) + + minetest.register_craft({ output = "screwdriver:screwdriver", recipe = { @@ -135,25 +76,8 @@ minetest.register_craft({ } }) -minetest.register_tool("screwdriver:screwdriver", { - description = "Screwdriver", - inventory_image = "screwdriver.png", - on_use = function(itemstack, user, pointed_thing) - screwdriver_handler(itemstack, user, pointed_thing) - return itemstack - end, -}) - -for i = 1, 4 do - minetest.register_tool("screwdriver:screwdriver"..i, { - description = "Screwdriver in Mode "..i, - inventory_image = "screwdriver.png^tool_mode"..i..".png", - wield_image = "screwdriver.png", - groups = {not_in_creative_inventory=1}, - on_use = function(itemstack, user, pointed_thing) - screwdriver_handler(itemstack, user, pointed_thing) - return itemstack - end, - }) -end - +-- Compatibility with original mod +minetest.register_alias("screwdriver:screwdriver1", "screwdriver:screwdriver") +minetest.register_alias("screwdriver:screwdriver2", "screwdriver:screwdriver") +minetest.register_alias("screwdriver:screwdriver3", "screwdriver:screwdriver") +minetest.register_alias("screwdriver:screwdriver4", "screwdriver:screwdriver") diff --git a/minetestforfun_game/mods/screwdriver/readme.txt b/minetestforfun_game/mods/screwdriver/readme.txt old mode 100755 new mode 100644 index d0b10e05..64e7714b --- a/minetestforfun_game/mods/screwdriver/readme.txt +++ b/minetestforfun_game/mods/screwdriver/readme.txt @@ -1,5 +1,6 @@ Minetest mod: screwdriver -========================= +Edited by TenPlus1 on 2nd Sep 2014 +================================== License of source code: ----------------------- @@ -15,4 +16,4 @@ http://www.gnu.org/licenses/lgpl-2.1.html License of media (textures and sounds) -------------------------------------- Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) -http://creativecommons.org/licenses/by-sa/3.0/ +http://creativecommons.org/licenses/by-sa/3.0/ \ No newline at end of file diff --git a/minetestforfun_game/mods/screwdriver/textures/screwdriver.png b/minetestforfun_game/mods/screwdriver/textures/screwdriver.png deleted file mode 100755 index 672692a1..00000000 Binary files a/minetestforfun_game/mods/screwdriver/textures/screwdriver.png and /dev/null differ diff --git a/minetestforfun_game/mods/screwdriver/textures/tool_mode1.png b/minetestforfun_game/mods/screwdriver/textures/tool_mode1.png deleted file mode 100755 index 41e12ab4..00000000 Binary files a/minetestforfun_game/mods/screwdriver/textures/tool_mode1.png and /dev/null differ diff --git a/minetestforfun_game/mods/screwdriver/textures/tool_mode2.png b/minetestforfun_game/mods/screwdriver/textures/tool_mode2.png deleted file mode 100755 index 2043d8f6..00000000 Binary files a/minetestforfun_game/mods/screwdriver/textures/tool_mode2.png and /dev/null differ diff --git a/minetestforfun_game/mods/screwdriver/textures/tool_mode3.png b/minetestforfun_game/mods/screwdriver/textures/tool_mode3.png deleted file mode 100755 index fbc729f7..00000000 Binary files a/minetestforfun_game/mods/screwdriver/textures/tool_mode3.png and /dev/null differ diff --git a/minetestforfun_game/mods/screwdriver/textures/tool_mode4.png b/minetestforfun_game/mods/screwdriver/textures/tool_mode4.png deleted file mode 100755 index c9253146..00000000 Binary files a/minetestforfun_game/mods/screwdriver/textures/tool_mode4.png and /dev/null differ diff --git a/mods/xban/LICENSE.txt b/mods/xban/LICENSE.txt deleted file mode 100755 index ebac2db4..00000000 --- a/mods/xban/LICENSE.txt +++ /dev/null @@ -1,25 +0,0 @@ - -Copyright (c) 2013, Diego Martínez -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. diff --git a/mods/xban/README.txt b/mods/xban/README.txt deleted file mode 100755 index fa1864a9..00000000 --- a/mods/xban/README.txt +++ /dev/null @@ -1,115 +0,0 @@ - -Extended Ban Mod for Minetest ------------------------------ - -This mod registers all the IPs used by individual players, and can ban the -player when using any of them, even if he is not online at the moment. - -License -------- - -See file 'LICENSE.txt'. - -Chat Commands -------------- - -/xban [] - Ban given player and all his IPs. If reason not given, it defaults to - "because random". If player is online at the moment, he/she is shown it. If - user is not online, it saves it in a list, and next time he connects from any - IP, or connects from a banned IP with different name, it gets banned again, - and new IP/username recorded. - -/xtempban