From a6f004e4df50ec40da9b25f8d7c149d83933dceb Mon Sep 17 00:00:00 2001 From: kakalak-lumberjack Date: Sun, 27 Nov 2022 06:47:56 -0500 Subject: [PATCH] Move hud over statbars --- README.md | 86 ++- check_owner.lua | 44 -- hud.lua | 6 +- init.lua | 524 ++++++++++-------- inspect.lua | 26 +- .../replacer/textures/replacer_inspect.png | Bin 0 -> 594 bytes .../replacer/textures/replacer_replacer.png | Bin 0 -> 234 bytes .../legacy_textures/replacer_replacer.png | Bin 0 -> 461 bytes textures/replacer_inspect.png | Bin 594 -> 5821 bytes textures/replacer_replacer.png | Bin 461 -> 5858 bytes 10 files changed, 354 insertions(+), 332 deletions(-) delete mode 100644 check_owner.lua create mode 100644 textures/Gabosburg Mods/replacer/textures/replacer_inspect.png create mode 100644 textures/Gabosburg Mods/replacer/textures/replacer_replacer.png create mode 100644 textures/legacy_textures/replacer_replacer.png diff --git a/README.md b/README.md index 5f263f1..2d3faf2 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,54 @@ - Replacement tool for creative building (Mod for MineTest) + ## Replacer Tool -This tool is helpful for creative purposes (i.e. build a wall and "paint" windows into it). -It replaces nodes with a previously selected other type of node (i.e. places said windows -into a brick wall). +Replacer tool for creative building in [Minetest](http://minetest.net) is helpful for copying, placing and replacing nodes. The tool can place or replace existing nodes with a previously selected other type of node (i.e. places said windows into a brick wall) preserving rotations of the copied node. -Crafting: chest - - - - stick - - - - chest -Or just use /giveme replacer:replacer +### Crafting the replacer: +chest | _____ | _____ -Usage: Right-click on a node of that type you want to replace other nodes with. - Left-click (normal usage) on any nodes you want to replace with the type you previously right-clicked on. - SHIFT-Right-click in order to store a new pattern. +_____ | stick | _____ -When in creative mode, the node will just be replaced. Your inventory will not be changed. +_____ | _____ | chest -When not in creative mode, digging will be simulated and you will get what was there. In return, the replacement node -will be taken from your inventory. +### Commands +Give yourself a replacer (priv required) `/giveme replacer:replacer` +Set replacer modes (paint/legacy) `/replacer legacy` `/replacer paint` -The second tool included in this mod is the inspector. +### Paint mode controls (default) + The controls allow players continuously place or replace nodes by holding down right mouse key (Shift for replace) -Crafting: torch - stick + `Shift + Left Mouse`: Set replacer's replacement node data (node to be placed) + + `Left Mouse`: Replace pointed node with replacement node. + + `Right Mouse`: Place replacement node on pointed node (normal placement) continuously while keys are held. + + `Shift + Right Mouse`: Replace pointed node with replacement node continuously while keys are held + +### Legacy mode controls + `Right Mouse` Place replacement node on pointed face. + + `Left Mouse`: Replace pointed node with replacement node. + + `Shift + Right Mouse`: Set replacer's replacement node data (node to be placed) + +### Inventory and Creative mode support +When not in creative mode, digging will be simulated when replacing nodes, giving the player any drops. In return, the replacement node will be taken from your inventory. + +When in minetest game's creative mode, the node will just be replaced. Your inventory will not be changed. + +## Inspector tool + The inspector tool shows information about the pointed node. + +###Crafting: +torch + +stick Just wield it and click on any node or entity you want to know more about. A limited craft-guide is included. - - - Copyright (C) 2013,2014,2015 Sokomine +### License +-- Copyright 2021 Sokomine, lumberJack, Vanessa E This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -42,4 +62,30 @@ Just wield it and click on any node or entity you want to know more about. A lim You should have received a copy of the GNU General Public License along with this program. If not, see . +### Change log: +- 11.27.2021 + - Add mode setting for paint and legacy keybindings + - Code and documentation cleaned up and updated. +- 2020 + - Added HUD support and remove chat messages + - Added new keybinding to allow paint mechanic while replacing nodes +#### Forked from Sokomine + +-- 09.12.2017 * Got rid of outdated minetest.env +-- * Fixed error in protection function. +-- * Fixed minor bugs. +-- * Added blacklist +-- 02.10.2014 * Some more improvements for inspect-tool. Added craft-guide. +-- 01.10.2014 * Added inspect-tool. +-- 12.01.2013 * If digging the node was unsuccessful, then the replacement will now fail +-- (instead of destroying the old node with its metadata; i.e. chests with content) +-- 20.11.2013 * if the server version is new enough, minetest.is_protected is used +-- in order to check if the replacement is allowed +-- 24.04.2013 * param1 and param2 are now stored +-- * hold sneak + right click to store new pattern +-- * right click: place one of the itmes +-- * receipe changed +-- * inventory image added + +-- adds a function to check ownership of a node; taken from VanessaEs homedecor mod \ No newline at end of file diff --git a/check_owner.lua b/check_owner.lua deleted file mode 100644 index 6a63f69..0000000 --- a/check_owner.lua +++ /dev/null @@ -1,44 +0,0 @@ --- taken from Vanessa Ezekowitz' homedecor mod --- see http://forum.minetest.net/viewtopic.php?pid=26061 or https://github.com/VanessaE/homedecor for details! -function replacer_homedecor_node_is_owned(pos, placer) - - if( not( placer ) or not(pos )) then - return true; - end - local pname = placer:get_player_name(); - if (type( minetest.is_protected ) == "function") then - local res = minetest.is_protected( pos, pname ); - if( res ) then - minetest.chat_send_player( pname, "Cannot replace node. It is protected." ); - end - return res; - end - - local ownername = false - if type(IsPlayerNodeOwner) == "function" then -- node_ownership mod - if HasOwner(pos, placer) then -- returns true if the node is owned - if not IsPlayerNodeOwner(pos, pname) then - if type(getLastOwner) == "function" then -- ...is an old version - ownername = getLastOwner(pos) - elseif type(GetNodeOwnerName) == "function" then -- ...is a recent version - ownername = GetNodeOwnerName(pos) - else - ownername = "someone" - end - end - end - - elseif type(isprotect)=="function" then -- glomie's protection mod - if not isprotect(5, pos, placer) then - ownername = "someone" - end - end - - if ownername ~= false then - minetest.chat_send_player( pname, "Sorry, "..ownername.." owns that spot." ) - return true - else - return false - end -end - diff --git a/hud.lua b/hud.lua index 378dd9b..7d7098b 100644 --- a/hud.lua +++ b/hud.lua @@ -1,4 +1,4 @@ --- HUD support added by lumberJack +-- HUD support added by lumberJack 2021 -- store Hud ids by playername replacer.hud_ids = {}; @@ -14,8 +14,8 @@ function replacer.set_hud(playername, message) hud_elem_type = "text", name = "Replacer", number = 0xFFFFFF, - position = {x=0.7, y=1}, - offset = {x=0, y=-8}, + position = {x=0.5, y=1}, + offset = {x = (-10 * 24) - 25, y = -(64 + 24 + 16)}, text = message, scale = {x=200, y=60}, alignment = {x=1, y=-1}, diff --git a/init.lua b/init.lua index b92ce37..500e4f9 100644 --- a/init.lua +++ b/init.lua @@ -1,271 +1,305 @@ - - ---[[ - Replacement tool for creative building (Mod for MineTest) - Copyright (C) 2013 Sokomine - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . ---]] - --- Version 3.0 - --- Changelog: --- 09.12.2017 * Got rid of outdated minetest.env --- * Fixed error in protection function. --- * Fixed minor bugs. --- * Added blacklist --- 02.10.2014 * Some more improvements for inspect-tool. Added craft-guide. --- 01.10.2014 * Added inspect-tool. --- 12.01.2013 * If digging the node was unsuccessful, then the replacement will now fail --- (instead of destroying the old node with its metadata; i.e. chests with content) --- 20.11.2013 * if the server version is new enough, minetest.is_protected is used --- in order to check if the replacement is allowed --- 24.04.2013 * param1 and param2 are now stored --- * hold sneak + right click to store new pattern --- * right click: place one of the itmes --- * receipe changed --- * inventory image added - --- adds a function to check ownership of a node; taken from VanessaEs homedecor mod -dofile(minetest.get_modpath("replacer").."/check_owner.lua"); - -replacer = {}; - -replacer.blacklist = {}; +replacer = {} +replacer.blacklist = {} -- playing with tnt and creative building are usually contradictory -- (except when doing large-scale landscaping in singleplayer) -replacer.blacklist[ "tnt:boom"] = true; -replacer.blacklist[ "tnt:gunpowder"] = true; -replacer.blacklist[ "tnt:gunpowder_burning"] = true; -replacer.blacklist[ "tnt:tnt"] = true; +replacer.blacklist["tnt:boom"] = true +replacer.blacklist["tnt:gunpowder"] = true +replacer.blacklist["tnt:gunpowder_burning"] = true +replacer.blacklist["tnt:tnt"] = true -- prevent accidental replacement of your protector -replacer.blacklist[ "protector:protect"] = true; -replacer.blacklist[ "protector:protect2"] = true; +replacer.blacklist["protector:protect"] = true +replacer.blacklist["protector:protect2"] = true -- adds a tool for inspecting nodes and entities -dofile(minetest.get_modpath("replacer").."/inspect.lua"); +dofile(minetest.get_modpath("replacer") .. "/inspect.lua") -- add support for HUD messenges -dofile(minetest.get_modpath("replacer").."/hud.lua"); +dofile(minetest.get_modpath("replacer") .. "/hud.lua") +minetest.register_tool("replacer:replacer", { + description = "Node replacement tool", + groups = {}, + inventory_image = "replacer_replacer.png", + use_texture_alpha = true, + wield_image = "", + wield_scale = { + x = 1, + y = 1, + z = 1 + }, + stack_max = 1, -- it has to store information - thus only one can be stacked + liquids_pointable = true, -- it is ok to paint in/with water + node_placement_prediction = nil, + metadata = "default:dirt", -- default replacement: common dirt -minetest.register_tool( "replacer:replacer", -{ - description = "Node replacement tool", - groups = {}, - inventory_image = "replacer_replacer.png", - wield_image = "", - wield_scale = {x=1,y=1,z=1}, - stack_max = 1, -- it has to store information - thus only one can be stacked - liquids_pointable = true, -- it is ok to painit in/with water ---[[ - -- the tool_capabilities are of nearly no intrest here - tool_capabilities = { - full_punch_interval = 1.0, - max_drop_level=0, - groupcaps={ - -- For example: - fleshy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1}, - snappy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1}, - choppy={times={[3]=0.90}, maxwear=0.05, maxlevel=0} - } - }, ---]] - node_placement_prediction = nil, - metadata = "default:dirt", -- default replacement: common dirt - - on_place = function(itemstack, placer, pointed_thing) - - if( placer == nil or pointed_thing == nil) then - return itemstack; -- nothing consumed - end - local name = placer:get_player_name(); - --minetest.chat_send_player( name, "You PLACED this on "..minetest.serialize( pointed_thing ).."."); - - local keys=placer:get_player_control(); - - -- just place the stored node if now new one is to be selected - if( not( keys["sneak"] )) then - - return replacer.replace( itemstack, placer, pointed_thing, 0 ); - else - return replacer.replace( itemstack, placer, pointed_thing, above ); - end - end, - - --- on_drop = func(itemstack, dropper, pos), - - on_use = function(itemstack, user, pointed_thing) - name = user:get_player_name(); + on_place = function(itemstack, placer, pointed_thing) + if (placer == nil or pointed_thing == nil) then + return itemstack -- nothing consumed + end if( pointed_thing.type ~= "node" ) then - replacer.set_hud( name, " Error: No node selected."); - return nil; + -- minetest.chat_send_player( name, " Error: No node selected."); + replacer.set_hud(name, " Error: No node selected."); + return nil; + end + local name = placer:get_player_name() + local mode = replacer.get_mode(placer) + local keys = placer:get_player_control() + + if mode == "legacy" then + if( not( keys["sneak"] )) then + return replacer.replace( itemstack, placer, pointed_thing, 0 ); end + + local pos = minetest.get_pointed_thing_position( pointed_thing, under ); + local node = minetest.get_node_or_nil( pos ); + + --minetest.chat_send_player( name, " Target node: "..minetest.serialize( node ).." at pos "..minetest.serialize( pos ).."."); + local metadata = "default:dirt 0 0"; + if( node ~= nil and node.name ) then + metadata = node.name..' '..node.param1..' '..node.param2; + end + itemstack:set_metadata( metadata ); + + --minetest.chat_send_player( name, "Node replacement tool set to: '"..metadata.."'."); + replacer.set_hud(name, "Node replacement tool set to: '"..metadata.."'."); + return itemstack; -- nothing consumed but data changed end - local pos = minetest.get_pointed_thing_position( pointed_thing, under ); - local node = minetest.get_node_or_nil( pos ); - - --minetest.chat_send_player( name, " Target node: "..minetest.serialize( node ).." at pos "..minetest.serialize( pos ).."."); - local metadata = "default:dirt 0 0"; - if( node ~= nil and node.name ) then - metadata = node.name..' '..node.param1..' '..node.param2; + -- just place the stored node if now new one is to be selected + if (not (keys["sneak"])) then + + return replacer.replace(itemstack, placer, pointed_thing, 0) + else + return replacer.replace(itemstack, placer, pointed_thing, above) end - itemstack:set_metadata( metadata ); + end, - replacer.set_hud( name, "Node replacement tool set to: '"..metadata.."'."); + on_use = function(itemstack, user, pointed_thing) + local name = user:get_player_name() + local keys = user:get_player_control() + local mode = replacer.get_mode(user) - return itemstack; -- nothing consumed but data changed - end, + if (pointed_thing.type ~= "node") then + replacer.set_hud(name, " Error: No node selected.") + return nil + end + if mode == "legacy" then + return replacer.replace( itemstack, user, pointed_thing, above ); + end + if (keys["sneak"]) then + local pos = minetest.get_pointed_thing_position(pointed_thing, under) + local node = minetest.get_node_or_nil(pos) + local metadata = "default:dirt 0 0" + if (node ~= nil and node.name) then + metadata = node.name .. ' ' .. node.param1 .. ' ' .. node.param2 + end + itemstack:set_metadata(metadata) + + replacer.set_hud(name, "Node replacement tool set to: '" .. metadata .. "'.") + + return itemstack -- nothing consumed but data changed + else + return replacer.replace(itemstack, user, pointed_thing, above) + end + end }) +replacer.replace = function(itemstack, user, pointed_thing, mode) -replacer.replace = function( itemstack, user, pointed_thing, mode ) + if (user == nil or pointed_thing == nil) then + return nil + end + local name = user:get_player_name() - if( user == nil or pointed_thing == nil) then - return nil; - end - local name = user:get_player_name(); - --minetest.chat_send_player( name, "You USED this on "..minetest.serialize( pointed_thing ).."."); - - if( pointed_thing.type ~= "node" ) then - replacer.set_hud( name, " Error: No node."); - return nil; - end - - local pos = minetest.get_pointed_thing_position( pointed_thing, mode ); - local node = minetest.get_node_or_nil( pos ); - - --minetest.chat_send_player( name, " Target node: "..minetest.serialize( node ).." at pos "..minetest.serialize( pos ).."."); - - if( node == nil ) then - - replacer.set_hud( name, "Error: Target node not yet loaded. Please wait a moment for the server to catch up."); - return nil; - end - - - local item = itemstack:to_table(); - - -- make sure it is defined - if( not( item[ "metadata"] ) or item["metadata"]=="" ) then - item["metadata"] = "default:dirt 0 0"; - end - - -- regain information about nodename, param1 and param2 - local daten = item[ "metadata"]:split( " " ); - -- the old format stored only the node name - if( #daten < 3 ) then - daten[2] = 0; - daten[3] = 0; - end - - -- if someone else owns that node then we can not change it - if( replacer_homedecor_node_is_owned(pos, user)) then - - return nil; - end - - if( node.name and node.name ~= "" and replacer.blacklist[ node.name ]) then - replacer.set_hud( name, "Replacing blocks of the type '"..( node.name or "?" ).. - "' is not allowed on this server. Replacement failed."); - return nil; - end - - if( replacer.blacklist[ daten[1] ]) then - replacer.set_hud( name, "Placing blocks of the type '"..( daten[1] or "?" ).. - "' with the replacer is not allowed on this server. Replacement failed."); - return nil; - end - - -- do not replace if there is nothing to be done - if( node.name == daten[1] ) then - - -- the node itshelf remains the same, but the orientation was changed - if( node.param1 ~= daten[2] or node.param2 ~= daten[3] ) then - minetest.add_node( pos, { name = node.name, param1 = daten[2], param2 = daten[3] } ); - end - - return nil; - end - - - -- in survival mode, the player has to provide the node he wants to place - if( not(minetest.settings:get_bool("creative_mode") ) - and not( minetest.check_player_privs( name, {creative=true}))) then - - -- players usually don't carry dirt_with_grass around; it's safe to assume normal dirt here - -- fortunately, dirt and dirt_with_grass does not make use of rotation - if( daten[1] == "default:dirt_with_grass" ) then - daten[1] = "default:dirt"; - item["metadata"] = "default:dirt 0 0"; - end - - -- does the player carry at least one of the desired nodes with him? - if( not( user:get_inventory():contains_item("main", daten[1]))) then - - - replacer.set_hud( name, "You have no further '"..( daten[1] or "?" ).."'. Replacement failed."); - return nil; - end - - - - -- give the player the item by simulating digging if possible - if( node.name ~= "air" - and node.name ~= "ignore" - and node.name ~= "default:lava_source" - and node.name ~= "default:lava_flowing" - and node.name ~= "default:river_water_source" - and node.name ~= "default:river_water_flowing" - and node.name ~= "default:water_source" - and node.name ~= "default:water_flowing" ) then - - minetest.node_dig( pos, node, user ); - - local digged_node = minetest.get_node_or_nil( pos ); - if( not( digged_node ) - or digged_node.name == node.name ) then - - replacer.set_hud( name, "Replacing '"..( node.name or "air" ).."' with '"..( item[ "metadata"] or "?" ).."' failed. Unable to remove old node."); - return nil; - end - - end - - -- consume the item - user:get_inventory():remove_item("main", daten[1].." 1"); - - --user:get_inventory():add_item( "main", node.name.." 1"); - end - - --minetest.chat_send_player( name, "Replacing node '"..( node.name or "air" ).."' with '"..( item[ "metadata"] or "?" ).."'."); - - --minetest.place_node( pos, { name = item[ "metadata" ] } ); - minetest.add_node( pos, { name = daten[1], param1 = daten[2], param2 = daten[3] } ); - return nil; -- no item shall be removed from inventory + if (pointed_thing.type ~= "node") then + replacer.set_hud(name, " Error: No node.") + return nil end + local pos = minetest.get_pointed_thing_position(pointed_thing, mode) + local node = minetest.get_node_or_nil(pos) + if (node == nil) then + replacer.set_hud(name, "Error: Target node not yet loaded. Please wait a moment for the server to catch up.") + return nil + end -minetest.register_craft({ - output = 'replacer:replacer', - recipe = { - { 'default:chest', '', '' }, - { '', 'default:stick', '' }, - { '', '', 'default:chest' }, - } + local item = itemstack:to_table() + + -- make sure it is defined + if (not (item["metadata"]) or item["metadata"] == "") then + item["metadata"] = "default:dirt 0 0" + end + + -- regain information about nodename, param1 and param2 + local daten = item["metadata"]:split(" ") + -- the old format stored only the node name + if (#daten < 3) then + daten[2] = 0 + daten[3] = 0 + end + + -- if someone else owns that node then we can not change it + if replacer.node_is_owned(pos, user) then + return nil + end + + if (node.name and node.name ~= "" and replacer.blacklist[node.name]) then + replacer.set_hud(name, "Replacing blocks of the type '" .. (node.name or "?") .. + "' is not allowed on this server. Replacement failed.") + return nil + end + + if (replacer.blacklist[daten[1]]) then + replacer.set_hud(name, "Placing blocks of the type '" .. (daten[1] or "?") .. + "' with the replacer is not allowed on this server. Replacement failed.") + return nil + end + + -- do not replace if there is nothing to be done + if (node.name == daten[1]) then + + -- the node itshelf remains the same, but the orientation was changed + if (node.param1 ~= daten[2] or node.param2 ~= daten[3]) then + minetest.add_node(pos, { + name = node.name, + param1 = daten[2], + param2 = daten[3] + }) + end + + return nil + end + + -- in survival mode, the player has to provide the node he wants to place + if (not (minetest.settings:get_bool("creative_mode")) and not (minetest.check_player_privs(name, { + creative = true + }))) then + + -- players usually don't carry dirt_with_grass around it's safe to assume normal dirt here + -- fortunately, dirt and dirt_with_grass does not make use of rotation + if (daten[1] == "default:dirt_with_grass") then + daten[1] = "default:dirt" + item["metadata"] = "default:dirt 0 0" + end + + -- does the player carry at least one of the desired nodes with him? + if (not (user:get_inventory():contains_item("main", daten[1]))) then + replacer.set_hud(name, "You have no further '" .. (daten[1] or "?") .. "'. Replacement failed.") + return nil + end + + -- give the player the item by simulating digging if possible + if (node.name ~= "air" and node.name ~= "ignore" and node.name ~= "default:lava_source" and node.name ~= + "default:lava_flowing" and node.name ~= "default:river_water_source" and node.name ~= + "default:river_water_flowing" and node.name ~= "default:water_source" and node.name ~= + "default:water_flowing") then + + minetest.node_dig(pos, node, user) + + local digged_node = minetest.get_node_or_nil(pos) + if (not (digged_node) or digged_node.name == node.name) then + + replacer.set_hud(name, + "Replacing '" .. (node.name or "air") .. "' with '" .. (item["metadata"] or "?") .. + "' failed.\nUnable to remove old node.") + return nil + end + + end + + -- consume the item + user:get_inventory():remove_item("main", daten[1] .. " 1") + + end + + minetest.add_node(pos, { + name = daten[1], + param1 = daten[2], + param2 = daten[3] + }) + return nil -- no item shall be removed from inventory +end + +-- protection checking from Vanessa Ezekowitz' homedecor mod +-- see http://forum.minetest.net/viewtopic.php?pid=26061 or https://github.com/VanessaE/homedecor for details! + +replacer.node_is_owned = function(pos, placer) + if (not (placer) or not (pos)) then + return true + end + local pname = placer:get_player_name() + if (type(minetest.is_protected) == "function") then + local res = minetest.is_protected(pos, pname) + if (res) then + + replacer.set_hud(pname, "Cannot replace node. It is protected.") + end + return res + end + + local ownername = false + if type(IsPlayerNodeOwner) == "function" then -- node_ownership mod + if HasOwner(pos, placer) then -- returns true if the node is owned + if not IsPlayerNodeOwner(pos, pname) then + if type(getLastOwner) == "function" then -- ...is an old version + ownername = getLastOwner(pos) + elseif type(GetNodeOwnerName) == "function" then -- ...is a recent version + ownername = GetNodeOwnerName(pos) + else + ownername = "someone" + end + end + end + + elseif type(isprotect) == "function" then -- glomie's protection mod + if not isprotect(5, pos, placer) then + ownername = "someone" + end + end + + if ownername ~= false then + minetest.chat_send_player(pname, "Sorry, " .. ownername .. " owns that spot.") + return true + else + return false + end +end + +-- Handle mode setting/getting +replacer.set_mode = function(player, mode_name) + if mode_name ~= "legacy" and mode_name ~= "paint" then + return replacer.set_hud(player:get_player_name(), "Invalid replacer mode!") + end + local meta = player:get_meta() + meta:set_string('replacer_mode', mode_name) + replacer.set_hud(player:get_player_name(), "Replacer set to " .. mode_name .. " mode.") +end + +replacer.get_mode = function(player) + local meta = player:get_meta() + local mode_name = meta:get_string("replacer_mode") + if mode_name == nil then + mode_name = "paint" + replacer.set_mode(player, mode_name) + end + return mode_name +end + +-- Chat command to set mode +minetest.register_chatcommand("replacer_mode", { + params = "", + description = "Sets replacer mode. Modes include 'legacy' or 'paint'", + func = function(name, param) + if param ~= "legacy" and param ~= "paint" then + return minetest.chat_send_player(name, "Invalid replacer mode: 'legacy' or 'paint'") + end + replacer.set_mode(minetest.get_player_by_name(name), param) + end }) +-- Crafting +minetest.register_craft({ + output = 'replacer:replacer', + recipe = {{'default:chest', '', ''}, {'', 'default:stick', ''}, {'', '', 'default:chest'}} +}) diff --git a/inspect.lua b/inspect.lua index 893fc99..6983e4c 100644 --- a/inspect.lua +++ b/inspect.lua @@ -17,26 +17,13 @@ if( minetest.get_modpath("trees") replacer.image_replacements[ "default:furnace_active" ] = "oven:oven_active"; end -minetest.register_tool( "replacer:inspect", -{ +minetest.register_tool( "replacer:inspect", { description = "Node inspection tool", groups = {}, inventory_image = "replacer_inspect.png", wield_image = "", wield_scale = {x=1,y=1,z=1}, liquids_pointable = true, -- it is ok to request information about liquids ---[[ - -- the tool_capabilities are of no intrest here; it is not for digging - tool_capabilities = { - full_punch_interval = 1.0, - max_drop_level=0, - groupcaps={ - fleshy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1}, - snappy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1}, - choppy={times={[3]=0.90}, maxwear=0.05, maxlevel=0} - } - }, ---]] node_placement_prediction = nil, on_use = function(itemstack, user, pointed_thing) @@ -52,7 +39,6 @@ minetest.register_tool( "replacer:inspect", replacer.inspect = function( itemstack, user, pointed_thing, mode, show_receipe ) - if( user == nil or pointed_thing == nil) then return nil; end @@ -367,19 +353,19 @@ replacer.inspect_show_crafting = function( name, node_name, fields ) end elseif( receipe.type=='cooking' and receipe.items and #receipe.items==1 and receipe.output=="" ) then - formspec = formspec.."item_image_button[1,1;3.4,3.4;"..replacer.image_button_link( 'default:furnace_active' ).."]".. --default_furnace_front.png]".. + formspec = formspec.."item_image_button[1,1;1.0,1.0;"..replacer.image_button_link( 'default:furnace_active' ).."]".. --default_furnace_front.png]".. "item_image_button[2.9,2.7;1.0,1.0;"..replacer.image_button_link( receipe.items[1] ).."]".. "label[1.0,0;"..tostring(receipe.items[1]).."]".. "label[0,0.5;This can be used as a fuel.]"; elseif( receipe.type=='cooking' and receipe.items and #receipe.items==1 ) then - formspec = formspec.."item_image_button[1,1;3.4,3.4;"..replacer.image_button_link( 'default:furnace' ).."]".. --default_furnace_front.png]".. + formspec = formspec.."item_image_button[1,1;1.0,1.0;"..replacer.image_button_link( 'default:furnace' ).."]".. --default_furnace_front.png]".. "item_image_button[2.9,2.7;1.0,1.0;"..replacer.image_button_link( receipe.items[1] ).."]"; elseif( receipe.type=='colormachine' and receipe.items and #receipe.items==1 ) then - formspec = formspec.."item_image_button[1,1;3.4,3.4;"..replacer.image_button_link( 'colormachine:colormachine' ).."]".. --colormachine_front.png]".. + formspec = formspec.."item_image_button[1,1;1.0,1.0;"..replacer.image_button_link( 'colormachine:colormachine' ).."]".. --colormachine_front.png]".. "item_image_button[2,2;1.0,1.0;"..replacer.image_button_link( receipe.items[1] ).."]"; elseif( receipe.type=='saw' and receipe.items and #receipe.items==1 ) then - --formspec = formspec.."item_image[1,1;3.4,3.4;moreblocks:circular_saw]".. - formspec = formspec.."item_image_button[1,1;3.4,3.4;"..replacer.image_button_link( 'moreblocks:circular_saw' ).."]".. + --formspec = formspec.."item_image[1,1;1.0,1.0;moreblocks:circular_saw]".. + formspec = formspec.."item_image_button[1,1;1.0,1.0;"..replacer.image_button_link( 'moreblocks:circular_saw' ).."]".. "item_image_button[2,0.6;1.0,1.0;"..replacer.image_button_link( receipe.items[1] ).."]"; else formspec = formspec..'label[3,1;Error: Unkown receipe.]'; diff --git a/textures/Gabosburg Mods/replacer/textures/replacer_inspect.png b/textures/Gabosburg Mods/replacer/textures/replacer_inspect.png new file mode 100644 index 0000000000000000000000000000000000000000..ea47b56083d17937d198fa323f83de0b35086da1 GIT binary patch literal 594 zcmV-Y0fTxstS*#m zO3^4-!;m$HJ!cu5I$>7^bC?zZ5jZ&%V6@|V-!(c9%IMJOh7B}@$TTPBmzDQ4^Bl5_ zdhy1~nZoSG`@s+qp*1nTtO}87+E8PRY6Qk8j8=q3Ep0xTZD()o^qK1~6u|Cosg|b1 z&Vl!|Mn}6@Xb}Mf5vss_fSu=60qFH;q$xN@Yj}8{41iD-8EnCMspn2e zb0259Z;Q(im$K8UB!kMGk&%7!=ciYb?xQP`=00{_@LuW)U_F^iqCihtYc3CknkdwS zfu?x#l>+$kY)-P=)6YD;%+u>TawqjmwN7$)iR;N!O>5PN0*wuI>-5~mPu>%2P4nC9 z^Ks^cEcZAk&5L(e4sRhiFnX!4Xbs*={lcAgvbkB3!3yK?+i%og{Q|&20)Vlx?y)$1 gY(UfeS^qcr0qhU*SLO1>FaQ7m07*qoM6N<$f>L}JD*ylh literal 0 HcmV?d00001 diff --git a/textures/Gabosburg Mods/replacer/textures/replacer_replacer.png b/textures/Gabosburg Mods/replacer/textures/replacer_replacer.png new file mode 100644 index 0000000000000000000000000000000000000000..c7b0c0b4373b94be05dae71b47a9366f372b6b33 GIT binary patch literal 234 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP~6E6e1zH^&OB~Yl`)5S5w;&gI?M8*M+u1Ej>$NW2N zYV@POjxwA)lEP!Sh<8Fq{6G2WiY$(6)}E?YS3URNz}e%Pj^O@3`zH%Mub;$h zcrEPd|I5q$B_)91+uh&iJT{&E|9|I$Et2cGHMU94pZ{@JgI?V+&N)*oPF}ZJz`$Uw WWfK!(xP=es1O`u6KbLh*2~7ZM>QhGm literal 0 HcmV?d00001 diff --git a/textures/legacy_textures/replacer_replacer.png b/textures/legacy_textures/replacer_replacer.png new file mode 100644 index 0000000000000000000000000000000000000000..0c5a4f8a105339eb2df5ef5d20e009c9ee03bec6 GIT binary patch literal 461 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPggq7I86gm1@DuMnF@1JzX3_EKVmU zNMsz4c#^yL_<;ijf{_JxuPOH!eA}FUe#Vj|Oa47HX=rS0T&NxU&wf+F%`@#iJV3D3 zzWKqUvu|EYY?M53FaixxXd2`d)O;dB_e~GvQ?9a~3JiKtxqEEjyPXDrh zWM0x5929gfv4T;IgX_kV|pv886= zA?EMT8yEb4!6swBi9L@&c-OP#{`3FcE`R^~|9r=zt1NQ<^<2OCV-MTrpFbwr{%_us z`%gJLtSIQw6E)R2eeySx9Ru}j>QeZvnSp>IGqK+(rTpbFU|2JFy85}Sb4q9e09ZfI A@&Et; literal 0 HcmV?d00001 diff --git a/textures/replacer_inspect.png b/textures/replacer_inspect.png index ea47b56083d17937d198fa323f83de0b35086da1..27ff1ff271b064bd4d80f7972a7c3018b1188332 100644 GIT binary patch literal 5821 zcmeHKX;f3!77jR|fFoLgf`m8#+KeP5HzqO#k_af1iate>n;W(vlqEOP#-9dgnPS+tSCEE^I7z-M%EOwq{$?0t@ra$yj7z^qsu;63uqUf^l*i zw9%q<8KLvZB0HNWD;w6WxrW{es9$e$aA^JT_WCVp!q!-`-Q?Rf+uDA*lE8uz7R?-g zA#_98H~Cm~WBL(oNz2&89Hvz!)m_VG4x4*-8bm)j!QCUYwW^7Sj1M>w|6+ZY(U@_W zO>WV7)!M4ec>jk;`<3+jIhz-j%{g^r!r1oX+n$dvD6%Rz*ofGrUq8-_k+-&;IfQS0 zswM6m`ZV#B4RJ@2(UPfG(PQ;VbDTyE*y6t38nLb$F|UZgtKBvz4 zMqb+BRG$OTpscaa*b$v;SFVq_ad^R`%8InGs)6D3qOgZ8%=(k-&u49ND2Z=1jsAV2 zeMQ#AD-OlDA!!@=&4OpQ#~)1DKOm`Da73JZdrRxif%Og99F@t{;j4^Pwq_Z}Z1G+p z)9{vunl`3AF!m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G*A~@0`E! zr?=ex#t4A=YmhI}_p4lA<@zE8z6kuay1vTwMGAZo_-l3j-{dm=@P>`Z!9RK$@cz8o z{csp~_Z}?v;q!3Ez%Op^xN|753{?u|sc|?n3;o9kmz`?~j3$`S&&#CMZ2U;FT}|BH zbHEfMv zJ)*n2{1JHYeSmf_)4OM>@Px>E?L+$sv!l*GHV%|Ych%kYZOe8oU*eUK*St1&6RZ2V lX-c|Hm~Wf$#MK>%18~MSxTI1e>m-l>PUtn0cfcbo>EA^3xO@Nr delta 570 zcmV-A0>%BkEz$&#BYy%JNkl)q41^(*8xPNYNWVrMV?ggC+iQ#E+HWnaE|hCPBMLR+x3;hrtcC95 z5&&nfbxBi5Q`l;a($73Ved^v?609ziYf8~5Si_JthdpN*oH}7w26LDe0TDPk6kxRD zd*3xW56bA!=zoR{G=<1CC+3%x_cZeyvW$B1#><()?8f`S5D}p@F~6(|k!jjcV~lD9 z#wd(dghnlGKACN2Z|(G%>n{|*?ry1;ro_&H_q0YwyH$X|sHMQD*b8V80R$1Mz9J()_PKu=n0E)Rv8DAa_3rg-y}0{HT5PO{w7&pf@%)9X8OC-qCU zPI7pO>&aA2Yt@JXjSY3{^xVf!-VFaQ7m07*qo IM6N<$g09FGPyhe` diff --git a/textures/replacer_replacer.png b/textures/replacer_replacer.png index 0c5a4f8a105339eb2df5ef5d20e009c9ee03bec6..b51a97232d87f255e568d7d734386ca242131e95 100644 GIT binary patch literal 5858 zcmeHKcUTkI7LNr)P(je8Jd_wI3Qij75H5Toe==Pb`#o6HxK3&wYO1+y9(=nan-+cYf#GbI&<9lN>O8 z>QGZVQydOARN%`G0>2jeuZc0ZJG|(Iakzm$#)gEdgJ3OQp_Gd;35r+8C{R4A!^Ak8 zuJ-=yc}mA^!#cx9?iuK4VR`P3?INvWz2~YGMJ38QWMVzVb1nawMZQIo@3&`v=kR*#w15iP+jz@5&$8{g>swd- zRCcexYlqp2}7tqGjXifE`{~;W{u{)@#Xk2O7chWp#tFh*@_Erw%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