forked from mtcontrib/replacer
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
23de5fe9c6
@ -1,5 +0,0 @@
|
|||||||
default?
|
|
||||||
dye?
|
|
||||||
moreblocks?
|
|
||||||
stairs?
|
|
||||||
stairsplus?
|
|
@ -52,7 +52,7 @@ replacer.set_to = function(player_name, pattern, player, itemstack)
|
|||||||
end
|
end
|
||||||
-- fallback if nothing is given
|
-- fallback if nothing is given
|
||||||
if(not(pattern)) then
|
if(not(pattern)) then
|
||||||
pattern = "default:dirt 0 0"
|
pattern = replacer.default_dirt.." 0 0"
|
||||||
end
|
end
|
||||||
|
|
||||||
local set_to = replacer.human_readable_pattern(pattern)
|
local set_to = replacer.human_readable_pattern(pattern)
|
||||||
@ -156,8 +156,8 @@ replacer.get_formspec = function(player_name, current_pattern, player)
|
|||||||
if(not(parts) or #parts<1) then
|
if(not(parts) or #parts<1) then
|
||||||
parts = {"does not exist"}
|
parts = {"does not exist"}
|
||||||
-- TODO: handle this in a more general way
|
-- TODO: handle this in a more general way
|
||||||
elseif(parts[1] == "default:dirt_with_grass") then
|
elseif(parts[1] == "default:dirt_with_grass" or parts[1] == "mcl_core:dirt_with_grass") then
|
||||||
parts[1] = "default:dirt"
|
parts[1] = replacer.default_dirt
|
||||||
end
|
end
|
||||||
if(counted_inv[ parts[1] ]) then
|
if(counted_inv[ parts[1] ]) then
|
||||||
amount_left = "#00FF00,"..tostring(counted_inv[ parts[1] ]).." available:"..
|
amount_left = "#00FF00,"..tostring(counted_inv[ parts[1] ]).." available:"..
|
||||||
|
26
init.lua
26
init.lua
@ -48,6 +48,8 @@ dofile(minetest.get_modpath("replacer").."/check_owner.lua");
|
|||||||
|
|
||||||
replacer = {};
|
replacer = {};
|
||||||
|
|
||||||
|
replacer.default_dirt = "default:dirt"
|
||||||
|
|
||||||
replacer.blacklist = {};
|
replacer.blacklist = {};
|
||||||
|
|
||||||
-- playing with tnt and creative building are usually contradictory
|
-- playing with tnt and creative building are usually contradictory
|
||||||
@ -119,7 +121,7 @@ minetest.register_tool( "replacer:replacer",
|
|||||||
local pos = minetest.get_pointed_thing_position( pointed_thing, false ); -- node under
|
local pos = minetest.get_pointed_thing_position( pointed_thing, false ); -- node under
|
||||||
local node = minetest.get_node_or_nil( pos );
|
local node = minetest.get_node_or_nil( pos );
|
||||||
|
|
||||||
local pattern = "default:dirt 0 0";
|
local pattern = replacer.default_dirt.." 0 0";
|
||||||
if( node ~= nil and node.name ) then
|
if( node ~= nil and node.name ) then
|
||||||
pattern = node.name..' '..node.param1..' '..node.param2;
|
pattern = node.name..' '..node.param1..' '..node.param2;
|
||||||
end
|
end
|
||||||
@ -162,7 +164,7 @@ replacer.replace = function( itemstack, user, pointed_thing, mode )
|
|||||||
|
|
||||||
-- make sure it is defined
|
-- make sure it is defined
|
||||||
if(not(pattern) or pattern == "") then
|
if(not(pattern) or pattern == "") then
|
||||||
pattern = "default:dirt 0 0";
|
pattern = replacer.default_dirt.." 0 0";
|
||||||
end
|
end
|
||||||
|
|
||||||
local keys=user:get_player_control();
|
local keys=user:get_player_control();
|
||||||
@ -220,9 +222,9 @@ replacer.replace = function( itemstack, user, pointed_thing, mode )
|
|||||||
|
|
||||||
-- players usually don't carry dirt_with_grass around; it's safe to assume normal dirt here
|
-- 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
|
-- fortunately, dirt and dirt_with_grass does not make use of rotation
|
||||||
if( daten[1] == "default:dirt_with_grass" ) then
|
if( daten[1] == "default:dirt_with_grass" or daten[1] == "mcl_core:dirt_with_grass") then
|
||||||
daten[1] = "default:dirt";
|
daten[1] = replacer.default_dirt
|
||||||
pattern = "default:dirt 0 0";
|
pattern = replacer.default_dirt.." 0 0";
|
||||||
end
|
end
|
||||||
|
|
||||||
-- does the player carry at least one of the desired nodes with him?
|
-- does the player carry at least one of the desired nodes with him?
|
||||||
@ -263,6 +265,19 @@ replacer.replace = function( itemstack, user, pointed_thing, mode )
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- do the exception for MineClone first...
|
||||||
|
if(minetest.registered_nodes["mcl_chests:chest"]) then
|
||||||
|
replacer.default_dirt = "mcl_core:dirt"
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'replacer:replacer',
|
||||||
|
recipe = {
|
||||||
|
{ 'mcl_chests:chest', '', '' },
|
||||||
|
{ '', 'mcl_core:stick', '' },
|
||||||
|
{ '', '', 'mcl_chests:chest' },
|
||||||
|
}
|
||||||
|
})
|
||||||
|
-- then the normal receipe
|
||||||
|
elseif(minetest.registered_nodes["default:chest"]) then
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'replacer:replacer',
|
output = 'replacer:replacer',
|
||||||
recipe = {
|
recipe = {
|
||||||
@ -271,5 +286,6 @@ minetest.register_craft({
|
|||||||
{ '', '', 'default:chest' },
|
{ '', '', 'default:chest' },
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
end
|
||||||
|
|
||||||
minetest.log("action", "[replacer] loaded.")
|
minetest.log("action", "[replacer] loaded.")
|
||||||
|
62
inspect.lua
62
inspect.lua
@ -7,14 +7,18 @@ if( minetest.get_modpath("trees")
|
|||||||
and minetest.get_modpath("instruments")
|
and minetest.get_modpath("instruments")
|
||||||
and minetest.get_modpath("anvil")
|
and minetest.get_modpath("anvil")
|
||||||
and minetest.get_modpath("scribing_table")) then
|
and minetest.get_modpath("scribing_table")) then
|
||||||
replacer.image_replacements[ "group:planks" ] = "trees:pine_planks";
|
-- replacer.image_replacements[ "group:planks" ] = "trees:pine_planks";
|
||||||
replacer.image_replacements[ "group:plank" ] = "trees:pine_plank";
|
-- replacer.image_replacements[ "group:plank" ] = "trees:pine_plank";
|
||||||
replacer.image_replacements[ "group:wood" ] = "trees:pine_planks";
|
-- replacer.image_replacements[ "group:wood" ] = "trees:pine_planks";
|
||||||
replacer.image_replacements[ "group:tree" ] = "trees:pine_log";
|
-- replacer.image_replacements[ "group:tree" ] = "trees:pine_log";
|
||||||
replacer.image_replacements[ "group:sapling"] = "trees:pine_sapling";
|
-- replacer.image_replacements[ "group:sapling"] = "trees:pine_sapling";
|
||||||
replacer.image_replacements[ "group:leaves" ] = "trees:pine_leaves";
|
-- replacer.image_replacements[ "group:leaves" ] = "trees:pine_leaves";
|
||||||
replacer.image_replacements[ "default:furnace" ] = "oven:oven";
|
replacer.image_replacements[ "default:furnace" ] = "oven:oven";
|
||||||
replacer.image_replacements[ "default:furnace_active" ] = "oven:oven_active";
|
replacer.image_replacements[ "default:furnace_active" ] = "oven:oven_active";
|
||||||
|
-- MineClone
|
||||||
|
elseif(minetest.registered_items["mcl_furnaces:furnace"]) then
|
||||||
|
replacer.image_replacements[ "default:furnace" ] = "mcl_furnaces:furnace"
|
||||||
|
replacer.image_replacements[ "default:furnace_active" ] = "mcl_furnaces:furnace_active"
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_tool( "replacer:inspect",
|
minetest.register_tool( "replacer:inspect",
|
||||||
@ -86,6 +90,10 @@ replacer.inspect = function( itemstack, user, pointed_thing, mode, show_receipe
|
|||||||
if( sdata.age ) then
|
if( sdata.age ) then
|
||||||
text = text..', dropped '..tostring( math.floor( sdata.age/60 ))..' minutes ago';
|
text = text..', dropped '..tostring( math.floor( sdata.age/60 ))..' minutes ago';
|
||||||
end
|
end
|
||||||
|
-- show the owner of an entity
|
||||||
|
if( sdata.owner ) then
|
||||||
|
text = text..' (owned by '..minetest.formspec_escape(sdata.owner)..")"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
text = text..'object \"'..tostring( ref:get_entity_name() )..'\"';
|
text = text..'object \"'..tostring( ref:get_entity_name() )..'\"';
|
||||||
@ -164,14 +172,38 @@ if( minetest.get_modpath("dye") and dye and dye.basecolors) then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- find the first known member of a group as an example/representative
|
||||||
|
replacer.get_first_group_member = function(group_name)
|
||||||
|
for k,v in pairs(minetest.registered_items) do
|
||||||
|
if(v and v.groups and v.groups[group_name] and v.groups[group_name] > 0) then
|
||||||
|
return k
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- nothing found
|
||||||
|
return group_name
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
replacer.image_button_link = function( stack_string )
|
replacer.image_button_link = function( stack_string )
|
||||||
local group = '';
|
local group = '';
|
||||||
if( replacer.image_replacements[ stack_string ] ) then
|
if( replacer.image_replacements[ stack_string ] ) then
|
||||||
stack_string = replacer.image_replacements[ stack_string ];
|
stack_string = replacer.image_replacements[ stack_string ];
|
||||||
end
|
end
|
||||||
|
replacer.group_placeholder[ 'group:wood_slab'] = 'stairs:slab_wood';
|
||||||
|
|
||||||
|
-- if it is a group
|
||||||
|
if( string.sub(stack_string, 1, 6) == "group:"
|
||||||
|
-- ..and there is no known member of that group yet
|
||||||
|
and (not(replacer.group_placeholder[ stack_string ])
|
||||||
|
-- or the known member does not exist
|
||||||
|
or not(minetest.registered_items[ replacer.group_placeholder[ stack_string ]]))) then
|
||||||
|
-- find and store a suitable group member as example
|
||||||
|
replacer.group_placeholder[ stack_string ] = replacer.get_first_group_member(string.sub(stack_string, 7))
|
||||||
|
end
|
||||||
if(replacer.group_placeholder[ stack_string ] ) then
|
if(replacer.group_placeholder[ stack_string ] ) then
|
||||||
|
group = 'Group\n'..minetest.formspec_escape(string.sub(stack_string, 7))
|
||||||
stack_string = replacer.group_placeholder[ stack_string ];
|
stack_string = replacer.group_placeholder[ stack_string ];
|
||||||
group = 'G';
|
|
||||||
end
|
end
|
||||||
-- TODO: show information about other groups not handled above
|
-- TODO: show information about other groups not handled above
|
||||||
local stack = ItemStack( stack_string );
|
local stack = ItemStack( stack_string );
|
||||||
@ -299,9 +331,9 @@ replacer.inspect_show_crafting = function( name, node_name, fields )
|
|||||||
-- provide additional information regarding the node in particular that has been inspected
|
-- provide additional information regarding the node in particular that has been inspected
|
||||||
if( fields.pos ) then
|
if( fields.pos ) then
|
||||||
formspec = formspec.."label[0.0,0.3;Located at "..
|
formspec = formspec.."label[0.0,0.3;Located at "..
|
||||||
minetest.formspec_escape( minetest.pos_to_string( fields.pos ));
|
minetest.formspec_escape( minetest.pos_to_string( fields.pos )).."]"
|
||||||
if( fields.param2 ) then
|
if( fields.param2 ) then
|
||||||
formspec = formspec.." with param2="..tostring( fields.param2 );
|
formspec = formspec.."label[0.0,0.6;with param2="..tostring( fields.param2 )
|
||||||
end
|
end
|
||||||
if( fields.light ) then
|
if( fields.light ) then
|
||||||
formspec = formspec.." and receiving "..tostring( fields.light ).." light";
|
formspec = formspec.." and receiving "..tostring( fields.light ).." light";
|
||||||
@ -405,6 +437,17 @@ end
|
|||||||
minetest.register_on_player_receive_fields( replacer.form_input_handler );
|
minetest.register_on_player_receive_fields( replacer.form_input_handler );
|
||||||
|
|
||||||
|
|
||||||
|
-- do the exception for MineClone first...
|
||||||
|
if(minetest.registered_items["mcl_core:stick"]) then
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'replacer:inspect',
|
||||||
|
recipe = {
|
||||||
|
{ 'mcl_torches:torch' },
|
||||||
|
{ 'mcl_core:stick' },
|
||||||
|
}
|
||||||
|
})
|
||||||
|
-- ..then the normal version
|
||||||
|
elseif(minetest.registered_nodes["default:torch"]) then
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'replacer:inspect',
|
output = 'replacer:inspect',
|
||||||
recipe = {
|
recipe = {
|
||||||
@ -412,3 +455,4 @@ minetest.register_craft({
|
|||||||
{ 'default:stick' },
|
{ 'default:stick' },
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
end
|
||||||
|
2
mod.conf
2
mod.conf
@ -1,5 +1,5 @@
|
|||||||
name = replacer
|
name = replacer
|
||||||
description = Essential tool for builders. Allows to store material and rotation and place more blocks the same way without having to turn them all individually with the screwdriver.
|
description = Essential tool for builders. Allows to store material and rotation and place more blocks the same way without having to turn them all individually with the screwdriver.
|
||||||
optional_depends = default, dye, moreblocks, stairs, stairsplus
|
optional_depends = default, dye, moreblocks, stairs, stairsplus, mcl_core, mcl_chests
|
||||||
author = Sokomine
|
author = Sokomine
|
||||||
title = Replacer - Node Replace Tool
|
title = Replacer - Node Replace Tool
|
||||||
|
Loading…
Reference in New Issue
Block a user